From ebd184e14ab4a0a49eab6f45060356e3058f9db7 Mon Sep 17 00:00:00 2001 From: Udhay-Adithya Date: Wed, 3 Sep 2025 23:26:26 +0530 Subject: [PATCH] refactor: replace TextButton with HomeScreenTaskButton in home page --- .../core/model/dashbot_window_model.dart | 8 +- .../features/home/view/pages/home_page.dart | 81 ++++--------------- .../view/widgets/home_screen_task_button.dart | 34 ++++++++ 3 files changed, 57 insertions(+), 66 deletions(-) create mode 100644 lib/dashbot/features/home/view/widgets/home_screen_task_button.dart diff --git a/lib/dashbot/core/model/dashbot_window_model.dart b/lib/dashbot/core/model/dashbot_window_model.dart index e9ef2123..be46e948 100644 --- a/lib/dashbot/core/model/dashbot_window_model.dart +++ b/lib/dashbot/core/model/dashbot_window_model.dart @@ -4,13 +4,15 @@ class DashbotWindowModel { final double right; final double bottom; final bool isActive; + final bool isPopped; const DashbotWindowModel({ - this.width = 350, - this.height = 450, + this.width = 375, + this.height = 460, this.right = 50, this.bottom = 100, this.isActive = false, + this.isPopped = false, }); DashbotWindowModel copyWith({ @@ -19,6 +21,7 @@ class DashbotWindowModel { double? right, double? bottom, bool? isActive, + bool? isPopped, }) { return DashbotWindowModel( width: width ?? this.width, @@ -26,6 +29,7 @@ class DashbotWindowModel { right: right ?? this.right, bottom: bottom ?? this.bottom, isActive: isActive ?? this.isActive, + isPopped: isPopped ?? this.isPopped, ); } } diff --git a/lib/dashbot/features/home/view/pages/home_page.dart b/lib/dashbot/features/home/view/pages/home_page.dart index bdd5c9d8..8d092c69 100644 --- a/lib/dashbot/features/home/view/pages/home_page.dart +++ b/lib/dashbot/features/home/view/pages/home_page.dart @@ -9,6 +9,7 @@ import 'package:apidash_design_system/tokens/measurements.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../../../chat/models/chat_models.dart'; +import '../widgets/home_screen_task_button.dart'; class DashbotHomePage extends ConsumerStatefulWidget { const DashbotHomePage({super.key}); @@ -48,97 +49,49 @@ class _DashbotHomePageState extends ConsumerState { spacing: 8, runSpacing: 8, children: [ - // TextButton( - // onPressed: () { - // Navigator.of(context).pushNamed( - // DashbotRoutes.dashbotChat, - // ); - // }, - // style: TextButton.styleFrom( - // side: BorderSide( - // color: Theme.of(context).colorScheme.primary, - // ), - // padding: const EdgeInsets.symmetric( - // vertical: 0, - // horizontal: 16, - // ), - // ), - // child: const Text("🤖 Chat with Dashbot"), - // ), - TextButton( + HomeScreenTaskButton( + label: "🤖 Chat with Dashbot", + onPressed: () { + Navigator.of(context).pushNamed( + DashbotRoutes.dashbotChat, + ); + }, + ), + HomeScreenTaskButton( + label: "🔎 Explain me this response", onPressed: () { Navigator.of(context).pushNamed( DashbotRoutes.dashbotChat, arguments: ChatMessageType.explainResponse, ); }, - style: TextButton.styleFrom( - side: BorderSide( - color: Theme.of(context).colorScheme.primary, - ), - padding: const EdgeInsets.symmetric( - vertical: 0, - horizontal: 16, - ), - ), - child: const Text("🔎 Explain me this response"), ), - TextButton( + HomeScreenTaskButton( + label: "🐞 Help me debug this error", 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( + HomeScreenTaskButton( + label: "📄 Generate documentation", onPressed: () { Navigator.of(context).pushNamed( DashbotRoutes.dashbotChat, arguments: ChatMessageType.general, ); }, - style: TextButton.styleFrom( - side: BorderSide( - color: Theme.of(context).colorScheme.primary, - ), - padding: const EdgeInsets.symmetric( - vertical: 0, - horizontal: 16, - ), - ), - child: const Text( - "📄 Generate documentation", - textAlign: TextAlign.center, - ), ), - TextButton( + HomeScreenTaskButton( + label: "📝 Generate Tests", onPressed: () { Navigator.of(context).pushNamed( DashbotRoutes.dashbotChat, arguments: ChatMessageType.generateTest, ); }, - style: TextButton.styleFrom( - side: BorderSide( - color: Theme.of(context).colorScheme.primary, - ), - padding: const EdgeInsets.symmetric( - vertical: 0, - horizontal: 16, - ), - ), - child: const Text("📝 Generate Tests"), ), if (currentRequest?.httpResponseModel?.statusCode != null && currentRequest?.httpResponseModel?.statusCode == 200) ...[ diff --git a/lib/dashbot/features/home/view/widgets/home_screen_task_button.dart b/lib/dashbot/features/home/view/widgets/home_screen_task_button.dart new file mode 100644 index 00000000..881a96b8 --- /dev/null +++ b/lib/dashbot/features/home/view/widgets/home_screen_task_button.dart @@ -0,0 +1,34 @@ +import 'package:flutter/material.dart'; + +class HomeScreenTaskButton extends StatelessWidget { + const HomeScreenTaskButton({ + super.key, + required this.label, + required this.onPressed, + this.textAlign = TextAlign.center, + }); + + final String label; + final VoidCallback onPressed; + final TextAlign textAlign; + + @override + Widget build(BuildContext context) { + return TextButton( + onPressed: onPressed, + style: TextButton.styleFrom( + side: BorderSide( + color: Theme.of(context).colorScheme.primary, + ), + padding: const EdgeInsets.symmetric( + vertical: 0, + horizontal: 16, + ), + ), + child: Text( + label, + textAlign: textAlign, + ), + ); + } +}