From c0d568070cdfca19505b5ea98e0c3c6e4ec72fd2 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Fri, 23 Apr 2021 23:07:47 +0300 Subject: [PATCH 1/3] add icon --- lib/screens/patients/profile/note/update_note.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/screens/patients/profile/note/update_note.dart b/lib/screens/patients/profile/note/update_note.dart index 9585e115..8c2f7a45 100644 --- a/lib/screens/patients/profile/note/update_note.dart +++ b/lib/screens/patients/profile/note/update_note.dart @@ -7,6 +7,7 @@ import 'package:doctor_app_flutter/core/model/note/note_model.dart'; import 'package:doctor_app_flutter/core/model/note/update_note_model.dart'; import 'package:doctor_app_flutter/core/provider/robot_provider.dart'; import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; +import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/models/patient/progress_note_request.dart'; @@ -107,7 +108,7 @@ class _UpdateNoteOrderState extends State { hasBorder: true, suffixIcon: IconButton( icon: Icon( - Icons.mic, + DoctorApp.speechtotext, color: Colors.black, ), onPressed: () { From d8f27f6a98de04607192be184f8d66f16bc6091f Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Fri, 23 Apr 2021 23:17:49 +0300 Subject: [PATCH 2/3] add speech to text --- .../referral/AddReplayOnReferralPatient.dart | 75 ++++++++++++++++--- 1 file changed, 66 insertions(+), 9 deletions(-) diff --git a/lib/screens/patients/profile/referral/AddReplayOnReferralPatient.dart b/lib/screens/patients/profile/referral/AddReplayOnReferralPatient.dart index 636b42ab..051fc6aa 100644 --- a/lib/screens/patients/profile/referral/AddReplayOnReferralPatient.dart +++ b/lib/screens/patients/profile/referral/AddReplayOnReferralPatient.dart @@ -1,16 +1,10 @@ -import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; +import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/model/MyReferralPatientModel.dart'; -import 'package:doctor_app_flutter/core/model/note/CreateNoteModel.dart'; -import 'package:doctor_app_flutter/core/model/note/note_model.dart'; -import 'package:doctor_app_flutter/core/model/note/update_note_model.dart'; -import 'package:doctor_app_flutter/core/service/MyReferralPatientService.dart'; +import 'package:doctor_app_flutter/core/provider/robot_provider.dart'; import 'package:doctor_app_flutter/core/viewModel/patient-referral-viewmodel.dart'; -import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; -import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; -import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; -import 'package:doctor_app_flutter/models/patient/progress_note_request.dart'; +import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; @@ -18,8 +12,13 @@ import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; +import 'package:doctor_app_flutter/widgets/shared/speech-text-popup.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; import 'package:flutter/material.dart'; +import 'package:permission_handler/permission_handler.dart'; +import 'package:speech_to_text/speech_recognition_error.dart'; +import 'package:speech_to_text/speech_to_text.dart' as stt; + class AddReplayOnReferralPatient extends StatefulWidget { final PatientReferralViewModel patientReferralViewModel; @@ -37,7 +36,16 @@ class AddReplayOnReferralPatient extends StatefulWidget { class _AddReplayOnReferralPatientState extends State { bool isSubmitted = false; + stt.SpeechToText speech = stt.SpeechToText(); + var reconizedWord; + var event = RobotProvider(); TextEditingController progressNoteController = TextEditingController(); + @override + void initState() { + requestPermissions(); + super.initState(); + } + @override Widget build(BuildContext context) { @@ -67,6 +75,15 @@ class _AddReplayOnReferralPatientState extends State maxLines: 35, minLines: 25, hasBorder: true, + suffixIcon: IconButton( + icon: Icon( + DoctorApp.speechtotext, + color: Colors.black, + ), + onPressed: () { + onVoiceText(); + }, + ), validationError: progressNoteController.text.isEmpty && isSubmitted ? TranslationBase.of(context).emptyMessage @@ -118,4 +135,44 @@ class _AddReplayOnReferralPatientState extends State ), ); } + + 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: ListenMode.confirmation, + localeId: lang == 'en' ? 'en-US' : 'ar-SA', + ); + } else { + print("The user has denied the use of speech recognition."); + } + } + + void errorListener(SpeechRecognitionError 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); + progressNoteController.text = reconizedWord; + }); + } + } } From 1a830b7f44f1b22b991e7f08d7ecc6ac5a7a8cea Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Fri, 23 Apr 2021 23:28:52 +0300 Subject: [PATCH 3/3] make icon on top --- .../patients/profile/note/update_note.dart | 59 +++++++++++-------- .../referral/AddReplayOnReferralPatient.dart | 45 ++++++++------ 2 files changed, 61 insertions(+), 43 deletions(-) diff --git a/lib/screens/patients/profile/note/update_note.dart b/lib/screens/patients/profile/note/update_note.dart index 8c2f7a45..c9932e63 100644 --- a/lib/screens/patients/profile/note/update_note.dart +++ b/lib/screens/patients/profile/note/update_note.dart @@ -95,32 +95,41 @@ class _UpdateNoteOrderState extends State { widthFactor: 0.9, child: Column( children: [ - AppTextFieldCustom( - hintText: widget.visitType == 3 - ? (widget.isUpdate ? 'Update' : 'Add') + - ' Order Sheet' - : (widget.isUpdate ? 'Update' : 'Add') + - ' Progress Note', - //TranslationBase.of(context).addProgressNote, - controller: progressNoteController, - maxLines: 35, - minLines: 25, - hasBorder: true, - suffixIcon: IconButton( - icon: Icon( - DoctorApp.speechtotext, - color: Colors.black, + Stack( + children: [ + AppTextFieldCustom( + hintText: widget.visitType == 3 + ? (widget.isUpdate ? 'Update' : 'Add') + + ' Order Sheet' + : (widget.isUpdate ? 'Update' : 'Add') + + ' Progress Note', + //TranslationBase.of(context).addProgressNote, + controller: progressNoteController, + maxLines: 35, + minLines: 25, + hasBorder: true, + + // isTextFieldHasSuffix: true, + validationError: + progressNoteController.text.isEmpty && isSubmitted + ? TranslationBase.of(context).emptyMessage + : null, ), - onPressed: () { - onVoiceText(); - }, - ), - - isTextFieldHasSuffix: true, - validationError: - progressNoteController.text.isEmpty && isSubmitted - ? TranslationBase.of(context).emptyMessage - : null, + + Positioned( + top: 0,//MediaQuery.of(context).size.height * 0, + right: 15, + child: IconButton( + icon: Icon( + DoctorApp.speechtotext, + color: Colors.black, + ), + onPressed: () { + onVoiceText(); + }, + ), + ) + ], ), ], ), diff --git a/lib/screens/patients/profile/referral/AddReplayOnReferralPatient.dart b/lib/screens/patients/profile/referral/AddReplayOnReferralPatient.dart index 051fc6aa..1a90b708 100644 --- a/lib/screens/patients/profile/referral/AddReplayOnReferralPatient.dart +++ b/lib/screens/patients/profile/referral/AddReplayOnReferralPatient.dart @@ -69,25 +69,34 @@ class _AddReplayOnReferralPatientState extends State widthFactor: 0.9, child: Column( children: [ - AppTextFieldCustom( - hintText: 'Replay your responses here', - controller: progressNoteController, - maxLines: 35, - minLines: 25, - hasBorder: true, - suffixIcon: IconButton( - icon: Icon( - DoctorApp.speechtotext, - color: Colors.black, + Stack( + children: [ + AppTextFieldCustom( + hintText: 'Replay your responses here', + controller: progressNoteController, + maxLines: 35, + minLines: 25, + hasBorder: true, + validationError: + progressNoteController.text.isEmpty && + isSubmitted + ? TranslationBase.of(context).emptyMessage + : null, ), - onPressed: () { - onVoiceText(); - }, - ), - validationError: - progressNoteController.text.isEmpty && isSubmitted - ? TranslationBase.of(context).emptyMessage - : null, + Positioned( + top: 0,//MediaQuery.of(context).size.height * 0, + right: 15, + child: IconButton( + icon: Icon( + DoctorApp.speechtotext, + color: Colors.black, + ), + onPressed: () { + onVoiceText(); + }, + ), + ) + ], ), ], ),