Merge branch 'sultan_v3.3' of http://34.17.52.79/Haroon6138/diplomatic-quarter into development_v3.3

# Conflicts:
#	lib/widgets/new_design/doctor_header.dart
#	pubspec.yaml
Dev_3.3_MedicalReportCR
Sultan khan 3 years ago
commit 68f39d965c

@ -1,6 +1,7 @@
extension CapExtension on String { extension CapExtension on String {
String get toCamelCase => "${this[0].toUpperCase()}${this.substring(1)}"; String get toCamelCase => "${this[0].toUpperCase()}${this.substring(1)}";
String get inCaps => '${this[0].toUpperCase()}${this.substring(1)}'; String get inCaps => '${this[0].toUpperCase()}${this.substring(1)}';
String get allInCaps => this.toUpperCase(); String get allInCaps => this.toUpperCase();
String get capitalizeFirstofEach => this.trim().length > 0 ? this.trim().toLowerCase().split(" ").map((str) => str.inCaps).join(" ") : ""; String get capitalizeFirstofEach => this.trim().length > 0 ? this.trim().toLowerCase().split(" ").map((str) => str.isNotEmpty ? str.inCaps: str).join(" ") : "";
} }

@ -298,12 +298,12 @@ class DoctorHeader extends StatelessWidget {
width: 100.0, width: 100.0,
margin: EdgeInsets.only(top: 10.0, left: 15.0, right: 15.0), margin: EdgeInsets.only(top: 10.0, left: 15.0, right: 15.0),
child: Text(TranslationBase.of(context).excellent, style: TextStyle(fontSize: 13.0, color: Colors.black, fontWeight: FontWeight.w600))), child: Text(TranslationBase.of(context).excellent, style: TextStyle(fontSize: 13.0, color: Colors.black, fontWeight: FontWeight.w600))),
getRatingLine(doctorDetailsList[0].patientNumber, Colors.green[700]), getRatingLine(doctorDetailsList[0].ratio, Colors.green[700]),
], ],
), ),
Container( Container(
margin: EdgeInsets.only(top: 10.0, left: 10.0, right: 10.0), margin: EdgeInsets.only(top: 10.0, left: 20.0, right: 20.0),
child: Text(getRatingWidth(doctorDetailsList[0].patientNumber).round().toString() + "%", child: Text(getRatingWidth(doctorDetailsList[0].ratio).round().toString() + "%",
style: TextStyle(fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.w600)), style: TextStyle(fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.w600)),
), ),
], ],
@ -319,12 +319,12 @@ class DoctorHeader extends StatelessWidget {
width: 100.0, width: 100.0,
margin: EdgeInsets.only(top: 10.0, left: 15.0, right: 15.0), margin: EdgeInsets.only(top: 10.0, left: 15.0, right: 15.0),
child: Text(TranslationBase.of(context).v_good, style: TextStyle(fontSize: 13.0, color: Colors.black, fontWeight: FontWeight.w600))), child: Text(TranslationBase.of(context).v_good, style: TextStyle(fontSize: 13.0, color: Colors.black, fontWeight: FontWeight.w600))),
getRatingLine(doctorDetailsList[1].patientNumber, Color(0xffB7B723)), getRatingLine(doctorDetailsList[1].ratio, Color(0xffB7B723)),
], ],
), ),
Container( Container(
margin: EdgeInsets.only(top: 10.0, left: 10.0, right: 10.0), margin: EdgeInsets.only(top: 10.0, left: 20.0, right: 20.0),
child: Text(getRatingWidth(doctorDetailsList[1].patientNumber).round().toString() + "%", child: Text(doctorDetailsList[1].ratio.round().toString() + "%",
style: TextStyle(fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.w600)), style: TextStyle(fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.w600)),
), ),
], ],
@ -340,12 +340,12 @@ class DoctorHeader extends StatelessWidget {
width: 100.0, width: 100.0,
margin: EdgeInsets.only(top: 10.0, left: 15.0, right: 15.0), margin: EdgeInsets.only(top: 10.0, left: 15.0, right: 15.0),
child: Text(TranslationBase.of(context).good, style: TextStyle(fontSize: 13.0, color: Colors.black, fontWeight: FontWeight.w600))), child: Text(TranslationBase.of(context).good, style: TextStyle(fontSize: 13.0, color: Colors.black, fontWeight: FontWeight.w600))),
getRatingLine(doctorDetailsList[2].patientNumber, Color(0xffEBA727)), getRatingLine(doctorDetailsList[2].ratio, Color(0xffEBA727)),
], ],
), ),
Container( Container(
margin: EdgeInsets.only(top: 10.0, left: 10.0, right: 10.0), margin: EdgeInsets.only(top: 10.0, left: 20.0, right: 20.0),
child: Text(getRatingWidth(doctorDetailsList[2].patientNumber).round().toString() + "%", child: Text(doctorDetailsList[2].ratio.round().toString() + "%",
style: TextStyle(fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.w600)), style: TextStyle(fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.w600)),
), ),
], ],
@ -361,12 +361,12 @@ class DoctorHeader extends StatelessWidget {
width: 100.0, width: 100.0,
margin: EdgeInsets.only(top: 10.0, left: 15.0, right: 15.0), margin: EdgeInsets.only(top: 10.0, left: 15.0, right: 15.0),
child: Text(TranslationBase.of(context).average, style: TextStyle(fontSize: 13.0, color: Colors.black, fontWeight: FontWeight.w600))), child: Text(TranslationBase.of(context).average, style: TextStyle(fontSize: 13.0, color: Colors.black, fontWeight: FontWeight.w600))),
getRatingLine(doctorDetailsList[3].patientNumber, Color(0xffEB7227)), getRatingLine(doctorDetailsList[3].ratio, Color(0xffEB7227)),
], ],
), ),
Container( Container(
margin: EdgeInsets.only(top: 10.0, left: 10.0, right: 10.0), margin: EdgeInsets.only(top: 10.0, left: 20.0, right: 20.0),
child: Text(getRatingWidth(doctorDetailsList[3].patientNumber).round().toString() + "%", child: Text(doctorDetailsList[3].ratio.round().toString() + "%",
style: TextStyle(fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.w600)), style: TextStyle(fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.w600)),
), ),
], ],
@ -383,12 +383,12 @@ class DoctorHeader extends StatelessWidget {
width: 100.0, width: 100.0,
margin: EdgeInsets.only(top: 10.0, left: 15.0, right: 15.0), margin: EdgeInsets.only(top: 10.0, left: 15.0, right: 15.0),
child: Text(TranslationBase.of(context).below_average, style: TextStyle(fontSize: 13.0, color: Colors.black, fontWeight: FontWeight.w600))), child: Text(TranslationBase.of(context).below_average, style: TextStyle(fontSize: 13.0, color: Colors.black, fontWeight: FontWeight.w600))),
getRatingLine(doctorDetailsList[4].patientNumber, Color(0xffE20C0C)), getRatingLine(doctorDetailsList[4].ratio, Color(0xffE20C0C)),
], ],
), ),
Container( Container(
margin: EdgeInsets.only(top: 10.0, left: 10.0, right: 10.0), margin: EdgeInsets.only(top: 10.0, left: 20.0, right: 20.0),
child: Text(getRatingWidth(doctorDetailsList[4].patientNumber).round().toString() + "%", child: Text(doctorDetailsList[4].ratio.round().toString() + "%",
style: TextStyle(fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.w600)), style: TextStyle(fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.w600)),
), ),
], ],
@ -410,12 +410,12 @@ class DoctorHeader extends StatelessWidget {
pageBuilder: (context, animation1, animation2) {}); pageBuilder: (context, animation1, animation2) {});
} }
double getRatingWidth(int patientNumber) { double getRatingWidth(double patientNumber) {
var width = (patientNumber / this.headerModel.totalReviews) * 100; var width = patientNumber;
return width.roundToDouble(); return width.roundToDouble();
} }
Widget getRatingLine(int patientNumber, Color color) { Widget getRatingLine(double patientNumber, Color color) {
return Container( return Container(
margin: EdgeInsets.only(top: 10.0), margin: EdgeInsets.only(top: 10.0),
child: Stack(children: [ child: Stack(children: [
@ -427,7 +427,7 @@ class DoctorHeader extends StatelessWidget {
), ),
), ),
SizedBox( SizedBox(
width: getRatingWidth(patientNumber) * 1.35, width: patientNumber * 1.35,
height: 4.0, height: 4.0,
child: Container( child: Container(
color: color, color: color,

@ -66,8 +66,9 @@ import 'package:flutter/material.dart';
import 'package:flutter_tts/flutter_tts.dart'; import 'package:flutter_tts/flutter_tts.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
// import 'package:speech_to_text/speech_recognition_error.dart'; import 'package:speech_to_text/speech_recognition_error.dart';
// import 'package:speech_to_text/speech_to_text.dart' as stt; import 'package:speech_to_text/speech_to_text.dart' as stt;
import 'package:speech_to_text/speech_to_text.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
class FloatingSearchButton extends StatefulWidget { class FloatingSearchButton extends StatefulWidget {
@ -83,7 +84,8 @@ class _FloatingSearchButton extends State<FloatingSearchButton> with TickerProvi
RobotProvider eventProvider = RobotProvider(); RobotProvider eventProvider = RobotProvider();
bool isLoading = false; bool isLoading = false;
bool isError = false; bool isError = false;
// stt.SpeechToText speech = stt.SpeechToText(); stt.SpeechToText speech = stt.SpeechToText();
FlutterTts tts = FlutterTts();
String error = ''; String error = '';
String _currentLocaleId = ""; String _currentLocaleId = "";
String lastError; String lastError;
@ -92,7 +94,6 @@ class _FloatingSearchButton extends State<FloatingSearchButton> with TickerProvi
double minSoundLevel = 50000; double minSoundLevel = 50000;
double maxSoundLevel = -50000; double maxSoundLevel = -50000;
String reconizedWord = ''; String reconizedWord = '';
FlutterTts flutterTts = FlutterTts();
var selectedLang; var selectedLang;
bool isSearching = false; bool isSearching = false;
Map results = {}; Map results = {};
@ -113,7 +114,7 @@ class _FloatingSearchButton extends State<FloatingSearchButton> with TickerProvi
void initState() { void initState() {
controller = AnimationController(vsync: this, duration: Duration(seconds: 1)); controller = AnimationController(vsync: this, duration: Duration(seconds: 1));
offset = Tween<Offset>(begin: Offset(0.0, 1.0), end: Offset(0.0, 0.0)).animate(controller); offset = Tween<Offset>(begin: Offset(0.0, 1.0), end: Offset(0.0, 0.0)).animate(controller);
startIosTts();
if (IS_VOICE_COMMAND_CLOSED == true) { if (IS_VOICE_COMMAND_CLOSED == true) {
controller.reverse(from: -1); controller.reverse(from: -1);
} else { } else {
@ -192,20 +193,20 @@ class _FloatingSearchButton extends State<FloatingSearchButton> with TickerProvi
: Image.asset('assets/images/gif/robot-idle.gif'), : Image.asset('assets/images/gif/robot-idle.gif'),
), ),
onTap: () async { onTap: () async {
// if (Platform.isAndroid) { if (Platform.isAndroid) {
// if (await PermissionService.isMicrophonePermissionEnabled()) { if (await PermissionService.isMicrophonePermissionEnabled()) {
// new RoboSearch(context: context).showAlertDialog(context); new RoboSearch(context: context).showAlertDialog(context);
// initSpeechState().then((value) => {startVoiceSearch()}); initSpeechState().then((value) => {startVoiceSearch()});
// } else { } else {
// Utils.showPermissionConsentDialog(context, TranslationBase.of(context).recordAudioPermission, () { Utils.showPermissionConsentDialog(context, TranslationBase.of(context).recordAudioPermission, () {
// new RoboSearch(context: context).showAlertDialog(context); new RoboSearch(context: context).showAlertDialog(context);
// initSpeechState().then((value) => {startVoiceSearch()}); initSpeechState().then((value) => {startVoiceSearch()});
// }); });
// } }
// } else { } else {
// new RoboSearch(context: context).showAlertDialog(context); new RoboSearch(context: context).showAlertDialog(context);
// initSpeechState().then((value) => {startVoiceSearch()}); initSpeechState().then((value) => {startVoiceSearch()});
// } }
}, },
), ),
Positioned( Positioned(
@ -234,44 +235,60 @@ class _FloatingSearchButton extends State<FloatingSearchButton> with TickerProvi
])); ]));
} }
// startVoiceSearch() async {
// bool available = await speech.initialize(onStatus: statusListener, onError: errorListener); startIosTts() async{
// _currentLocaleId = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); await tts.setSharedInstance(true);
// await tts.setLanguage("en-US");
// if (available) { tts.setIosAudioCategory(
// speech.listen( IosTextToSpeechAudioCategory.playback,
// onResult: resultListener, [IosTextToSpeechAudioCategoryOptions.mixWithOthers],
// //listenMode: ListenMode.confirmation, IosTextToSpeechAudioMode.voicePrompt);
// localeId: _currentLocaleId == 'en' ? 'en_US' : 'ar_SA', }
// ); startVoiceSearch() async {
// } else { bool available = await speech.initialize();
// print("The user has denied the use of speech recognition."); _currentLocaleId = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar');
// } //
// // some time later... // if (available) {
// //speech.stop(); // speech.listen(
// // speech.listen( // onResult: resultListener,
// // onResult: resultListener, // //listenMode: ListenMode.confirmation,
// // listenFor: Duration(seconds: 10), // localeId: _currentLocaleId == 'en' ? 'en_US' : 'ar_SA',
// // localeId: _currentLocaleId == 'en' ? 'en-US' : 'ar-SA', // );
// // onSoundLevelChange: soundLevelListener, // } else {
// // cancelOnError: true, // print("The user has denied the use of speech recognition.");
// // partialResults: true, // }
// // onDevice: true, // some time later...
// // listenMode: ListenMode.deviceDefault); if(available) {
// } speech.stop();
speech.listen(
onResult: resultListener,
listenFor: Duration(seconds: 10),
localeId: _currentLocaleId == 'en' ? 'en-US' : 'ar-SA',
onSoundLevelChange: soundLevelListener,
cancelOnError: true,
partialResults: true,
onDevice: true,
listenMode: ListenMode.deviceDefault);
}
}
void resultListener(result) { void resultListener(result) {
_stopListening();
reconizedWord = result.recognizedWords; reconizedWord = result.recognizedWords;
event.setValue({"searchText": reconizedWord}); event.setValue({"searchText": reconizedWord});
if (result.finalResult == true) { if (result.finalResult == true) {
Future.delayed(const Duration(seconds: 1), () { Future.delayed(const Duration(seconds: 1), () {
_speak(reconizedWord); _speak(reconizedWord);
RoboSearch.closeAlertDialog(context); RoboSearch.closeAlertDialog(context);
//Navigator.of(context).pop(); //Navigator.of(context).pop();
}); });
} }
} }
void _stopListening() async {
await speech.stop();
// setState(() {});
}
Future _speak(reconizedWord) async { Future _speak(reconizedWord) async {
getPages(reconizedWord); getPages(reconizedWord);
} }
@ -315,10 +332,10 @@ class _FloatingSearchButton extends State<FloatingSearchButton> with TickerProvi
// }); // });
} }
// void errorListener(SpeechRecognitionError error) { void errorListener(SpeechRecognitionError error) {
// event.setValue({"searchText": 'null'}); event.setValue({"searchText": 'null'});
// RoboSearch.closeAlertDialog(context); RoboSearch.closeAlertDialog(context);
// } }
void statusListener(String status) { void statusListener(String status) {
//setState(() { //setState(() {
@ -807,7 +824,7 @@ class _FloatingSearchButton extends State<FloatingSearchButton> with TickerProvi
); );
} }
speak({isInit}) async { speak({isInit =false}) async {
//if (mounted) { //if (mounted) {
setState(() { setState(() {
this.networkImage = results['AnimationURL']; this.networkImage = results['AnimationURL'];
@ -817,12 +834,18 @@ class _FloatingSearchButton extends State<FloatingSearchButton> with TickerProvi
if (isInit == true) { if (isInit == true) {
event.setValue({"animationEnable": 'true'}); event.setValue({"animationEnable": 'true'});
} }
// var voice = await tts.getVoice();
// print(voice);
if (isArabic == false && results['ReturnMessage'] != null && isInit == false) { if (isArabic == false && results['ReturnMessage'] != null && isInit == false) {
await flutterTts.setVoice({"name": "en-au-x-aub-network", "locale": "en-AU"}); // await tts.synthesizeToFile("Hello World", Platform.isAndroid ? "tts.wav" : "tts.caf");
await flutterTts.speak(results['ReturnMessage']);
await tts.setVoice({"name": "Karen", "locale": "en-AU"});
// await tts.setVoice({"name" : voice[35]["name"],"locale": voice[35]["locale"]});
await tts.speak(results['ReturnMessage']);
} else if (results['ReturnMessage_Ar'] != null && isInit == false) { } else if (results['ReturnMessage_Ar'] != null && isInit == false) {
await flutterTts.setVoice({"name": "ar-xa-x-ard-network", "locale": "ar"}); //await tts.setVoice({"name" : voice[0]["name"],"locale": voice[0]["locale"]});
await flutterTts.speak(results['ReturnMessage_Ar']); await tts.speak(results['ReturnMessage_Ar']);
} }
stopAnimation(isInit: isInit); stopAnimation(isInit: isInit);
@ -850,7 +873,7 @@ class _FloatingSearchButton extends State<FloatingSearchButton> with TickerProvi
} }
initialSpeak() async { initialSpeak() async {
await flutterTts.awaitSpeakCompletion(true); // await flutterTts.awaitSpeakCompletion(true);
results = { results = {
'ReturnMessage_Ar': "هذه الخدمة تم تصميمها لتتمكن من ربط الملفات الطبية للعائلة بملفك الطبي حتى تتمكن من إدارة سجلاتهم عن طريق تسجيل الدخول إلى ملفك الطبي.", 'ReturnMessage_Ar': "هذه الخدمة تم تصميمها لتتمكن من ربط الملفات الطبية للعائلة بملفك الطبي حتى تتمكن من إدارة سجلاتهم عن طريق تسجيل الدخول إلى ملفك الطبي.",
'ReturnMessage': "Through this service, you will be able to link your family medical files to your medical file so that you can manage their records by login to your medical file." 'ReturnMessage': "Through this service, you will be able to link your family medical files to your medical file so that you can manage their records by login to your medical file."
@ -875,21 +898,21 @@ class _FloatingSearchButton extends State<FloatingSearchButton> with TickerProvi
}); });
}); });
} else { } else {
flutterTts.setCompletionHandler(() async { // tts.setCompletionHandler(() async {
event.setValue({"animationEnable": 'false'}); // event.setValue({"animationEnable": 'false'});
setState(() { // setState(() {
this.networkImage = null; // this.networkImage = null;
this.isAnimationEnable = false; // this.isAnimationEnable = false;
}); // });
}); // });
} }
flutterTts.setCompletionHandler(() async { // flutterTts.setCompletionHandler(() async {
event.setValue({"animationEnable": 'false'}); // event.setValue({"animationEnable": 'false'});
setState(() { // setState(() {
this.networkImage = null; // this.networkImage = null;
this.isAnimationEnable = false; // this.isAnimationEnable = false;
}); // });
}); // });
} }
signOut() async { signOut() async {

@ -1,5 +1,6 @@
import 'package:json_annotation/json_annotation.dart'; import 'package:json_annotation/json_annotation.dart';
part 'speech_recognition_error.g.dart'; part 'speech_recognition_error.g.dart';
/// A single error returned from the underlying speech services. /// A single error returned from the underlying speech services.

Loading…
Cancel
Save