diff --git a/lib/ui/chatbot/chatbot_screen.dart b/lib/ui/chatbot/chatbot_screen.dart index a41b3d2..964eaa2 100644 --- a/lib/ui/chatbot/chatbot_screen.dart +++ b/lib/ui/chatbot/chatbot_screen.dart @@ -1,5 +1,6 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:flutter_svg/svg.dart'; import 'package:mohem_flutter_app/api/dashboard_api_client.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; @@ -11,6 +12,11 @@ import 'package:mohem_flutter_app/models/generic_response_model.dart'; import 'package:speech_to_text/speech_recognition_result.dart'; import 'package:speech_to_text/speech_to_text.dart'; + +class MessagesHolder{ + static List messages = []; +} + enum ChatMode { home, chatActive } class ChatMessage { @@ -51,6 +57,13 @@ class _ChatBotScreenState extends State { /// Initialize speech to text void _initSpeech() async { _speechEnabled = await _speechToText.initialize(); + + if(MessagesHolder.messages.isNotEmpty){ + setState(() { + _messages.addAll(MessagesHolder.messages); + _currentMode = ChatMode.chatActive; + }); + } setState(() {}); } @@ -159,9 +172,26 @@ class _ChatBotScreenState extends State { return Scaffold( backgroundColor: MyColors.backgroundColor, appBar: AppBar( + automaticallyImplyLeading: false, title: Text(LocaleKeys.chatBot.tr(), style: const TextStyle(fontSize: 24, fontWeight: FontWeight.w700, color: Color(0xFF2B353E))), backgroundColor: MyColors.backgroundColor, centerTitle: false, + actions: [ + IconButton( + icon: const Icon(Icons.minimize, color: Color(0xFF2B353E)), + onPressed: () { + MessagesHolder.messages = _messages; + Navigator.of(context).pop(); + }, + ), + IconButton( + icon: const Icon(Icons.close, color: Color(0xFF2B353E)), + onPressed: () { + MessagesHolder.messages.clear(); + Navigator.of(context).pop(); + }, + ), + ], ), body: Column(children: [Expanded(child: _currentMode == ChatMode.home ? _buildHomeMode() : _buildChatMode()), _buildBottomInputBar()]), ); @@ -464,3 +494,6 @@ class _AnimatedMessageBubbleState extends State with Sing ); } } + + +