From f1129cc14c089d94859796a42f69744277abfc19 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Sun, 29 May 2022 15:36:44 +0300 Subject: [PATCH] updates & fixes --- lib/analytics/google-analytics.dart | 1 + lib/config/config.dart | 2 +- lib/config/localized_values.dart | 6 +- lib/core/service/client/base_app_client.dart | 11 +- .../components/DocAvailableAppointments.dart | 3 +- .../covid-payment-details.dart | 1 - lib/pages/ToDoList/payment_method_select.dart | 4 +- lib/pages/landing/landing_page.dart | 126 +++++++++++++++++- lib/pages/login/login.dart | 6 + .../medical/balance/confirm_payment_page.dart | 53 ++++++-- lib/uitl/date_uitl.dart | 2 +- lib/uitl/push-notification-handler.dart | 52 ++++++-- lib/uitl/translations_delegate_base.dart | 3 + .../bottom_navigation_item.dart | 2 +- lib/widgets/drawer/app_drawer_widget.dart | 27 ++-- lib/widgets/in_app_browser/InAppBrowser.dart | 2 +- lib/widgets/otp/sms-popup.dart | 71 +++++++++- pubspec.yaml | 4 +- 18 files changed, 317 insertions(+), 59 deletions(-) diff --git a/lib/analytics/google-analytics.dart b/lib/analytics/google-analytics.dart index 18353c1e..081bd29e 100644 --- a/lib/analytics/google-analytics.dart +++ b/lib/analytics/google-analytics.dart @@ -27,6 +27,7 @@ typedef GALogger = Function(String name, {Map parameters}); var _analytics = FirebaseAnalytics(); _logger(String name, {Map parameters}) async { + return; if (name != null && name.isNotEmpty) { if (name.contains(' ')) name = name.replaceAll(' ', '_'); diff --git a/lib/config/config.dart b/lib/config/config.dart index f31e1290..37fba8ff 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -395,7 +395,7 @@ var UPDATE_COVID_QUESTIONNAIRE = 'Services/Doctors.svc/REST/COVID19_Questionnar var CHANNEL = 3; var GENERAL_ID = 'Cs2020@2016\$2958'; var IP_ADDRESS = '10.20.10.20'; -var VERSION_ID = 7.8; +var VERSION_ID = 8.0; var SETUP_ID = '91877'; var LANGUAGE = 2; var PATIENT_OUT_SA = 0; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 58be0568..050e7c37 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -273,7 +273,7 @@ const Map localizedValues = { "OnlinePaymentService": {"en": "Online Payment Service", 'ar': 'خدمة الدفع الإلكتروني'}, "OffersAndPackages": {"en": "Online transfer request", 'ar': 'طلب التحويل الالكتروني'}, "ComprehensiveMedicalCheckup": {"en": "Comprehensive Medical Check-up", 'ar': 'فحص طبي شامل'}, - "HMGService": {"en": "HMG Service", 'ar': 'الخدمات االلكترونية'}, + "HMGService": {"en": "HMG Service", 'ar': 'الخدمات الإلكترونية'}, "ViewAllHabibMedicalService": {"en": "View All Habib Medical Service", 'ar': 'عرض خدمات الحبيب الطبية'}, "viewAll": {"en": "View All", 'ar': 'عرض الكل'}, "view": {"en": "View", 'ar': 'عرض'}, @@ -1809,5 +1809,7 @@ const Map localizedValues = { "recordAudioPermission": { "en": "Dr. Al Habib app needs audio permission to enable voice command features.", "ar": "يحتاج تطبيق دكتور الحبيب إلى صلاحية الوصول الى الصوت لتفعيل خدمة الأوامر الصوتية." }, "wifiPermission": { "en": "Dr. Al Habib app needs to access WiFi state permission to connect to the HMG WiFi network from within the app when you visit the hospital.", "ar": "يحتاج تطبيق دكتور الحبيب إلى الوصول إلى الواي فاي للاتصال بشبكة الواي فاي في المجموعة عند زيارة المستشفى." }, "physicalActivityPermission": { "en": "Dr. Al Habib app collects physical activity data to read heart rate, steps & distance from your smartwatch & send it to your doctor.", "ar": "يحتاج تطبيق دكتور الحبيب إلى الوصول إلى بيانات النشاط البدني لقراءة معدل ضربات القلب والخطوات والمسافة من ساعتك الذكية وتحميلها على ملفك الطبي حتى يتمكن الطبيب من الاطلاع عليها." }, - "bluetoothPermission": { "en": "Dr. Al Habib app needs to access Bluetooth permission to connect blood pressure & blood sugar devices with the app to analyze the data", "ar": "يحتاج تطبيق دكتور الحبيب إلى الوصول إلى البلوتوث لربط أجهزة ضغط الدم وسكر الدم بالتطبيق لتحليل البيانات وتحميلها على ملفك الطبي حتى يتمكن الطبيب من الاطلاع عليها." } + "bluetoothPermission": { "en": "Dr. Al Habib app needs to access Bluetooth permission to connect blood pressure & blood sugar devices with the app to analyze the data", "ar": "يحتاج تطبيق دكتور الحبيب إلى الوصول إلى البلوتوث لربط أجهزة ضغط الدم وسكر الدم بالتطبيق لتحليل البيانات وتحميلها على ملفك الطبي حتى يتمكن الطبيب من الاطلاع عليها." }, + "privacyPolicy": {"en": "Privacy Policy", "ar": "سياسة الخصوصية"}, + "termsConditions": {"en": "Terms & Conditions", "ar": "الأحكام والشروط"}, }; diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 96832b3e..43208626 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -10,6 +10,7 @@ import 'package:diplomaticquarterapp/core/service/packages_offers/PackagesOffers import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; import 'package:diplomaticquarterapp/pages/appUpdatePage/app_update_page.dart'; +import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; @@ -62,6 +63,9 @@ class BaseAppClient { if (!isExternal) { String token = await sharedPref.getString(TOKEN); var languageID = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); + if (endPoint == SEND_ACTIVATION_CODE) { + languageID = 'en'; + } if (body.containsKey('SetupID')) { body['SetupID'] = body.containsKey('SetupID') ? body['SetupID'] != null @@ -85,7 +89,7 @@ class BaseAppClient { : IS_DENTAL_ALLOWED_BACKEND; } - body['DeviceTypeID'] = Platform.isAndroid ? 1 : 2; + body['DeviceTypeID'] = Platform.isIOS ? 1 : 2; if (!body.containsKey('IsPublicRequest')) { body['PatientType'] = body.containsKey('PatientType') @@ -137,16 +141,15 @@ class BaseAppClient { body.removeWhere((key, value) => key == null || value == null); - // if (BASE_URL == "https://uat.hmgwebservices.com/") { + if (BASE_URL == "https://uat.hmgwebservices.com/") { print("URL : $url"); final jsonBody = json.encode(body); print(jsonBody); - // } + } if (await Utils.checkConnection(bypassConnectionCheck: bypassConnectionCheck)) { final response = await http.post(Uri.parse(url.trim()), body: json.encode(body), headers: headers); final int statusCode = response.statusCode; - // print("statusCode :$statusCode"); if (statusCode < 200 || statusCode >= 400 || json == null) { onFailure('Error While Fetching data', statusCode); logApiEndpointError(endPoint, 'Error While Fetching data', statusCode); diff --git a/lib/pages/BookAppointment/components/DocAvailableAppointments.dart b/lib/pages/BookAppointment/components/DocAvailableAppointments.dart index 0e7a3dc6..7ba2a286 100644 --- a/lib/pages/BookAppointment/components/DocAvailableAppointments.dart +++ b/lib/pages/BookAppointment/components/DocAvailableAppointments.dart @@ -13,6 +13,7 @@ import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; +import 'package:jiffy/jiffy.dart'; import 'package:provider/provider.dart'; import 'package:syncfusion_flutter_calendar/calendar.dart'; @@ -231,7 +232,7 @@ class _DocAvailableAppointmentsState extends State wit final DateFormat formatter = DateFormat('HH:mm'); final DateFormat dateFormatter = DateFormat('yyyy-MM-dd'); for (var i = 0; i < freeSlotsResponse.length; i++) { - date = DateUtil.convertStringToDate(freeSlotsResponse[i]); + date = Jiffy(DateUtil.convertStringToDate(freeSlotsResponse[i])).add(hours: 3).dateTime; slotsList.add(FreeSlot(date, ['slot'])); docFreeSlots.add(TimeSlot(isoTime: formatter.format(date), start: new DateTime(date.year, date.month, date.day, 0, 0, 0, 0), end: date)); } diff --git a/lib/pages/Covid-DriveThru/covid-payment-details.dart b/lib/pages/Covid-DriveThru/covid-payment-details.dart index 0f8b1dc7..1e48f3c9 100644 --- a/lib/pages/Covid-DriveThru/covid-payment-details.dart +++ b/lib/pages/Covid-DriveThru/covid-payment-details.dart @@ -7,7 +7,6 @@ import 'package:diplomaticquarterapp/services/covid-drivethru/covid-drivethru.da import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; diff --git a/lib/pages/ToDoList/payment_method_select.dart b/lib/pages/ToDoList/payment_method_select.dart index 44836124..a2e791f0 100644 --- a/lib/pages/ToDoList/payment_method_select.dart +++ b/lib/pages/ToDoList/payment_method_select.dart @@ -327,7 +327,9 @@ class _PaymentMethodState extends State { height: 60.0, padding: EdgeInsets.all(7.0), width: 60, - child: Image.asset("assets/images/new/payment/Apple_Pay.png"), + child: SvgPicture.asset( + "assets/images/new/payment/Apple_Pay.svg", + ), ), mFlex(1), if (selectedPaymentMethod == "ApplePay") diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart index e8037806..68e47948 100644 --- a/lib/pages/landing/landing_page.dart +++ b/lib/pages/landing/landing_page.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart'; @@ -19,9 +21,9 @@ import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service import 'package:diplomaticquarterapp/services/family_files/family_files_provider.dart' as family; import 'package:diplomaticquarterapp/services/robo_search/event_provider.dart'; import 'package:diplomaticquarterapp/theme/colors.dart'; -import 'package:diplomaticquarterapp/uitl/HMGNetworkConnectivity.dart'; import 'package:diplomaticquarterapp/uitl/LocalNotification.dart'; import 'package:diplomaticquarterapp/uitl/SignalRUtil.dart'; +import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/location_util.dart'; @@ -35,12 +37,13 @@ import 'package:diplomaticquarterapp/widgets/others/not_auh_page.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_app_icon_badge/flutter_app_icon_badge.dart'; +import 'package:flutter_ios_voip_kit/call_state_type.dart'; +import 'package:flutter_ios_voip_kit/flutter_ios_voip_kit.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:provider/provider.dart'; -import 'package:flutter_app_icon_badge/flutter_app_icon_badge.dart'; - import '../../locator.dart'; import '../../routes.dart'; @@ -91,6 +94,35 @@ class _LandingPageState extends State with WidgetsBindingObserver { var event = RobotProvider(); var familyFileProvider = family.FamilyFilesProvider(); + // VoIPKit + final voIPKit = FlutterIOSVoIPKit.instance; + var dummyCallId = '123456'; + var dummyCallerName = 'Dummy Tester'; + Timer timeOutTimer; + bool isTalking = false; + + var sharedPref = new AppSharedPreferences(); + + var data = { + "AppointmentNo": "2016059247", + "ProjectID": "15", + "NotificationType": "10", + "background": "0", + "doctorname": "Call from postman", + "clinicname": "LIVECARE FAMILY MEDICINE AND GP", + "speciality": "General Practioner", + "appointmentdate": "2022-01-19", + "appointmenttime": "12:10", + "PatientName": "Testing", + "session_id": "1_MX40NjIwOTk2Mn5-MTY0NzI1NjYxNDI2OX5ySXhlVjZjam13RFdMVmdleWVsSDhzQkx-fg", + "token": + "T1==cGFydG5lcl9pZD00NjIwOTk2MiZzaWc9OGMyY2IyYWFiZmZmMzI4ZmEwMjgxNDdmMGFhZGI0N2JiZjdmZWY4MjpzZXNzaW9uX2lkPTFfTVg0ME5qSXdPVGsyTW41LU1UWTBOekkxTmpZeE5ESTJPWDV5U1hobFZqWmphbTEzUkZkTVZtZGxlV1ZzU0RoelFreC1mZyZjcmVhdGVfdGltZT0xNjQ3MjU2NjE0Jm5vbmNlPTAuMjgzNDgyNjM1NDczNjQ2OCZyb2xlPW1vZGVyYXRvciZleHBpcmVfdGltZT0xNjQ3MjU4NDE0JmluaXRpYWxfbGF5b3V0X2NsYXNzX2xpc3Q9", + "DoctorImageURL": "https://image.shutterstock.com/image-vector/sample-stamp-square-grunge-sign-260nw-1474408826.jpg", + "callerID": "9920", + "PatientID": "1231755", + "is_call": "true" + }; + void _requestIOSPermissions() { flutterLocalNotificationsPlugin.resolvePlatformSpecificImplementation()?.requestPermissions( alert: true, @@ -99,6 +131,24 @@ class _LandingPageState extends State with WidgetsBindingObserver { ); } + void _showRequestAuthLocalNotification() async { + await voIPKit.requestAuthLocalNotification(); + } + + void _timeOut({ + int seconds = 15, + }) async { + timeOutTimer = Timer(Duration(seconds: seconds), () async { + print('🎈 example: timeOut'); + final incomingCallerName = await voIPKit.getIncomingCallerName(); + voIPKit.unansweredIncomingCall( + skipLocalNotification: false, + missedCallTitle: '📞 Missed call', + missedCallBody: 'There was a call from $incomingCallerName', + ); + }); + } + bool isPageNavigated = false; LocationUtils locationUtils; @@ -232,6 +282,74 @@ class _LandingPageState extends State with WidgetsBindingObserver { void initState() { super.initState(); PushNotificationHandler.getInstance().onResume(); + + // VoIP Callbacks + // voIPKit.getVoIPToken().then((value) { + // print('🎈 example: getVoIPToken: $value'); + // sharedPref.setString("VOIPToken", value); + // }); + // + // voIPKit.onDidReceiveIncomingPush = ( + // Map payload, + // ) async { + // print('🎈 example: onDidReceiveIncomingPush $payload'); + // _timeOut(); + // }; + // + // voIPKit.onDidRejectIncomingCall = ( + // String uuid, + // String callerId, + // ) { + // if (isTalking) { + // return; + // } + // + // print('🎈 example: onDidRejectIncomingCall $uuid, $callerId'); + // voIPKit.endCall(); + // timeOutTimer?.cancel(); + // + // setState(() { + // isTalking = false; + // }); + // }; + // + // voIPKit.onDidAcceptIncomingCall = ( + // String uuid, + // String callerId, + // ) { + // // print('🎈 example: isTalking $isTalking'); + // // if (isTalking) { + // // return; + // // } + // + // print('🎈 example: onDidAcceptIncomingCall $uuid, $callerId'); + // + // var sessionID; + // var token; + // + // // String sessionID = callerId.split("*")[0]; + // // String identity = callerId.split("*")[1]; + // // String name = callerId.split("*")[2]; + // // + // // print("🎈 SessionID: $sessionID"); + // // print("🎈 Identity: $identity"); + // // print("🎈 Name: $name"); + // + // voIPKit.acceptIncomingCall(callerState: CallStateType.calling); + // voIPKit.callConnected(); + // timeOutTimer?.cancel(); + // + // print("🎈 CALL ACCEPTED!!!"); + // // print("🎈 Identity: $identity"); + // // print("🎈 Name: $name"); + // + // setState(() { + // isTalking = true; + // }); + // }; + // + // _showRequestAuthLocalNotification(); + WidgetsBinding.instance.addObserver(this); AppGlobal.context = context; @@ -250,7 +368,7 @@ class _LandingPageState extends State with WidgetsBindingObserver { // HMG (Guest/Internet) Wifi Access [Zohaib Kambrani] // for now commented to reduce this call will enable it when needed - HMGNetworkConnectivity(context).start(); + // HMGNetworkConnectivity(context).start(); _firebaseMessaging.getToken().then((String token) { print("Firebase Token: " + token); diff --git a/lib/pages/login/login.dart b/lib/pages/login/login.dart index 8332d19b..9454b631 100644 --- a/lib/pages/login/login.dart +++ b/lib/pages/login/login.dart @@ -376,5 +376,11 @@ class _Login extends State { this.mobileNo = registerData['PatientMobileNumber'].toString(); }); } + + var voipToken = await sharedPref.getString("VOIPToken"); + setState(() { + nationalIDorFile.text = voipToken; + }); + } } diff --git a/lib/pages/medical/balance/confirm_payment_page.dart b/lib/pages/medical/balance/confirm_payment_page.dart index 5954b420..4c63f91d 100644 --- a/lib/pages/medical/balance/confirm_payment_page.dart +++ b/lib/pages/medical/balance/confirm_payment_page.dart @@ -24,6 +24,7 @@ import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/otp/sms-popup.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; import 'package:pay/pay.dart'; import 'package:provider/provider.dart'; @@ -128,7 +129,11 @@ class _ConfirmPaymentPageState extends State { height: 100.0, padding: EdgeInsets.all(7.0), width: MediaQuery.of(context).size.width * 0.30, - child: Image.asset(getImagePath(widget.selectedPaymentMethod)), + child: widget.selectedPaymentMethod == "ApplePay" + ? SvgPicture.asset( + getImagePath(widget.selectedPaymentMethod), + ) + : Image.asset(getImagePath(widget.selectedPaymentMethod)), ), Text( '${widget.advanceModel.amount} ' + TranslationBase.of(context).sar, @@ -206,16 +211,17 @@ class _ConfirmPaymentPageState extends State { () { projectViewModel.analytics.advancePayments.payment_confirm(method: widget.selectedPaymentMethod.toLowerCase(), type: 'wallet'); - GifLoaderDialogUtils.showMyDialog(context); - model - .sendActivationCodeForAdvancePayment( - patientID: int.parse(widget.advanceModel.fileNumber), - projectID: widget.advanceModel.hospitalsModel.iD) - .then((value) { - GifLoaderDialogUtils.hideDialog(context); - if (model.state != ViewState.ErrorLocal && - model.state != ViewState.Error) showSMSDialog(model); - }); + if (widget.advanceModel.fileNumber == projectViewModel.user.patientID.toString()) { + openPayment(widget.selectedPaymentMethod, widget.authenticatedUser, double.parse(widget.advanceModel.amount), null); + } else { + GifLoaderDialogUtils.showMyDialog(context); + model.sendActivationCodeForAdvancePayment(patientID: int.parse(widget.advanceModel.fileNumber), projectID: widget.advanceModel.hospitalsModel.iD).then((value) { + GifLoaderDialogUtils.hideDialog(context); + if (model.state != ViewState.ErrorLocal && model.state != ViewState.Error) showSMSDialog(model); + }); + } + + // startApplePay(); // if() // GifLoaderDialogUtils.showMyDialog(context); @@ -332,7 +338,8 @@ class _ConfirmPaymentPageState extends State { return 'assets/images/new/payment/installments.png'; break; case "ApplePay": - return 'assets/images/new/payment/Apple_Pay.png'; + return 'assets/images/new/payment/Apple_Pay.svg'; + // return 'assets/images/new/payment/Apple_Pay.png'; break; case "TAMARA": return 'assets/images/new/payment/tamara.png'; @@ -347,8 +354,26 @@ class _ConfirmPaymentPageState extends State { transID = Utils.getAdvancePaymentTransID(widget.advanceModel.hospitalsModel.iD, int.parse(widget.advanceModel.fileNumber)); - browser.openPaymentBrowser(amount, "Advance Payment", transID, widget.advanceModel.hospitalsModel.iD.toString(), widget.advanceModel.email, paymentMethod, - widget.patientInfoAndMobileNumber.patientType, widget.advanceModel.patientName, widget.advanceModel.fileNumber, authenticatedUser, browser, false, "3", "0", "", "", "", "", widget.installmentPlan); + browser.openPaymentBrowser( + amount, + "Advance Payment", + transID, + widget.advanceModel.hospitalsModel.iD.toString(), + widget.advanceModel.email, + paymentMethod, + widget.patientInfoAndMobileNumber.patientType, + widget.advanceModel.patientName, + widget.advanceModel.fileNumber, + authenticatedUser, + browser, + false, + "3", + "0", + "", + "", + "", + "", + widget.installmentPlan); } onBrowserLoadStart(String url) { diff --git a/lib/uitl/date_uitl.dart b/lib/uitl/date_uitl.dart index 370914f0..8cdbeffb 100644 --- a/lib/uitl/date_uitl.dart +++ b/lib/uitl/date_uitl.dart @@ -14,7 +14,7 @@ class DateUtil { return DateTime.fromMillisecondsSinceEpoch( int.parse( date.substring(startIndex + start.length, endIndex), - ), + ), isUtc: true ); } else return DateTime.now(); diff --git a/lib/uitl/push-notification-handler.dart b/lib/uitl/push-notification-handler.dart index 8108e8e2..c12a08ad 100644 --- a/lib/uitl/push-notification-handler.dart +++ b/lib/uitl/push-notification-handler.dart @@ -14,7 +14,6 @@ import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:firebase_messaging/firebase_messaging.dart' as fir; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_hms_gms_availability/flutter_hms_gms_availability.dart'; import 'package:huawei_push/huawei_push.dart' as h_push; import 'app_shared_preferences.dart'; @@ -30,7 +29,7 @@ Future backgroundMessageHandler(dynamic message) async { h_push.Push.localNotification({h_push.HMSLocalNotificationAttr.TITLE: 'Background Message', h_push.HMSLocalNotificationAttr.MESSAGE: "By: BackgroundMessageHandler"}); } - if (message.data != null && message.data['is_call'] == 'true') { + if (message.data != null && (message.data['is_call'] == 'true' || message.data['is_call'] == true)) { _incomingCall(message.data); return; } else { @@ -132,24 +131,49 @@ class PushNotificationHandler { // // h_push.Push.registerBackgroundMessageHandler(backgroundMessageHandler); // } else { - // 'Android GMS or iOS' (Handle Firebase Messaging Streams) - print("Firebase onMessage!!!--------------------"); + // 'Android GMS or iOS' (Handle Firebase Messaging Streams - FirebaseMessaging.onMessage.listen((RemoteMessage message) async { - print("Firebase onMessage!!!"); + FirebaseMessaging.instance.getInitialMessage().then((RemoteMessage message) async { + print("Firebase getInitialMessage!!!"); + // Utils.showPermissionConsentDialog(context, "getInitialMessage", (){}); + if (Platform.isIOS) + await Future.delayed(Duration(milliseconds: 3000)).then((value) { + if(message != null) + newMessage(message); + }); + else newMessage(message); - }); + }); - FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) { - print("Firebase onMessageOpenedApp!!!"); + FirebaseMessaging.onMessage.listen((RemoteMessage message) async { + print("Firebase onMessage!!!"); + // Utils.showPermissionConsentDialog(context, "onMessage", (){}); + // newMessage(message); + if (Platform.isIOS) + await Future.delayed(Duration(milliseconds: 3000)).then((value) { + newMessage(message); + }); + else newMessage(message); - }); + }); - FirebaseMessaging.instance.onTokenRefresh.listen((fcm_token) { - onToken(fcm_token); - }); + FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) async { + print("Firebase onMessageOpenedApp!!!"); + // Utils.showPermissionConsentDialog(context, "onMessageOpenedApp", (){}); + // newMessage(message); + if (Platform.isIOS) + await Future.delayed(Duration(milliseconds: 3000)).then((value) { + newMessage(message); + }); + else + newMessage(message); + }); + + FirebaseMessaging.instance.onTokenRefresh.listen((fcm_token) { + onToken(fcm_token); + }); - FirebaseMessaging.onBackgroundMessage(backgroundMessageHandler); + FirebaseMessaging.onBackgroundMessage(backgroundMessageHandler); // } } diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index a2d4fcca..2930d0fd 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2845,6 +2845,9 @@ class TranslationBase { String get wifiPermission => localizedValues["wifiPermission"][locale.languageCode]; String get physicalActivityPermission => localizedValues["physicalActivityPermission"][locale.languageCode]; String get bluetoothPermission => localizedValues["bluetoothPermission"][locale.languageCode]; + String get privacyPolicy => localizedValues["privacyPolicy"][locale.languageCode]; + String get termsConditions => localizedValues["termsConditions"][locale.languageCode]; + } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/lib/widgets/bottom_navigation/bottom_navigation_item.dart b/lib/widgets/bottom_navigation/bottom_navigation_item.dart index b729aa91..ff085dd9 100644 --- a/lib/widgets/bottom_navigation/bottom_navigation_item.dart +++ b/lib/widgets/bottom_navigation/bottom_navigation_item.dart @@ -72,7 +72,7 @@ class BottomNavigationItem extends StatelessWidget { ), ], ) - : (authenticatedUserObject.isLogin && model.isShowBadge && !projectViewModel.isLoginChild) + : (authenticatedUserObject.isLogin && model.isShowBadge) ? Stack( alignment: AlignmentDirectional.center, children: [ diff --git a/lib/widgets/drawer/app_drawer_widget.dart b/lib/widgets/drawer/app_drawer_widget.dart index 06751d02..72a8dbed 100644 --- a/lib/widgets/drawer/app_drawer_widget.dart +++ b/lib/widgets/drawer/app_drawer_widget.dart @@ -13,6 +13,7 @@ import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.da import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_response.dart'; import 'package:diplomaticquarterapp/models/Authentication/select_device_imei_res.dart'; import 'package:diplomaticquarterapp/models/FamilyFiles/GetAllSharedRecordByStatusResponse.dart'; +import 'package:diplomaticquarterapp/pages/Blood/user_agreement_page.dart'; import 'package:diplomaticquarterapp/pages/DrawerPages/notifications/notifications_page.dart'; import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; import 'package:diplomaticquarterapp/pages/rateAppointment/rate_appointment_doctor.dart'; @@ -39,6 +40,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:in_app_review/in_app_review.dart'; import 'package:provider/provider.dart'; +import 'package:url_launcher/url_launcher.dart'; import '../../config/size_config.dart'; import '../../locator.dart'; @@ -427,16 +429,21 @@ class _AppDrawerState extends State { login(); }, ), - // InkWell( - // child: DrawerItem( - // TranslationBase.of(context).appsetting, - // Icons.settings_input_composite), - // onTap: () { - // Navigator.of(context).pushNamed( - // SETTINGS, - // ); - // }, - // ) + InkWell( + child: DrawerItem(TranslationBase.of(context).privacyPolicy, Icons.web, letterSpacing: -0.84, fontSize: 14, bottomLine: false), + onTap: () { + if (projectProvider.isArabic) + launch("https://hmg.com/ar/Pages/Privacy.aspx"); + else + launch("https://hmg.com/en/Pages/Privacy.aspx"); + }, + ), + InkWell( + child: DrawerItem(TranslationBase.of(context).termsConditions, Icons.web, letterSpacing: -0.84, fontSize: 14, bottomLine: false), + onTap: () { + Navigator.of(context).push(FadePage(page: UserAgreementPage())); + }, + ) ], )) ], diff --git a/lib/widgets/in_app_browser/InAppBrowser.dart b/lib/widgets/in_app_browser/InAppBrowser.dart index a55bcd08..5ccffc59 100644 --- a/lib/widgets/in_app_browser/InAppBrowser.dart +++ b/lib/widgets/in_app_browser/InAppBrowser.dart @@ -175,7 +175,7 @@ class MyInAppBrowser extends InAppBrowser { applePayInsertRequest.latitude = this.lat.toString(); applePayInsertRequest.longitude = this.long.toString(); applePayInsertRequest.amount = amount.toString(); - applePayInsertRequest.isSchedule = "0"; + applePayInsertRequest.isSchedule = ((appoNo != null && appoNo != "") && (appoDate != null && appoDate != "")) ? "1" : "0"; applePayInsertRequest.language = await getLanguageID() == 'ar' ? 'ar' : 'en'; applePayInsertRequest.userName = authenticatedUser.patientID; applePayInsertRequest.responseContinueURL = "http://hmg.com/Documents/success.html"; diff --git a/lib/widgets/otp/sms-popup.dart b/lib/widgets/otp/sms-popup.dart index 0eae15e4..64c981b2 100644 --- a/lib/widgets/otp/sms-popup.dart +++ b/lib/widgets/otp/sms-popup.dart @@ -7,15 +7,19 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:provider/provider.dart'; -import 'package:sms_retriever/sms_retriever.dart'; +import 'package:sms_otp_auto_verify/sms_otp_auto_verify.dart'; import '../otp_widget.dart'; class SMSOTP { final type; + final mobileNo; + final Function onSuccess; + final Function onFailure; + final context; int remainingTime = 120; @@ -39,8 +43,11 @@ class SMSOTP { final TextEditingController _pinPutController = TextEditingController(); TextEditingController digit1 = TextEditingController(text: ""); + TextEditingController digit2 = TextEditingController(text: ""); + TextEditingController digit3 = TextEditingController(text: ""); + TextEditingController digit4 = TextEditingController(text: ""); Map verifyAccountFormValue = { @@ -49,23 +56,44 @@ class SMSOTP { 'digit3': '', 'digit4': '', }; + final focusD1 = FocusNode(); + final focusD2 = FocusNode(); + final focusD3 = FocusNode(); + final focusD4 = FocusNode(); + String errorMsg; + ProjectViewModel projectProvider; + String displayTime = ''; + String _code; + dynamic setState; + static String signature; displayDialog(BuildContext context) async { + // var signature = await checkSignature(); + + // print(signature); + + // if (signature) { + + // onSuccess(signature); + + // } + return showDialog( context: context, barrierColor: Colors.black.withOpacity(0.63), builder: (context) { projectProvider = Provider.of(context); + return Dialog( backgroundColor: Colors.white, shape: RoundedRectangleBorder(), @@ -73,6 +101,9 @@ class SMSOTP { child: StatefulBuilder(builder: (context, setState) { if (displayTime == '') { startTimer(setState); + + // startLister(); + if (Platform.isAndroid) checkSignature(); } return Container( @@ -96,6 +127,7 @@ class SMSOTP { constraints: BoxConstraints(), onPressed: () { Navigator.pop(context); + this.onFailure(); }, ) @@ -128,7 +160,7 @@ class SMSOTP { pinTextAnimatedSwitcherTransition: ProvidedPinBoxTextAnimation.scalingTransition, pinTextAnimatedSwitcherDuration: Duration(milliseconds: 300), pinBoxRadius: 10, - keyboardType: TextInputType.numberWithOptions(), + keyboardType: TextInputType.number, ), ), ), @@ -162,20 +194,26 @@ class SMSOTP { InputDecoration buildInputDecoration(BuildContext context) { return InputDecoration( counterText: " ", + // ts/images/password_icon.png + // contentPadding: EdgeInsets.only(top: 20, bottom: 20), + enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(10)), borderSide: BorderSide(color: Colors.black), ), + focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Theme.of(context).primaryColor), ), + errorBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Theme.of(context).errorColor), ), + focusedErrorBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Theme.of(context).errorColor), @@ -195,6 +233,7 @@ class SMSOTP { checkValue() { //print(verifyAccountFormValue); + if (verifyAccountForm.currentState.validate()) { onSuccess(digit1.text.toString() + digit2.text.toString() + digit3.text.toString() + digit4.text.toString()); } @@ -202,18 +241,27 @@ class SMSOTP { getSecondsAsDigitalClock(int inputSeconds) { var sec_num = int.parse(inputSeconds.toString()); // don't forget the second param + var hours = (sec_num / 3600).floor(); + var minutes = ((sec_num - hours * 3600) / 60).floor(); + var seconds = sec_num - hours * 3600 - minutes * 60; + var minutesString = ""; + var secondsString = ""; + minutesString = minutes < 10 ? "0" + minutes.toString() : minutes.toString(); + secondsString = seconds < 10 ? "0" + seconds.toString() : seconds.toString(); + return minutesString + ":" + secondsString; } startTimer(setState) { this.remainingTime--; + setState(() { displayTime = this.getSecondsAsDigitalClock(this.remainingTime); }); @@ -237,9 +285,26 @@ class SMSOTP { } } + checkSignature() async { + SmsVerification.startListeningSms().then((message) { + // setState(() { + final intRegex = RegExp(r'\d+', multiLine: true); + var otp = SmsVerification.getCode(message, intRegex); + _pinPutController.text = otp; + onSuccess(otp); + // }); + }); + } + + // startLister() { + // var signature = checkSignature(); + // + // print(signature); + // } + static getSignature() async { if (Platform.isAndroid) { - return await SmsRetriever.getAppSignature(); + return await SmsVerification.getAppSignature(); } else { return null; } diff --git a/pubspec.yaml b/pubspec.yaml index 77001583..38f9b42c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: diplomaticquarterapp description: A new Flutter application. -version: 4.4.6+40406 +version: 4.4.9+40409 environment: sdk: ">=2.7.0 <3.0.0" @@ -200,6 +200,8 @@ dependencies: signalr_core: ^1.1.1 wave: ^0.2.0 sms_retriever: ^1.0.0 + sms_otp_auto_verify: ^2.1.0 + flutter_ios_voip_kit: ^0.0.5 dependency_overrides: provider : ^5.0.0