diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index dcc4aa1f..f8d6a510 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1,6 +1,7 @@ const Map> localizedValues = { 'dashboardScreenToolbarTitle': {'ar': 'الرئيسة', 'en': 'Home'}, 'settings': {'en': 'Settings', 'ar': 'الاعدادات'}, + 'areYouSureYouWantTo': {'en': 'Are you sure you want to', 'ar': 'هل انت متاكد من انك تريد أن'}, 'language': {'en': 'App Language', 'ar': 'لغة التطبيق'}, 'lanEnglish': {'en': 'English', 'ar': 'English'}, 'lanArabic': {'en': 'العربية', 'ar': 'العربية'}, diff --git a/lib/screens/live_care/end_call_screen.dart b/lib/screens/live_care/end_call_screen.dart index 880c8fd8..dff46923 100644 --- a/lib/screens/live_care/end_call_screen.dart +++ b/lib/screens/live_care/end_call_screen.dart @@ -1,6 +1,7 @@ import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/patients/profile/profile_screen/PatientProfileCardModel.dart'; +import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/PatientProfileButton.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/patient-profile-header-new-design-app-bar.dart'; @@ -35,18 +36,24 @@ class _EndCallScreenState extends State { final List cardsList = [ PatientProfileCardModel(TranslationBase.of(context).resume, TranslationBase.of(context).theCall, '', 'patient/vital_signs.png', - isInPatient: isInpatient, onTap: () {}, isDartIcon: true, + isInPatient: isInpatient, + onTap: () {}, + isDartIcon: true, dartIcon: DoctorApp.call), PatientProfileCardModel( TranslationBase.of(context).endLC, TranslationBase.of(context).consultation, '', 'patient/vital_signs.png', - isInPatient: isInpatient, - onTap: () {}, - isDartIcon: true, - dartIcon: DoctorApp.end_consultaion - ), + isInPatient: isInpatient, onTap: () { + Helpers.showConfirmationDialog( + context, + "${TranslationBase.of(context).areYouSureYouWantTo} ${TranslationBase.of(context).endLC} ${TranslationBase.of(context).consultation} ?", + () { + Navigator.of(context).pop(); + + }); + }, isDartIcon: true, dartIcon: DoctorApp.end_consultaion), PatientProfileCardModel( TranslationBase.of(context).sendLC, TranslationBase.of(context).instruction, @@ -55,19 +62,13 @@ class _EndCallScreenState extends State { onTap: () {}, isInPatient: isInpatient, isDartIcon: true, - dartIcon: DoctorApp.send_instruction - ), - PatientProfileCardModel( - TranslationBase.of(context).transferTo, - TranslationBase.of(context).admin, - '', - 'patient/health_summary.png', + dartIcon: DoctorApp.send_instruction), + PatientProfileCardModel(TranslationBase.of(context).transferTo, + TranslationBase.of(context).admin, '', 'patient/health_summary.png', onTap: () {}, - isInPatient: isInpatient, - - isDartIcon: true, - dartIcon: DoctorApp.transfer_to_admin - ), + isInPatient: isInpatient, + isDartIcon: true, + dartIcon: DoctorApp.transfer_to_admin), ]; return AppScaffold( @@ -93,8 +94,8 @@ class _EndCallScreenState extends State { child: ListView( children: [ Padding( - padding: const EdgeInsets.symmetric( - vertical: 15.0, horizontal: 15), + padding: + const EdgeInsets.symmetric(vertical: 15.0, horizontal: 15), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -103,11 +104,14 @@ class _EndCallScreenState extends State { fontSize: 14, fontWeight: FontWeight.w500, ), - AppText(TranslationBase.of(context).endcall, + AppText( + TranslationBase.of(context).endcall, fontSize: 26, fontWeight: FontWeight.bold, ), - SizedBox(height: 10,), + SizedBox( + height: 10, + ), StaggeredGridView.countBuilder( shrinkWrap: true, physics: NeverScrollableScrollPhysics(), diff --git a/lib/screens/live_care/live-care_transfer_to_admin.dart b/lib/screens/live_care/live-care_transfer_to_admin.dart new file mode 100644 index 00000000..f6e3798f --- /dev/null +++ b/lib/screens/live_care/live-care_transfer_to_admin.dart @@ -0,0 +1,108 @@ +import 'dart:html'; + +import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/core/provider/robot_provider.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/speech-text-popup.dart'; +import 'package:flutter/material.dart'; +import 'package:permission_handler/permission_handler.dart'; +import 'package:provider/provider.dart'; +import 'package:speech_to_text/speech_recognition_error.dart'; +import 'package:speech_to_text/speech_to_text.dart' as stt; + +class LivaCareTransferToAdmin extends StatefulWidget { + + final PatiantInformtion patient; + + const LivaCareTransferToAdmin({Key key, this.patient}) : super(key: key); + + @override + _LivaCareTransferToAdminState createState() => _LivaCareTransferToAdminState(); +} + +class _LivaCareTransferToAdminState extends State { + + stt.SpeechToText speech = stt.SpeechToText(); + var reconizedWord; + var event = RobotProvider(); + ProjectViewModel projectViewModel; + + TextEditingController noteController = TextEditingController(); + + void initState() { + requestPermissions(); + event.controller.stream.listen((p) { + if (p['startPopUp'] == 'true') { + if (this.mounted) { + initSpeechState().then((value) => {onVoiceText()}); + } + } + }); + super.initState(); + } + + @override + Widget build(BuildContext context) { + projectViewModel = Provider.of(context); + + return Container( + + ); + } + + onVoiceText() async { + new SpeechToText(context: context).showAlertDialog(context); + var lang = TranslationBase.of(AppGlobal.CONTEX).locale.languageCode; + bool available = await speech.initialize( + onStatus: statusListener, onError: errorListener); + if (available) { + speech.listen( + onResult: resultListener, + listenMode: stt.ListenMode.confirmation, + localeId: lang == 'en' ? 'en-US' : 'ar-SA', + ); + } else { + print("The user has denied the use of speech recognition."); + } + } + + void errorListener(SpeechRecognitionError error) { + event.setValue({"searchText": 'null'}); + //SpeechToText.closeAlertDialog(context); + print(error); + } + + void statusListener(String status) { + reconizedWord = status == 'listening' ? 'Lisening...' : 'Sorry....'; + } + + void requestPermissions() async { + Map statuses = await [ + Permission.microphone, + ].request(); + } + + void resultListener(result) { + reconizedWord = result.recognizedWords; + event.setValue({"searchText": reconizedWord}); + + if (result.finalResult == true) { + setState(() { + SpeechToText.closeAlertDialog(context); + speech.stop(); + noteController.text += reconizedWord + '\n'; + }); + } else { + print(result.finalResult); + } + } + + Future initSpeechState() async { + bool hasSpeech = await speech.initialize( + onError: errorListener, onStatus: statusListener); + print(hasSpeech); + if (!mounted) return; + } +} diff --git a/lib/util/helpers.dart b/lib/util/helpers.dart index 53f81ef2..7f72435f 100644 --- a/lib/util/helpers.dart +++ b/lib/util/helpers.dart @@ -8,6 +8,8 @@ import 'package:doctor_app_flutter/models/doctor/list_doctor_working_hours_table import 'package:doctor_app_flutter/screens/auth/login_screen.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -24,7 +26,47 @@ class Helpers { static int cupertinoPickerIndex = 0; get currentLanguage => null; - static showCupertinoPicker(context, List items, decKey, onSelectFun, AuthenticationViewModel model) { + + static showConfirmationDialog( + BuildContext context, String message, Function okFunction) { + return showDialog( + context: context, + barrierDismissible: false, // user must tap button! + builder: (_) { + return Container( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + AlertDialog( + title: null, + content: Container( + child: AppText(message), + ), + actions: [ + AppButton( + onPressed: okFunction, + title: TranslationBase.of(context).noteConfirm, + fontColor: Colors.white, + color: Colors.green[600], + ), + AppButton( + onPressed: (){ + Navigator.of(context).pop(); + }, + title: TranslationBase.of(context).cancel, + fontColor: Colors.white, + color: Colors.red[600], + ), + ], + ), + ], + ), + ); + }); + } + + static showCupertinoPicker(context, List items, + decKey, onSelectFun, AuthenticationViewModel model) { showModalBottomSheet( isDismissible: false, context: context, @@ -64,8 +106,8 @@ class Helpers { Container( height: SizeConfig.realScreenHeight * 0.3, color: Color(0xfff7f7f7), - child: - buildPickerItems(context, items, decKey, onSelectFun, model)) + child: buildPickerItems( + context, items, decKey, onSelectFun, model)) ], ), ); @@ -75,7 +117,8 @@ class Helpers { static TextStyle textStyle(context) => TextStyle(color: Theme.of(context).primaryColor); - static buildPickerItems(context, List items, decKey, onSelectFun, model) { + static buildPickerItems(context, List items, + decKey, onSelectFun, model) { return CupertinoPicker( magnification: 1.5, scrollController: diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index ac805956..4f5a128b 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -18,6 +18,8 @@ class TranslationBase { String get settings => localizedValues['settings'][locale.languageCode]; + String get areYouSureYouWantTo => localizedValues['areYouSureYouWantTo'][locale.languageCode]; + String get language => localizedValues['language'][locale.languageCode]; String get lanEnglish => localizedValues['lanEnglish'][locale.languageCode];