|
|
|
|
@ -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<ChatMessage> messages = [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum ChatMode { home, chatActive }
|
|
|
|
|
|
|
|
|
|
class ChatMessage {
|
|
|
|
|
@ -51,6 +57,13 @@ class _ChatBotScreenState extends State<ChatBotScreen> {
|
|
|
|
|
/// 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<ChatBotScreen> {
|
|
|
|
|
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: <Widget>[Expanded(child: _currentMode == ChatMode.home ? _buildHomeMode() : _buildChatMode()), _buildBottomInputBar()]),
|
|
|
|
|
);
|
|
|
|
|
@ -464,3 +494,6 @@ class _AnimatedMessageBubbleState extends State<AnimatedMessageBubble> with Sing
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|