From b759758a68a5dbb00a7d9925c0528a74a560de92 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Wed, 16 Dec 2020 12:21:13 +0300 Subject: [PATCH] bug fixes --- lib/config/localized_values.dart | 68 +++----- lib/config/shared_pref_kay.dart | 4 +- .../DrawerPages/family/add-family_type.dart | 2 +- lib/pages/DrawerPages/family/my-family.dart | 149 +++++++++++------- lib/pages/landing/landing_page.dart | 48 +++--- lib/pages/login/confirm-login.dart | 35 +++- lib/pages/login/login.dart | 1 + .../authentication/auth_provider.dart | 1 + .../family_files/family_files_provider.dart | 2 +- lib/uitl/translations_delegate_base.dart | 24 +-- lib/widgets/drawer/drawer_item_widget.dart | 17 +- 11 files changed, 212 insertions(+), 139 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 6c94019e..03fc51a9 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -75,7 +75,8 @@ const Map localizedValues = { 'ar': 'يرجى تأكيد الموعد لتفادي الإلغاء' }, "book-success-confirm-more-24-1-2": { - "en": "The online payment process will be available 24 hours before the appointment.", + "en": + "The online payment process will be available 24 hours before the appointment.", "ar": "- عملية الدفع الالكتروني ستكون متاحة قبل الموعد ب 24 ساعة." }, 'upcoming-payment-pending': { @@ -1114,68 +1115,51 @@ const Map localizedValues = { "not-active": {"en": "Not Active", "ar": "غير نشط"}, "card-detail": {"en": "Insurance Details", "ar": "منافعك التامينية"}, "Dr": {"en": "Dr. ", "ar": "الدكتور."}, - "empty": { - "en": "You do not have any records.", - "ar": "ليس لديك أي سجلات" - }, + "empty": {"en": "You do not have any records.", "ar": "ليس لديك أي سجلات"}, "last-visit": { "en": "How was your last visit with doctor?", "ar": "كيف تقيم زيارتك الأخيرة للطبيب؟" }, - "tap-title": { - "en": "Please rate the doctor", - "ar": "يرجى تقييم الطبيب" - }, - "later": { - "en": "Later", - "ar": "لاحقاً" - }, - "sendSuc":{ - "en":"A copy has been sent to the email", - "ar":"تم إرسال نسخة إلى البريد الإلكتروني" + "tap-title": {"en": "Please rate the doctor", "ar": "يرجى تقييم الطبيب"}, + "later": {"en": "Later", "ar": "لاحقاً"}, + "sendSuc": { + "en": "A copy has been sent to the email", + "ar": "تم إرسال نسخة إلى البريد الإلكتروني" }, "instructions": { - "en": "You can now talk directly to the appointments department by chat or request a call back", - "ar": "يمكنك الان التحدث مباشرة مع قسم المواعيد عن طريق خدمة المحادثة النصية أو طلب معاودة الاتصال" + "en": + "You can now talk directly to the appointments department by chat or request a call back", + "ar": + "يمكنك الان التحدث مباشرة مع قسم المواعيد عن طريق خدمة المحادثة النصية أو طلب معاودة الاتصال" }, "instructions-pharmacies": { - "en": "You can now talk directly to the pharmacist by chat or request a call back", - "ar": "يمكنك الآن التحدث مباشرة إلى الصيدلي عن طريق الدردشة أو طلب معاودة الاتصال" - }, - "select-hospital": { - "en": "Choose Hospital", - "ar": "اختر المستشفى" - }, - "start": { - "en": "Start", - "ar": "ابدأ" + "en": + "You can now talk directly to the pharmacist by chat or request a call back", + "ar": + "يمكنك الآن التحدث مباشرة إلى الصيدلي عن طريق الدردشة أو طلب معاودة الاتصال" }, + "select-hospital": {"en": "Choose Hospital", "ar": "اختر المستشفى"}, + "start": {"en": "Start", "ar": "ابدأ"}, "info-chat": { - "en": "This service allows you to chat with customer service directly without the need to call.", - "ar": "المحادثة المباشرة: هذه الخدمة تمكنك التحدث كتابياً مع خدمة العملاء مباشرة دون الحاجة الى الاتصال هاتفياً." + "en": + "This service allows you to chat with customer service directly without the need to call.", + "ar": + "المحادثة المباشرة: هذه الخدمة تمكنك التحدث كتابياً مع خدمة العملاء مباشرة دون الحاجة الى الاتصال هاتفياً." }, "last-appointment": { "en": "How was your appointment?", "ar": "كيف كان موعدك الطبي ؟" }, - "rate-clinic": { - "en": "Please rate the clinic", - "ar": "يرجى تقييم العيادة" - }, - "fetch-data": { - "en": "Fetch Data", - "ar": "تحديث الان" - }, + "rate-clinic": {"en": "Please rate the clinic", "ar": "يرجى تقييم العيادة"}, + "fetch-data": {"en": "Fetch Data", "ar": "تحديث الان"}, "send-email": { "en": "Send a copy of this report to the email", "ar": "أرسل نسخة من هذا التقرير إلى البريد الإلكتروني" }, - "update-email": { - "en": "Update Email", - "ar": "تحديث البريد الالكتروني" - }, + "update-email": {"en": "Update Email", "ar": "تحديث البريد الالكتروني"}, "noDataAvailable": { "en": "No data available", "ar": " لا يوجد بيانات متاحة " }, + "thename": {"en": "The Name", "ar": "الاسم"} }; diff --git a/lib/config/shared_pref_kay.dart b/lib/config/shared_pref_kay.dart index bcd7195b..a4e17388 100644 --- a/lib/config/shared_pref_kay.dart +++ b/lib/config/shared_pref_kay.dart @@ -19,4 +19,6 @@ const IS_LIVECARE_APPOINTMENT = 'is_livecare_appointment'; const IS_VIBRATION = 'is_vibration'; const THEME_VALUE = 'is_vibration'; const MAIN_USER = 'main-user'; -const WEATHER = 'weather'; \ No newline at end of file +const WEATHER = 'weather'; +const BLOOD_TYPE = 'blood-type'; +const NOTIFICATION_COUNT = 'notification-count'; diff --git a/lib/pages/DrawerPages/family/add-family_type.dart b/lib/pages/DrawerPages/family/add-family_type.dart index 2c85b043..cec0a0ab 100644 --- a/lib/pages/DrawerPages/family/add-family_type.dart +++ b/lib/pages/DrawerPages/family/add-family_type.dart @@ -27,7 +27,7 @@ class AddFamilyMemberType extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Image.asset( - 'assets/images/habib-logo.png', + 'assets/images/DQ/dq_logo_icon.png', height: 80, width: 80, ), diff --git a/lib/pages/DrawerPages/family/my-family.dart b/lib/pages/DrawerPages/family/my-family.dart index a86503a7..62dae624 100644 --- a/lib/pages/DrawerPages/family/my-family.dart +++ b/lib/pages/DrawerPages/family/my-family.dart @@ -55,7 +55,7 @@ class _MyFamily extends State with TickerProviderStateMixin { ProjectViewModel projectViewModel; AuthenticatedUser user; VitalSignService _vitalSignService = locator(); - + var isVaiable = false; @override void initState() { _tabController = new TabController(length: 2, vsync: this, initialIndex: 0); @@ -229,7 +229,8 @@ class _MyFamily extends State with TickerProviderStateMixin { if (snapshot.hasError) return Padding( padding: EdgeInsets.all(10), - child: Text("No data found")); + child: Text( + TranslationBase.of(context).noDataAvailable)); else return Padding( padding: EdgeInsets.only(top: 50), @@ -355,7 +356,8 @@ class _MyFamily extends State with TickerProviderStateMixin { if (snapshot.hasError) return Padding( padding: EdgeInsets.all(10), - child: Text('No data found')); + child: Text(TranslationBase.of(context) + .noDataAvailable)); else return Column( children: [ @@ -389,12 +391,20 @@ class _MyFamily extends State with TickerProviderStateMixin { left: 10, right: 10), child: Row(children: [ Expanded( - flex: 3, child: AppText('Name')), + flex: 3, + child: AppText( + TranslationBase.of(context) + .theName)), Expanded( - flex: 1, child: AppText('Allow')), + flex: 1, + child: AppText( + TranslationBase.of(context) + .allowView)), Expanded( flex: 1, - child: AppText('Reject')), + child: AppText( + TranslationBase.of(context) + .rejectView)), ])), Column( children: familyFileProvider @@ -469,12 +479,25 @@ class _MyFamily extends State with TickerProviderStateMixin { if (snapshot.hasError) return Padding( padding: EdgeInsets.all(10), - child: Text('No data found')); + child: Text(TranslationBase.of(context) + .noDataAvailable)); else - return SingleChildScrollView( - child: Container( - height: SizeConfig.screenHeight * .3, - child: ListView( + return Container( + height: SizeConfig.screenHeight * .3, + child: SingleChildScrollView( + child: Column( + children: [ + Padding( + padding: EdgeInsets.only( + left: 10, right: 10), + child: Row(children: [ + Expanded( + flex: 3, + child: AppText( + TranslationBase.of(context) + .theName)) + ])), + Column( children: snapshot .data.getAllSharedRecordsByStatusList .map((result) { @@ -492,12 +515,17 @@ class _MyFamily extends State with TickerProviderStateMixin { result.statusDescription, color: result.status == 3 ? Colors.green - : Colors.red, + : result.status == 2 + ? Colors + .yellow[800] + : Colors.red, )), ], )); }).toList(), - ))); + ) + ], + ))); } }) ], @@ -522,70 +550,59 @@ class _MyFamily extends State with TickerProviderStateMixin { if (snapshot.hasError) return Padding( padding: EdgeInsets.all(10), - child: Text('No data found')); + child: Text(TranslationBase.of(context) + .noDataAvailable)); else return Column( children: [ - // Padding( - // padding:EdgeInsets.only(left:10, right:10), - // child: Row( - // mainAxisAlignment: - // MainAxisAlignment.spaceBetween, - // children: [ - // Expanded( - // flex: 3, - // child: AppText( - // TranslationBase.of(context).request), - // ), - // Expanded( - // flex: 2, - // child: AppText( - // TranslationBase.of(context).switchUser, - // )), - // Expanded( - // flex: 1, - // child: AppText( - // TranslationBase.of(context).deleteView, - // )), - // ], - // )), Column(children: [ Padding( padding: EdgeInsets.only(left: 10, right: 10), child: Row(children: [ Expanded( - flex: 3, child: AppText('Name')), + flex: 3, + child: AppText( + TranslationBase.of(context) + .theName)), Expanded( - flex: 1, child: AppText('Delete')), + flex: 1, + child: AppText( + TranslationBase.of(context) + .deleteView)), ])), Column( children: familyFileProvider .allSharedRecordsByStatusResponse .getAllSharedRecordsByStatusList .map((result) { - return Padding( - padding: EdgeInsets.all(10), - child: Row( - children: [ - Expanded( - flex: 3, - child: AppText( - result.patientName)), - Expanded( - flex: 1, - child: IconButton( - icon: Icon( - Icons.delete, - color: Colors.black, - ), - onPressed: () { - deactivateRequest( - result.iD, 5, context); - }, - )), - ], - )); + return result.status == 3 + ? Padding( + padding: EdgeInsets.all(10), + child: Row( + children: [ + Expanded( + flex: 3, + child: AppText( + result.patientName)), + Expanded( + flex: 1, + child: IconButton( + icon: Icon( + Icons.delete, + color: Colors.black, + ), + onPressed: () { + deactivateRequest( + result.iD, + 5, + context); + }, + )), + ], + )) + : Container( + child: AppText(isAvailable())); }).toList()) ]) ], @@ -600,6 +617,15 @@ class _MyFamily extends State with TickerProviderStateMixin { ); } + String isAvailable() { + if (isVaiable == false) { + this.isVaiable = true; + return TranslationBase.of(context).noDataAvailable; + } else { + return ""; + } + } + Future getFamilyFiles() async { if (user != null) { if (await sharedPref.getObject(FAMILY_FILE) != null) { @@ -689,6 +715,7 @@ class _MyFamily extends State with TickerProviderStateMixin { } this.sharedPref.setString(APP_LANGUAGE, currentLang); this.sharedPref.setObject(MAIN_USER, mainUser); + //sharedPref.setString(BLOOD_TYPE, result['PatientBloodType']); this.sharedPref.setObject(USER_PROFILE, result.list); this.sharedPref.setObject(FAMILY_FILE, familyFile); this.sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID); diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart index b8d27d65..2094efd9 100644 --- a/lib/pages/landing/landing_page.dart +++ b/lib/pages/landing/landing_page.dart @@ -32,7 +32,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:provider/provider.dart'; - +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import '../../locator.dart'; import '../../routes.dart'; import 'home_page.dart'; @@ -154,7 +154,10 @@ class _LandingPageState extends State with WidgetsBindingObserver { if (token != null && await sharedPref.getObject(USER_PROFILE) == null) { DEVICE_TOKEN = token; checkUserStatus(token); + } else { + getNotificationCount(token); } + requestPermissions(); }).catchError((err) { print(err); @@ -513,25 +516,13 @@ class _LandingPageState extends State with WidgetsBindingObserver { // themeNotifier.setTheme(defaultTheme); } void checkUserStatus(token) async { + GifLoaderDialogUtils.showMyDialog(context); authService .selectDeviceImei(token) - .then((SelectDeviceIMEIRES value) => setUserValues(value)); - if (await sharedPref.getObject(USER_PROFILE) != null) { - var data = - AuthenticatedUser.fromJson(await sharedPref.getObject(USER_PROFILE)); - if (data != null) { - authService - .registeredAuthenticatedUser(data, token, 0, 0) - .then((res) => {print(res)}); - authService.getDashboard().then((value) => { - setState(() { - notificationCount = value['List_PatientDashboard'][0] - ['UnreadPatientNotificationCount'] - .toString(); - }) - }); - } - } + .then((SelectDeviceIMEIRES value) => setUserValues(value)) + .catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + }); } static Future myBackgroundMessageHandler( @@ -551,6 +542,7 @@ class _LandingPageState extends State with WidgetsBindingObserver { } void setUserValues(value) async { + GifLoaderDialogUtils.hideDialog(context); sharedPref.setObject(IMEI_USER_DATA, value); } @@ -571,4 +563,24 @@ class _LandingPageState extends State with WidgetsBindingObserver { ); } } + + getNotificationCount(token) async { + if (await sharedPref.getObject(USER_PROFILE) != null) { + var data = + AuthenticatedUser.fromJson(await sharedPref.getObject(USER_PROFILE)); + if (data != null) { + authService + .registeredAuthenticatedUser(data, token, 0, 0) + .then((res) => {print(res)}); + authService.getDashboard().then((value) => { + setState(() { + notificationCount = value['List_PatientDashboard'][0] + ['UnreadPatientNotificationCount'] + .toString(); + sharedPref.setString(NOTIFICATION_COUNT, notificationCount); + }) + }); + } + } + } } diff --git a/lib/pages/login/confirm-login.dart b/lib/pages/login/confirm-login.dart index 1c6bde43..7f7c883d 100644 --- a/lib/pages/login/confirm-login.dart +++ b/lib/pages/login/confirm-login.dart @@ -9,6 +9,8 @@ import 'package:diplomaticquarterapp/models/Authentication/check_activation_code import 'package:diplomaticquarterapp/models/Authentication/check_paitent_authentication_req.dart'; import 'package:diplomaticquarterapp/models/Authentication/select_device_imei_res.dart'; import 'package:diplomaticquarterapp/models/Authentication/send_activation_request.dart'; +import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; +import 'package:diplomaticquarterapp/pages/rateAppointment/rate_appointment_doctor.dart'; import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart'; @@ -22,6 +24,7 @@ import 'package:diplomaticquarterapp/widgets/card/rounded_container.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/otp/sms-popup.dart'; import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -512,6 +515,8 @@ class _ConfirmLogin extends State { sharedPref.remove(FAMILY_FILE), result.list.isFamily = false, userData = result.list, + // sharedPref.setString( + // BLOOD_TYPE, result['PatientBloodType']), sharedPref.setObject(MAIN_USER, result.list), sharedPref.setObject(USER_PROFILE, result.list), loginTokenID = result.logInTokenID, @@ -570,7 +575,35 @@ class _ConfirmLogin extends State { appointmentRateViewModel.isLogin = true; projectViewModel.isLogin = true; getToDoCount(); - Navigator.of(context).pushNamed(HOME); + appointmentRateViewModel + .getIsLastAppointmentRatedList() + .then((value) => { + getToDoCount(), + // GifLoaderDialogUtils.hideDialog(context), + if (appointmentRateViewModel.isHaveAppointmentNotRate) + { + Navigator.pushAndRemoveUntil( + context, + FadePage( + page: RateAppointmentDoctor(), + ), + (r) => false) + } + else + { + Navigator.pushAndRemoveUntil( + context, + FadePage( + page: LandingPage(), + ), + (r) => false) + } + }) + .catchError((err) { + print(err); + //GifLoaderDialogUtils.hideDialog(context); + }); + // SMSOTP.showLoadingDialog(context, false), } loading(flag) { diff --git a/lib/pages/login/login.dart b/lib/pages/login/login.dart index 729e294a..e212550b 100644 --- a/lib/pages/login/login.dart +++ b/lib/pages/login/login.dart @@ -244,6 +244,7 @@ class _Login extends State { sharedPref.remove(FAMILY_FILE), result = CheckActivationCode.fromJson(result), result.list.isFamily = false, + // this.sharedPref.setString(BLOOD_TYPE, result['PatientBloodType']), this.sharedPref.setObject(USER_PROFILE, result.list), this.sharedPref.setObject(MAIN_USER, result.list), this.sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID), diff --git a/lib/services/authentication/auth_provider.dart b/lib/services/authentication/auth_provider.dart index 07e1e301..3476435b 100644 --- a/lib/services/authentication/auth_provider.dart +++ b/lib/services/authentication/auth_provider.dart @@ -256,6 +256,7 @@ class AuthProvider with ChangeNotifier { return Future.value(error); // throw error; }, body: neRequest.toJson()); + sharedPref.setString(BLOOD_TYPE, localRes['PatientBloodType']); return Future.value(localRes); } catch (error) { throw error; diff --git a/lib/services/family_files/family_files_provider.dart b/lib/services/family_files/family_files_provider.dart index 0b0c1ef5..7a2dec81 100644 --- a/lib/services/family_files/family_files_provider.dart +++ b/lib/services/family_files/family_files_provider.dart @@ -299,7 +299,7 @@ class FamilyFilesProvider with ChangeNotifier { AppToast.showErrorToast(message: error); throw error; }, body: request); - + sharedPref.setString(BLOOD_TYPE, localRes['PatientBloodType']); return Future.value(localRes); } catch (error) { print(error); diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 3775ed4f..d87dc1f6 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -1004,26 +1004,32 @@ class TranslationBase { String get cardDetail => localizedValues['card-detail'][locale.languageCode]; String get dr => localizedValues['Dr'][locale.languageCode]; String get sendSuc => localizedValues['sendSuc'][locale.languageCode]; - String get instructions => localizedValues['instructions'][locale.languageCode]; - String get instructionsPharmacies => localizedValues['instructions-pharmacies'][locale.languageCode]; - String get selectHospitalDec => localizedValues['select-hospital'][locale.languageCode]; + String get instructions => + localizedValues['instructions'][locale.languageCode]; + String get instructionsPharmacies => + localizedValues['instructions-pharmacies'][locale.languageCode]; + String get selectHospitalDec => + localizedValues['select-hospital'][locale.languageCode]; String get start => localizedValues['start'][locale.languageCode]; String get infoChat => localizedValues['info-chat'][locale.languageCode]; - String get noRecords => localizedValues['empty'][locale.languageCode]; String get lastVisit => localizedValues['last-visit'][locale.languageCode]; String get tapTitle => localizedValues['tap-title'][locale.languageCode]; String get later => localizedValues['later'][locale.languageCode]; - String get lastAppointment => localizedValues['last-appointment'][locale.languageCode]; + String get lastAppointment => + localizedValues['last-appointment'][locale.languageCode]; String get rateClinic => localizedValues['rate-clinic'][locale.languageCode]; String get fetchData => localizedValues['fetch-data'][locale.languageCode]; - - String get sendConfEmail => localizedValues['send-email'][locale.languageCode]; - String get updateEmail => localizedValues['update-email'][locale.languageCode]; - String get noDataAvailable => localizedValues['noDataAvailable'][locale.languageCode]; + String get sendConfEmail => + localizedValues['send-email'][locale.languageCode]; + String get updateEmail => + localizedValues['update-email'][locale.languageCode]; + String get noDataAvailable => + localizedValues['noDataAvailable'][locale.languageCode]; + String get theName => localizedValues['thename'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/lib/widgets/drawer/drawer_item_widget.dart b/lib/widgets/drawer/drawer_item_widget.dart index e5a1eb50..100b9ae0 100644 --- a/lib/widgets/drawer/drawer_item_widget.dart +++ b/lib/widgets/drawer/drawer_item_widget.dart @@ -13,11 +13,13 @@ class DrawerItem extends StatefulWidget { final Color iconColor; final bool bottomLine; final bool sideArrow; + final Widget count; DrawerItem(this.title, this.icon, {this.textColor = Colors.black, this.iconColor = Colors.black87, this.subTitle = '', this.bottomLine = true, + this.count, this.sideArrow = false}); @override @@ -55,10 +57,15 @@ class _DrawerItemState extends State { crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ - Texts( - widget.title, - color: widget.textColor, - fontSize: SizeConfig.textMultiplier * 2.3, + Row( + children: [ + Texts( + widget.title, + color: widget.textColor, + fontSize: SizeConfig.textMultiplier * 2.3, + ), + widget.count ?? SizedBox(), + ], ), widget.subTitle != '' ? Texts( @@ -73,7 +80,7 @@ class _DrawerItemState extends State { flex: 1, child: Icon(Icons.keyboard_arrow_right, color: Colors.red)) - : Expanded(flex: 1, child: SizedBox()) + : Expanded(flex: 1, child: SizedBox()), ], ), ));