From 22f37276773e166307fff69cc82249566a438657 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Thu, 22 Oct 2026 11:48:56 +0300 Subject: [PATCH] ai option in action bar added. --- .../copilot/screens/copilot_chat_page.dart | 1 + .../screens/copilot_push_to_talk_page.dart | 5 ++- .../device_transfer/device_filter_screen.dart | 1 + .../device_transfer/device_search_screen.dart | 1 + .../common_widgets/default_app_bar.dart | 32 +++++++++++++++++-- .../my_request/all_requests_filter_page.dart | 1 + .../my_request/all_requests_search_page.dart | 1 + 7 files changed, 39 insertions(+), 3 deletions(-) diff --git a/lib/modules/copilot/screens/copilot_chat_page.dart b/lib/modules/copilot/screens/copilot_chat_page.dart index f1c60a6d..80e5a312 100644 --- a/lib/modules/copilot/screens/copilot_chat_page.dart +++ b/lib/modules/copilot/screens/copilot_chat_page.dart @@ -132,6 +132,7 @@ class _CopilotChatPageState extends State { return Scaffold( appBar: DefaultAppBar( title: "ATOMS – AI Assistant", + showCopilot: false, actions: [ IconButton( onPressed: () => Navigator.push(context, MaterialPageRoute(builder: (_) => const CopilotLiveTalkPage())), diff --git a/lib/modules/copilot/screens/copilot_push_to_talk_page.dart b/lib/modules/copilot/screens/copilot_push_to_talk_page.dart index a451f4eb..49163508 100644 --- a/lib/modules/copilot/screens/copilot_push_to_talk_page.dart +++ b/lib/modules/copilot/screens/copilot_push_to_talk_page.dart @@ -122,7 +122,10 @@ class _CopilotPushToTalkPageState extends State with Widg @override Widget build(BuildContext context) { return Scaffold( - appBar: const DefaultAppBar(title: "Push to Talk"), + appBar: const DefaultAppBar( + title: "Push to Talk", + showCopilot: false, + ), body: Column( children: [ Expanded( diff --git a/lib/modules/tm_module/device_transfer/device_filter_screen.dart b/lib/modules/tm_module/device_transfer/device_filter_screen.dart index 04802a5e..63b81a50 100644 --- a/lib/modules/tm_module/device_transfer/device_filter_screen.dart +++ b/lib/modules/tm_module/device_transfer/device_filter_screen.dart @@ -92,6 +92,7 @@ class _DeviceFilterScreenState extends State { appBar: DefaultAppBar( title: context.translation.filter, showBackButtonAsCancel: true, + showCopilot: false, actions: [ if (loading == false && _showResetButton()) TextButton( diff --git a/lib/modules/tm_module/device_transfer/device_search_screen.dart b/lib/modules/tm_module/device_transfer/device_search_screen.dart index 88050fb2..3aaf5e13 100644 --- a/lib/modules/tm_module/device_transfer/device_search_screen.dart +++ b/lib/modules/tm_module/device_transfer/device_search_screen.dart @@ -62,6 +62,7 @@ class _DeviceSearchScreenState extends State { appBar: DefaultAppBar( title: context.translation.search, showBackButtonAsCancel: true, + showCopilot: false, actions: [ if (_showResetButton()) TextButton( diff --git a/lib/new_views/common_widgets/default_app_bar.dart b/lib/new_views/common_widgets/default_app_bar.dart index d3c1c90d..d21bf769 100644 --- a/lib/new_views/common_widgets/default_app_bar.dart +++ b/lib/new_views/common_widgets/default_app_bar.dart @@ -1,10 +1,13 @@ import 'dart:io'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; +import 'package:test_sa/modules/copilot/controller/copilot_provider.dart'; +import 'package:test_sa/modules/copilot/screens/copilot_chat_page.dart'; import 'package:test_sa/new_views/pages/land_page/land_page.dart'; import 'package:test_sa/new_views/swipe_module/dialoge/acknowledge_work_dialog.dart'; @@ -20,9 +23,20 @@ class DefaultAppBar extends StatelessWidget implements PreferredSizeWidget { final VoidCallback? onWillPopScope; final TextStyle? titleStyle; final bool showBackButtonAsCancel; + final bool showCopilot; const DefaultAppBar( - {this.title, this.onBackPress, this.onWillPopScope, this.actions, this.titleStyle, this.showHomeActionButton = false, this.showBackButton = true,this.backgroundColor, this.showBackButtonAsCancel = false, Key? key}) + {this.title, + this.onBackPress, + this.onWillPopScope, + this.actions, + this.titleStyle, + this.showHomeActionButton = false, + this.showCopilot = true, + this.showBackButton = true, + this.backgroundColor, + this.showBackButtonAsCancel = false, + Key? key}) : super(key: key); @override @@ -44,10 +58,24 @@ class DefaultAppBar extends StatelessWidget implements PreferredSizeWidget { if (actions?.isNotEmpty ?? false) { _actions.addAll(actions!); } + if (showCopilot) { + _actions.add( + IconButton( + icon: "atoms_ai".toSvgAsset(), + padding: EdgeInsets.zero, + iconSize: 20, + visualDensity: VisualDensity.compact, + tooltip: "Barq", + onPressed: (() { + context.read().startNewConversation(); + Navigator.push(context, MaterialPageRoute(builder: (_) => const CopilotChatPage(isNewConversation: true))).then((_) => context.read().loadHistory()); + })), + ); + } return AppBar( automaticallyImplyLeading: false, titleSpacing: 16, - backgroundColor:backgroundColor, + backgroundColor: backgroundColor, title: Row( children: [ if (showBackButton) diff --git a/lib/new_views/pages/land_page/my_request/all_requests_filter_page.dart b/lib/new_views/pages/land_page/my_request/all_requests_filter_page.dart index 93a22f8b..1c5c8171 100644 --- a/lib/new_views/pages/land_page/my_request/all_requests_filter_page.dart +++ b/lib/new_views/pages/land_page/my_request/all_requests_filter_page.dart @@ -179,6 +179,7 @@ class _AllRequestsFilterPageState extends State { return Scaffold( appBar: DefaultAppBar( title: context.translation.filter,showBackButtonAsCancel: true, + showCopilot: false, actions: [ if (_showResetButton()) TextButton( diff --git a/lib/new_views/pages/land_page/my_request/all_requests_search_page.dart b/lib/new_views/pages/land_page/my_request/all_requests_search_page.dart index 1f430cdb..52af99fb 100644 --- a/lib/new_views/pages/land_page/my_request/all_requests_search_page.dart +++ b/lib/new_views/pages/land_page/my_request/all_requests_search_page.dart @@ -93,6 +93,7 @@ class _AllRequestsSearchPageState extends State { appBar: DefaultAppBar( title: context.translation.search, showBackButtonAsCancel: true, + showCopilot: false, actions: [ if (_showResetButton()) TextButton(