diff --git a/lib/config/shared_pref_kay.dart b/lib/config/shared_pref_kay.dart index 50390ae2..752938ad 100644 --- a/lib/config/shared_pref_kay.dart +++ b/lib/config/shared_pref_kay.dart @@ -33,3 +33,4 @@ const H2O_UNIT = 'H2O_UNIT'; const H2O_REMINDER = 'H2O_REMINDER'; const LIVECARE_CLINIC_DATA = 'LIVECARE_CLINIC_DATA'; const DOCTOR_SCHEDULE_DATE_SEL = 'DOCTOR_SCHEDULE_DATE_SEL'; +const APPOINTMENT_HISTORY_MEDICAL = 'APPOINTMENT_HISTORY_MEDICAL'; diff --git a/lib/core/service/medical/medical_service.dart b/lib/core/service/medical/medical_service.dart index 7e7cbe13..5c5e2d06 100644 --- a/lib/core/service/medical/medical_service.dart +++ b/lib/core/service/medical/medical_service.dart @@ -3,6 +3,7 @@ import 'package:diplomaticquarterapp/core/model/er/PatientER.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; import 'package:flutter/cupertino.dart'; +import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/pages/MyAppointments/models/DoctorScheduleResponse.dart'; @@ -18,16 +19,24 @@ class MedicalService extends BaseService { body['IsActiveAppointment'] = true; body['isDentalAllowedBackend'] = false; } - - await baseAppClient.post(GET_PATIENT_APPOINTMENT_HISTORY, onSuccess: (response, statusCode) async { + var appoHistory = await sharedPref.getObject(APPOINTMENT_HISTORY_MEDICAL); + if (appoHistory != null) { appoitmentAllHistoryResultList.clear(); - response['AppoimentAllHistoryResultList'].forEach((appoitment) { + appoHistory.forEach((appoitment) { appoitmentAllHistoryResultList.add(AppoitmentAllHistoryResultList.fromJson(appoitment)); }); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: body); + } else { + await baseAppClient.post(GET_PATIENT_APPOINTMENT_HISTORY, onSuccess: (response, statusCode) async { + appoitmentAllHistoryResultList.clear(); + response['AppoimentAllHistoryResultList'].forEach((appoitment) { + appoitmentAllHistoryResultList.add(AppoitmentAllHistoryResultList.fromJson(appoitment)); + }); + sharedPref.setObject(APPOINTMENT_HISTORY_MEDICAL, response['AppoimentAllHistoryResultList']); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: body); + } } addAmbulanceRequest({@required PatientER patientER}) async { diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart index 1ff631c7..85c1d369 100644 --- a/lib/pages/landing/landing_page.dart +++ b/lib/pages/landing/landing_page.dart @@ -157,21 +157,28 @@ class _LandingPageState extends State with WidgetsBindingObserver { return; } } + setState(() { - if (currentTab > 0 && tab == 2) - pageController.jumpToPage(0); - else if (tab != 0) { - if (tab == 4 && model.count == 0) { - AppToast.showErrorToast(message: TranslationBase.of(context).noBookedAppo); + if (tab == 5) { + IS_VOICE_COMMAND_CLOSED = false; + triggerRobot(); + + // pageController.jumpToPage(tab); + } else { + if (currentTab > 0 && tab == 2) + pageController.jumpToPage(0); + else if (tab != 0) { + if (tab == 4 && model.count == 0) { + AppToast.showErrorToast(message: TranslationBase.of(context).noBookedAppo); + } else { + pageController.jumpToPage(tab); + } } else { pageController.jumpToPage(tab); } - } else { - IS_VOICE_COMMAND_CLOSED = false; - pageController.jumpToPage(tab); + currentTab = tab; } - currentTab = tab; }); } @@ -631,7 +638,7 @@ class _LandingPageState extends State with WidgetsBindingObserver { } triggerRobot() { - event.setValue({"isRobot": 'true'}); + event.setValue({"isRobotVisible": 'true'}); } getText(currentTab) { diff --git a/lib/pages/medical/medical_profile_page.dart b/lib/pages/medical/medical_profile_page.dart index 3c426a3d..1d933530 100644 --- a/lib/pages/medical/medical_profile_page.dart +++ b/lib/pages/medical/medical_profile_page.dart @@ -37,7 +37,7 @@ class _MedicalProfilePageState extends State { builder: (_, model, widget) => AppScaffold( isShowDecPage: false, baseViewModel: model, - isHelp: true, + isHelp: false, body: Container( child: SingleChildScrollView( child: Column( diff --git a/lib/widgets/bottom_navigation/bottom_nav_bar.dart b/lib/widgets/bottom_navigation/bottom_nav_bar.dart index 1cebdfb4..57f954be 100644 --- a/lib/widgets/bottom_navigation/bottom_nav_bar.dart +++ b/lib/widgets/bottom_navigation/bottom_nav_bar.dart @@ -22,9 +22,7 @@ class BottomNavBar extends StatefulWidget { final ValueChanged changeIndex; final int index; final bool showHomeIcon; - BottomNavBar( - {Key key, this.changeIndex, this.index, this.showHomeIcon = false}) - : super(key: key); + BottomNavBar({Key key, this.changeIndex, this.index, this.showHomeIcon = false}) : super(key: key); @override _BottomNavBarState createState() => _BottomNavBarState(); @@ -36,7 +34,7 @@ class _BottomNavBarState extends State { var event = RobotProvider(); _changeIndex(int index) async { widget.changeIndex(index); - if (index == 0) { + if (index == 5) { event.setValue({'isRobotVisible': 'true'}); } } @@ -114,8 +112,7 @@ class _BottomNavBarState extends State { // currentIndex: 2, // name: TranslationBase.of(context).bookAppo, // ), - if (/*widget.index == 0 && */ projectViewModel - .havePrivilege(34)) + if (/*widget.index == 0 && */ projectViewModel.havePrivilege(34)) BottomNavigationItem( icon: EvaIcons.calendar, activeIcon: EvaIcons.calendar, @@ -130,7 +127,7 @@ class _BottomNavBarState extends State { activeIcon: DQIcons.roboticon, changeIndex: _changeIndex, index: widget.index, - currentIndex: 0, + currentIndex: 5, name: TranslationBase.of(context).help, ) ], diff --git a/lib/widgets/data_display/medical/time_line_new_widget.dart b/lib/widgets/data_display/medical/time_line_new_widget.dart index 09ab030c..c8c973e4 100644 --- a/lib/widgets/data_display/medical/time_line_new_widget.dart +++ b/lib/widgets/data_display/medical/time_line_new_widget.dart @@ -13,7 +13,7 @@ import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/avatar/large_avatar.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/list/flexible_container.dart'; +import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart' as auth; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; @@ -34,7 +34,7 @@ class _TimeLineViewState extends State { List tempList = []; List dateObjs = []; DateObj selectedDateObj = null; - + final authService = new auth.AuthProvider(); @override void initState() { super.initState(); @@ -276,9 +276,29 @@ class _TimeLineViewState extends State { } login() async { - Navigator.of(context).pushNamed( - WELCOME_LOGIN, - ); + var data = await sharedPref.getObject(IMEI_USER_DATA); + sharedPref.remove(REGISTER_DATA_FOR_LOGIIN); + if (data != null) { + Navigator.of(context).pushNamed(CONFIRM_LOGIN); + } else { + GifLoaderDialogUtils.showMyDialog(context); + authService.selectDeviceImei(DEVICE_TOKEN).then((SelectDeviceIMEIRES value) { + GifLoaderDialogUtils.hideDialog(context); + if (value != null) { + sharedPref.setObject(IMEI_USER_DATA, value); + Navigator.of(context).pushNamed(CONFIRM_LOGIN); + } else { + Navigator.of(context).pushNamed( + WELCOME_LOGIN, + ); + } + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + Navigator.of(context).pushNamed( + WELCOME_LOGIN, + ); + }); + } } } diff --git a/lib/widgets/drawer/app_drawer_widget.dart b/lib/widgets/drawer/app_drawer_widget.dart index 16bd98de..ed62a579 100644 --- a/lib/widgets/drawer/app_drawer_widget.dart +++ b/lib/widgets/drawer/app_drawer_widget.dart @@ -312,6 +312,7 @@ class _AppDrawerState extends State { fontHeight: projectProvider.isArabic ? 1 : 0.8, ), onTap: () { + sharedPref.remove(APPOINTMENT_HISTORY_MEDICAL); sharedPref.setBool(IS_ROBOT_INIT, null); if (projectProvider.isArabic) { projectProvider.changeLanguage('en'); diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index 9582ab8a..64980aad 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -279,6 +279,7 @@ class AppBarWidget extends StatefulWidget with PreferredSizeWidget { } String _badgeText = "0"; + class AppBarWidgetState extends State { String badgeText = "0"; @override @@ -397,42 +398,42 @@ class _RobotIcon extends State { return Positioned( child: Column( children: [ - isAnimation - ? Container( - height: 150, - width: 200, - padding: EdgeInsets.all(5), - margin: EdgeInsets.only(right: 35.0, bottom: 0), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.white, - boxShadow: [ - BoxShadow(color: Colors.black, spreadRadius: 1), - ], - ), - child: TyperAnimatedTextKit( - text: Provider.of(context, listen: false).isArabic == true - ? "هذه الخدمة تم تصميمها لتتمكن من ربط الملفات الطبية للعائلة بملفك الطبي حتى تتمكن من إدارة سجلاتهم عن طريق تسجيل الدخول إلى ملفك الطبي." - : "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.", - textLength: Provider.of(context, listen: false).isArabic == true - ? "هذه الخدمة تم تصميمها لتتمكن من ربط الملفات الطبية للعائلة بملفك الطبي حتى تتمكن من إدارة سجلاتهم عن طريق تسجيل الدخول إلى ملفك الطبي.".length - : "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." - .length)) - : Container(), + // isAnimation + // ? Container( + // height: 150, + // width: 200, + // padding: EdgeInsets.all(5), + // margin: EdgeInsets.only(right: 35.0, bottom: 0), + // decoration: BoxDecoration( + // borderRadius: BorderRadius.circular(10), + // color: Colors.white, + // boxShadow: [ + // BoxShadow(color: Colors.black, spreadRadius: 1), + // ], + // ), + // child: TyperAnimatedTextKit( + // text: Provider.of(context, listen: false).isArabic == true + // ? "هذه الخدمة تم تصميمها لتتمكن من ربط الملفات الطبية للعائلة بملفك الطبي حتى تتمكن من إدارة سجلاتهم عن طريق تسجيل الدخول إلى ملفك الطبي." + // : "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.", + // textLength: Provider.of(context, listen: false).isArabic == true + // ? "هذه الخدمة تم تصميمها لتتمكن من ربط الملفات الطبية للعائلة بملفك الطبي حتى تتمكن من إدارة سجلاتهم عن طريق تسجيل الدخول إلى ملفك الطبي.".length + // : "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." + // .length)) + // : Container(), Stack( children: [ - isAnimation - ? Positioned( - top: 0, - right: 40, - child: Container( - height: 0, - width: 0, - decoration: ShapeDecoration( - color: Colors.grey, - shape: MessageBorder(reverse: true), - ))) - : Container(), + // isAnimation + // ? Positioned( + // top: 0, + // right: 40, + // child: Container( + // height: 0, + // width: 0, + // decoration: ShapeDecoration( + // color: Colors.grey, + // shape: MessageBorder(reverse: true), + // ))) + // : Container(), FloatingSearchButton() ], ) diff --git a/lib/widgets/others/floating_button_search.dart b/lib/widgets/others/floating_button_search.dart index 195b479b..01957fbb 100644 --- a/lib/widgets/others/floating_button_search.dart +++ b/lib/widgets/others/floating_button_search.dart @@ -78,7 +78,7 @@ class FloatingSearchButton extends StatefulWidget { class _FloatingSearchButton extends State with TickerProviderStateMixin { Offset position = Offset(250, 400); bool activeAnimation = false; - bool isShow = true; + bool isShow = false; SearchProvider searchProvider = new SearchProvider(); RobotProvider eventProvider = RobotProvider(); bool isLoading = false; @@ -115,18 +115,16 @@ class _FloatingSearchButton extends State with TickerProvi offset = Tween(begin: Offset(0.0, 1.0), end: Offset(0.0, 0.0)).animate(controller); if (IS_VOICE_COMMAND_CLOSED == true) { controller.reverse(from: -1); - } - if (mounted) { - //Future.delayed(const Duration(seconds: 2), () { - isArabic = Provider.of(context, listen: false).isArabic; - requestPermissions(); - getUserData(); - initialSpeak(); - setState(() { - if (IS_TEXT_COMPLETED) { - isAnimationEnable = false; - } - }); + } else { + if (mounted) { + //Future.delayed(const Duration(seconds: 2), () { + + setState(() { + if (IS_TEXT_COMPLETED) { + isAnimationEnable = false; + } + }); + } } event.controller.stream.listen((p) { @@ -190,7 +188,7 @@ class _FloatingSearchButton extends State with TickerProvi placeholder: (context, url) => Image.asset('assets/images/gif/robot-idle.gif'), errorWidget: (context, url, error) => Icon(Icons.error), ) - : Image.asset(isAnimationEnable == true ? 'assets/images/gif/robot-speaking.gif' : 'assets/images/gif/robot-idle.gif'), + : Image.asset('assets/images/gif/robot-idle.gif'), ), onTap: () { new RoboSearch(context: context).showAlertDialog(context); @@ -273,7 +271,7 @@ class _FloatingSearchButton extends State with TickerProvi // }); } - void requestPermissions() async { + requestPermissions() async { if (await Permission.microphone.isDenied || await Permission.microphone.isUndetermined) { Map statuses = await [ Permission.microphone, @@ -282,7 +280,6 @@ class _FloatingSearchButton extends State with TickerProvi } Future initSpeechState() async { - bool hasSpeech = await speech.initialize(onError: errorListener, onStatus: statusListener); //if (hasSpeech) { // _currentLocaleId = // _currentLocaleId == 'en' @@ -290,6 +287,13 @@ class _FloatingSearchButton extends State with TickerProvi // : 'ar-SA'; // systemLocale.localeId; // } + + isArabic = Provider.of(context, listen: false).isArabic; + await requestPermissions(); + getUserData(); + await speech.initialize(onError: errorListener, onStatus: statusListener); + //initialSpeak(); + if (!mounted) return; // setState(() { diff --git a/lib/widgets/others/not_auh_page.dart b/lib/widgets/others/not_auh_page.dart index dc383c14..3bd9ae64 100644 --- a/lib/widgets/others/not_auh_page.dart +++ b/lib/widgets/others/not_auh_page.dart @@ -1,9 +1,13 @@ import 'package:carousel_slider/carousel_slider.dart'; +import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/models/Authentication/select_device_imei_res.dart'; import 'package:diplomaticquarterapp/pages/login/login-type.dart'; import 'package:diplomaticquarterapp/routes.dart'; +import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart' as auth; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; @@ -30,6 +34,7 @@ class NotAutPage extends StatefulWidget { } class _NotAutPageState extends State { + final authService = new auth.AuthProvider(); @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); @@ -64,7 +69,7 @@ class _NotAutPageState extends State { style: TextStyle(fontSize: 24, fontWeight: FontWeight.w700, color: Color(0xff2B353E), letterSpacing: -1.44, height: 23 / 24), ), Text( - widget.description??"", + widget.description ?? "", style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.56, height: 21 / 14), ), SizedBox( @@ -329,9 +334,23 @@ class _NotAutPageState extends State { if (data != null) { Navigator.of(context).pushNamed(CONFIRM_LOGIN); } else { - Navigator.of(context).pushNamed( - WELCOME_LOGIN, - ); + GifLoaderDialogUtils.showMyDialog(context); + authService.selectDeviceImei(DEVICE_TOKEN).then((SelectDeviceIMEIRES value) { + GifLoaderDialogUtils.hideDialog(context); + if (value != null) { + sharedPref.setObject(IMEI_USER_DATA, value); + Navigator.of(context).pushNamed(CONFIRM_LOGIN); + } else { + Navigator.of(context).pushNamed( + WELCOME_LOGIN, + ); + } + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + Navigator.of(context).pushNamed( + WELCOME_LOGIN, + ); + }); } } }