diff --git a/lib/dashbot/dashbot_dashboard.dart b/lib/dashbot/dashbot_dashboard.dart index 276512ee..5f005cdd 100644 --- a/lib/dashbot/dashbot_dashboard.dart +++ b/lib/dashbot/dashbot_dashboard.dart @@ -144,6 +144,10 @@ class DashbotWindow extends ConsumerWidget { .read(dashbotWindowNotifierProvider .notifier) .togglePopped(); + ref + .read(dashbotWindowNotifierProvider + .notifier) + .toggleActive(); }, ), IconButton( diff --git a/lib/dashbot/features/home/view/pages/home_page.dart b/lib/dashbot/features/home/view/pages/home_page.dart index 9fe0096b..8dfc13ec 100644 --- a/lib/dashbot/features/home/view/pages/home_page.dart +++ b/lib/dashbot/features/home/view/pages/home_page.dart @@ -1,6 +1,7 @@ import 'package:apidash/providers/collection_providers.dart'; import 'package:apidash/screens/common_widgets/agentic_ui_features/ai_ui_designer/generate_ui_dialog.dart'; import 'package:apidash/screens/common_widgets/agentic_ui_features/tool_generation/generate_tool_dialog.dart'; +import 'package:flutter/foundation.dart'; import '../../../../core/utils/dashbot_icons.dart'; import '../../../../core/providers/dashbot_window_notifier.dart'; @@ -22,11 +23,11 @@ class DashbotHomePage extends ConsumerStatefulWidget { class _DashbotHomePageState extends ConsumerState { @override Widget build(BuildContext context) { - final hasOkResponse = ref.watch( - selectedRequestModelProvider.select((req) => - req?.httpResponseModel?.statusCode != null && - req?.httpResponseModel?.statusCode == 200), - ); + // final hasOkResponse = ref.watch( + // selectedRequestModelProvider.select((req) => + // req?.httpResponseModel?.statusCode != null && + // req?.httpResponseModel?.statusCode == 200), + // ); // ref.listen( // selectedRequestModelProvider, @@ -54,32 +55,16 @@ class _DashbotHomePageState extends ConsumerState { spacing: 8, runSpacing: 8, children: [ - HomeScreenTaskButton( - label: "🤖 Chat with Dashbot", - onPressed: () { - Navigator.of(context).pushNamed( - DashbotRoutes.dashbotChat, - ); - }, - ), - HomeScreenTaskButton( - label: "📥 Import cURL", - onPressed: () { - Navigator.of(context).pushNamed( - DashbotRoutes.dashbotChat, - arguments: ChatMessageType.importCurl, - ); - }, - ), - HomeScreenTaskButton( - label: "📄 Import OpenAPI", - onPressed: () { - Navigator.of(context).pushNamed( - DashbotRoutes.dashbotChat, - arguments: ChatMessageType.importOpenApi, - ); - }, - ), + if (kDebugMode) ...[ + HomeScreenTaskButton( + label: "🤖 Chat with Dashbot", + onPressed: () { + Navigator.of(context).pushNamed( + DashbotRoutes.dashbotChat, + ); + }, + ), + ], HomeScreenTaskButton( label: "🔎 Explain me this response", onPressed: () { @@ -125,43 +110,59 @@ class _DashbotHomePageState extends ConsumerState { ); }, ), - if (hasOkResponse) ...[ - HomeScreenTaskButton( - label: "🛠️ Generate Tool", - onPressed: () async { - final notifier = - ref.read(dashbotWindowNotifierProvider.notifier); - notifier.hide(); - await GenerateToolDialog.show(context, ref); - notifier.show(); - }, - ), - HomeScreenTaskButton( - label: "📱 Generate UI", - onPressed: () async { - final notifier = - ref.read(dashbotWindowNotifierProvider.notifier); - notifier.hide(); - final model = ref.watch(selectedRequestModelProvider - .select((value) => value?.httpResponseModel)); - if (model == null) return; + HomeScreenTaskButton( + label: "📥 Import cURL", + onPressed: () { + Navigator.of(context).pushNamed( + DashbotRoutes.dashbotChat, + arguments: ChatMessageType.importCurl, + ); + }, + ), + HomeScreenTaskButton( + label: "📄 Import OpenAPI", + onPressed: () { + Navigator.of(context).pushNamed( + DashbotRoutes.dashbotChat, + arguments: ChatMessageType.importOpenApi, + ); + }, + ), + HomeScreenTaskButton( + label: "🛠️ Generate Tool", + onPressed: () async { + final notifier = + ref.read(dashbotWindowNotifierProvider.notifier); + notifier.hide(); + await GenerateToolDialog.show(context, ref); + notifier.show(); + }, + ), + HomeScreenTaskButton( + label: "📱 Generate UI", + onPressed: () async { + final notifier = + ref.read(dashbotWindowNotifierProvider.notifier); + notifier.hide(); + final model = ref.watch(selectedRequestModelProvider + .select((value) => value?.httpResponseModel)); + if (model == null) return; - String data = ""; - if (model.sseOutput != null) { - data = model.sseOutput!.join(''); - } else { - data = model.formattedBody ?? "<>"; - } + String data = ""; + if (model.sseOutput != null) { + data = model.sseOutput!.join(''); + } else { + data = model.formattedBody ?? "<>"; + } - await showCustomDialog( - context, - GenerateUIDialog(content: data), - useRootNavigator: true, - ); - notifier.show(); - }, - ), - ], + await showCustomDialog( + context, + GenerateUIDialog(content: data), + useRootNavigator: true, + ); + notifier.show(); + }, + ), ], ), ], diff --git a/lib/screens/dashboard.dart b/lib/screens/dashboard.dart index 3ba4ee1e..6c612821 100644 --- a/lib/screens/dashboard.dart +++ b/lib/screens/dashboard.dart @@ -19,6 +19,8 @@ class Dashboard extends ConsumerWidget { final railIdx = ref.watch(navRailIndexStateProvider); final isDashBotEnabled = ref.watch(settingsProvider.select((value) => value.isDashBotEnabled)); + final isDashBotActive = ref + .watch(dashbotWindowNotifierProvider.select((value) => value.isActive)); return Scaffold( body: SafeArea( child: Row( @@ -127,7 +129,7 @@ class Dashboard extends ConsumerWidget { ], ), ), - floatingActionButton: isDashBotEnabled + floatingActionButton: isDashBotEnabled && !isDashBotActive ? FloatingActionButton( backgroundColor: Theme.of(context).colorScheme.primaryContainer, onPressed: () => showDashbotWindow(context, ref),