From 77423139235dfa8986508705c9d5e7893b19fd72 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Wed, 9 Dec 2020 20:56:48 +0300 Subject: [PATCH] voice command --- lib/locator.dart | 2 + lib/widgets/others/app_scaffold_widget.dart | 57 +++++++++---------- .../others/floating_button_search.dart | 14 +++-- 3 files changed, 40 insertions(+), 33 deletions(-) diff --git a/lib/locator.dart b/lib/locator.dart index b0b999be..68557d01 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -50,6 +50,7 @@ import 'core/service/medical/reports_monthly_service.dart'; import 'core/service/medical/vital_sign_service.dart'; import 'core/service/parmacyModule/order-preview-service.dart'; import 'core/service/notifications_service.dart'; +import 'core/service/privilege_service.dart'; import 'core/viewModels/AlHabibMedicalService/cmc_view_model.dart'; import 'core/service/parmacyModule/parmacy_module_service.dart'; @@ -153,6 +154,7 @@ void setupLocator() { locator.registerLazySingleton(() => OrderPreviewService()); locator.registerLazySingleton(() => CustomerAddressesService()); // locator.registerLazySingleton(() => TermsConditionService()); + locator.registerLazySingleton(() => PrivilegeService()); /// View Model locator.registerFactory(() => HospitalViewModel()); diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index d15cde99..228407b5 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -94,37 +94,37 @@ class AppScaffold extends StatelessWidget { appBar = preferredSize == 0 ? appBarWidget : PreferredSize( - child: appBarWidget, - preferredSize: Size.fromHeight(preferredSize)); + child: appBarWidget, + preferredSize: Size.fromHeight(preferredSize)); } else { appBar = this.appBarWidget; } return Scaffold( - backgroundColor: - backgroundColor ?? Theme.of(context).scaffoldBackgroundColor, - appBar: appBar, - body: (!Provider.of(context, listen: false).isLogin && - isShowDecPage) - ? NotAutPage( - title: appBarTitle, - description: description, - infoList: infoList, - imagesInfo: imagesInfo, - ) - : baseViewModel != null - ? NetworkBaseView( - child: buildBodyWidget(context), - baseViewModel: baseViewModel, - ) - : buildBodyWidget(context), - bottomSheet: bottomSheet + backgroundColor: + backgroundColor ?? Theme.of(context).scaffoldBackgroundColor, + appBar: appBar, + body: (!Provider.of(context, listen: false).isLogin && + isShowDecPage) + ? NotAutPage( + title: appBarTitle, + description: description, + infoList: infoList, + imagesInfo: imagesInfo, + ) + : baseViewModel != null + ? NetworkBaseView( + child: buildBodyWidget(context), + baseViewModel: baseViewModel, + ) + : buildBodyWidget(context), + bottomSheet: bottomSheet - //floatingActionButton: floatingActionButton ?? floatingActionButton, - // bottomNavigationBar: - // this.isBottomBar == true ? BottomBarSearch() : SizedBox() - //floatingActionButton: FloatingSearchButton(), - ); + //floatingActionButton: floatingActionButton ?? floatingActionButton, + // bottomNavigationBar: + // this.isBottomBar == true ? BottomBarSearch() : SizedBox() + //floatingActionButton: FloatingSearchButton(), + ); } buildAppLoaderWidget(bool isLoading) { @@ -133,10 +133,9 @@ class AppScaffold extends StatelessWidget { buildBodyWidget(context) { // return body; //Stack(children: [body, buildAppLoaderWidget(isLoading)]); - return Stack(children: [ - body, - isHelp==true && Provider.of(context, listen: false).havePrivilege(77) ? RobotIcon() : Container() - ]); + //&& Provider.of(context, listen: false).havePrivilege(77) need to added + return Stack( + children: [body, isHelp == true ? RobotIcon() : Container()]); } } diff --git a/lib/widgets/others/floating_button_search.dart b/lib/widgets/others/floating_button_search.dart index 1b474339..f2ffb2d2 100644 --- a/lib/widgets/others/floating_button_search.dart +++ b/lib/widgets/others/floating_button_search.dart @@ -217,11 +217,11 @@ class _FloatingSearchButton extends State void resultListener(SpeechRecognitionResult result) { // lastWords = "${result.recognizedWords} - ${result.finalResult}"; - print(result); reconizedWord = result.recognizedWords; event.setValue({"searchText": reconizedWord}); if (result.finalResult == true) { - RoboSearch.closeAlertDialog(context); + + // setState(() { @@ -230,6 +230,7 @@ class _FloatingSearchButton extends State // }); Future.delayed(const Duration(seconds: 1), () { _speak(reconizedWord); + RoboSearch.closeAlertDialog(context); }); } //}); @@ -942,9 +943,14 @@ class RoboSearch { Expanded( flex: 1, child: Center( - child: Text(searchText != null + child: Text(searchText != null && searchText != 'null' ? searchText - : 'Try saying something'))) + : 'Try saying something'))), + + // searchText == 'null' ? Center(child:RaisedButton(child: Text('Retry'), onPressed: (){ + // //RoboSearch.closeAlertDialog(context); + // new FloatingSearchButton().createState().startVoiceSearch(); + // }, )) :SizedBox() ]), )); }),