From 0490163584480a60d6977106d7974fa015e23b5b Mon Sep 17 00:00:00 2001 From: Udhay-Adithya Date: Wed, 3 Sep 2025 10:59:03 +0530 Subject: [PATCH] refactor: move generate buttons to dashbot --- .../providers/dashbot_window_notifier.dart | 2 +- .../features/home/view/pages/home_page.dart | 75 ++++++++++++------- 2 files changed, 48 insertions(+), 29 deletions(-) diff --git a/lib/dashbot/core/providers/dashbot_window_notifier.dart b/lib/dashbot/core/providers/dashbot_window_notifier.dart index 7640fb39..d1c5baa1 100644 --- a/lib/dashbot/core/providers/dashbot_window_notifier.dart +++ b/lib/dashbot/core/providers/dashbot_window_notifier.dart @@ -16,7 +16,7 @@ class DashbotWindowNotifier extends StateNotifier { final newWidth = (state.width - dx).clamp(300, screenSize.width - state.right); final newHeight = - (state.height - dy).clamp(350, screenSize.height - state.bottom); + (state.height - dy).clamp(460, screenSize.height - state.bottom); state = state.copyWith( width: newWidth.toDouble(), diff --git a/lib/dashbot/features/home/view/pages/home_page.dart b/lib/dashbot/features/home/view/pages/home_page.dart index 0c9541ef..79def0fc 100644 --- a/lib/dashbot/features/home/view/pages/home_page.dart +++ b/lib/dashbot/features/home/view/pages/home_page.dart @@ -1,3 +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 '../../../../core/utils/dashbot_icons.dart'; import '../../../../core/routes/dashbot_routes.dart'; @@ -16,13 +20,22 @@ class DashbotHomePage extends ConsumerStatefulWidget { class _DashbotHomePageState extends ConsumerState { @override Widget build(BuildContext context) { + final currentRequest = ref.watch(selectedRequestModelProvider); + + // ref.listen( + // selectedRequestModelProvider, + // (current, next) { + // if (current?.id != next?.id) { + // Navigator.pop(context); + // } + // }, + // ); return Container( padding: const EdgeInsets.all(16), child: Column( children: [ kVSpacer16, DashbotIcons.getDashbotIcon1(width: 60), - kVSpacer16, Text( 'Hello there,', @@ -70,21 +83,31 @@ class _DashbotHomePageState extends ConsumerState { ), child: const Text("🔎 Explain me this response"), ), - // TextButton( - // onPressed: () {}, - // style: TextButton.styleFrom( - // side: BorderSide( - // color: Theme.of(context).colorScheme.primary, - // ), - // padding: const EdgeInsets.symmetric( - // vertical: 0, - // horizontal: 16, - // ), - // ), - // child: const Text("🐞 Help me debug this error"), - // ), TextButton( - onPressed: () {}, + onPressed: () { + Navigator.of(context).pushNamed( + DashbotRoutes.dashbotChat, + arguments: ChatMessageType.debugError, + ); + }, + style: TextButton.styleFrom( + side: BorderSide( + color: Theme.of(context).colorScheme.primary, + ), + padding: const EdgeInsets.symmetric( + vertical: 0, + horizontal: 16, + ), + ), + child: const Text("🐞 Help me debug this error"), + ), + TextButton( + onPressed: () { + Navigator.of(context).pushNamed( + DashbotRoutes.dashbotChat, + arguments: ChatMessageType.general, + ); + }, style: TextButton.styleFrom( side: BorderSide( color: Theme.of(context).colorScheme.primary, @@ -117,19 +140,15 @@ class _DashbotHomePageState extends ConsumerState { ), child: const Text("📝 Generate Tests"), ), - // TextButton( - // onPressed: () {}, - // style: TextButton.styleFrom( - // side: BorderSide( - // color: Theme.of(context).colorScheme.primary, - // ), - // padding: const EdgeInsets.symmetric( - // vertical: 0, - // horizontal: 16, - // ), - // ), - // child: const Text("📊 Generate Visualizations"), - // ), + if (currentRequest?.httpResponseModel?.statusCode != null && + currentRequest?.httpResponseModel?.statusCode == 200) ...[ + Expanded( + child: GenerateToolButton(), + ), + Expanded( + child: AIGenerateUIButton(), + ), + ], ], ), ],