From abcf82346e3afc81bc475415d55a6976c520f926 Mon Sep 17 00:00:00 2001 From: Sultan khan <> Date: Thu, 21 Sep 2023 16:44:58 +0300 Subject: [PATCH] Excluded change --- lib/config/config.dart | 2 +- .../send_activation_request.dart | 8 +- .../DrawerPages/family/add-family-member.dart | 41 +++++-- lib/pages/DrawerPages/family/my-family.dart | 8 +- .../family_files/family_files_provider.dart | 3 +- lib/uitl/LocalNotification.dart | 114 +++++++++--------- lib/uitl/push-notification-handler.dart | 12 +- 7 files changed, 105 insertions(+), 83 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index e93af7c8..d5482cb8 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -19,7 +19,7 @@ var PACKAGES_SHOPPING_CART = '/api/shopping_cart_items'; var PACKAGES_ORDERS = '/api/orders'; var PACKAGES_ORDER_HISTORY = '/api/orders/items'; var PACKAGES_TAMARA_OPT = '/api/orders/paymentoptions/tamara'; -// var BASE_URL = 'http://10.50.100.198:2018/'; +// var BASE_URL = 'http://10.50.100.198:4422/'; var BASE_URL = 'https://uat.hmgwebservices.com/'; // var BASE_URL = 'https://hmgwebservices.com/'; // var BASE_URL = 'https://orash.cloudsolutions.com.sa/'; diff --git a/lib/models/Authentication/send_activation_request.dart b/lib/models/Authentication/send_activation_request.dart index 9c9c7804..fbaa744c 100644 --- a/lib/models/Authentication/send_activation_request.dart +++ b/lib/models/Authentication/send_activation_request.dart @@ -28,7 +28,7 @@ class SendActivationRequest { int responseID; int status; int familyRegionID; - + bool isPatientExcluded; SendActivationRequest( {this.patientMobileNumber, this.mobileNo, @@ -58,7 +58,9 @@ class SendActivationRequest { this.healthId, this.responseID, this.status, - this.familyRegionID}); + this.familyRegionID, + this.isPatientExcluded + }); SendActivationRequest.fromJson(Map json) { patientMobileNumber = json['PatientMobileNumber']; @@ -90,6 +92,7 @@ class SendActivationRequest { responseID = json['ReponseID']; status = json['Status']; familyRegionID = json['FamilyRegionID']; + isPatientExcluded = json['IsPatientExcluded']; } Map toJson() { @@ -123,6 +126,7 @@ class SendActivationRequest { data['ResponseID'] = responseID; data['Status'] = status; data['FamilyRegionID'] = familyRegionID; + data['IsPatientExcluded'] = isPatientExcluded; return data; } } diff --git a/lib/pages/DrawerPages/family/add-family-member.dart b/lib/pages/DrawerPages/family/add-family-member.dart index 6d9064d7..c3d79918 100644 --- a/lib/pages/DrawerPages/family/add-family-member.dart +++ b/lib/pages/DrawerPages/family/add-family-member.dart @@ -161,7 +161,8 @@ class _AddMember extends State { } insertFamilyData(addMemberResult) { - sendActivationCode(addMemberResult); + + sendActivationCode(addMemberResult, addMemberResult['ShareFamilyFileObj']['IsPatientExcluded']); // var request = InsertSharePatientFileReq(); // request.responseID = addMemberResult['ShareFamilyFileObj']['ReponseID']; // request.shareFamilyPatientName = addMemberResult['ShareFamilyFileObj']['SharedPatientName']; @@ -178,13 +179,21 @@ class _AddMember extends State { // }); } - sendActivationCode(result) { + sendActivationCode(result, bool isExcluded) { // var request = this.getCommonRequest(); loading(true); patientShareResponseID = result['ShareFamilyFileObj']['ReponseID']; - familyFileProvider.sendActivationCode(mobileNo, countryCode, nationalIDorFile.text, patientShareResponseID).then((res) => { - patientShareRequestID = res['PatientShareRequestID'], - if (res != null && res['isSMSSent'] == true) {this.startSMSService(1, res)} + familyFileProvider.sendActivationCode(mobileNo, countryCode, nationalIDorFile.text, patientShareResponseID, isExcluded).then((res) { + patientShareRequestID = res['PatientShareRequestID']; + if (res != null && res['isSMSSent'] == true) + { + this.startSMSService(1, res); + + }else + { + this.checkActivationCodeExcluded('0000', res); + } + }); } @@ -206,12 +215,19 @@ class _AddMember extends State { ).displayDialog(context); } + checkActivationCodeExcluded(value, result){ + familyFileProvider.checkActivationCode(result['LogInTokenID'], value, nationalIDorFile.text, mobileNo, patientShareRequestID, patientShareResponseID).then((result) { + SMSOTP.hideSMSBox(context); + handleFamilyRequests(); + }); + } + checkActivationCode(value, result) { Navigator.pop(context); GifLoaderDialogUtils.showMyDialog(context); familyFileProvider.checkActivationCode(result['LogInTokenID'], value, nationalIDorFile.text, mobileNo, patientShareRequestID, patientShareResponseID).then((result) { SMSOTP.hideSMSBox(context); - handleFamilyRequests(this.patientShareRequestID, 3); + handleFamilyRequests(); }).catchError((err) { Future.delayed(Duration(seconds: 1), () { AppToast.showErrorToast(message: err); @@ -220,13 +236,12 @@ class _AddMember extends State { }); } - handleFamilyRequests(id, stauts) { - // familyFileProvider.acceptAndRejectRecievedRequests(id, stauts).then((result) => { - sharedPref.remove(FAMILY_FILE); - Navigator.of(context).pushNamed( - MY_FAMILIY, - ); - // }); + handleFamilyRequests() { + Navigator.pop(context); + sharedPref.remove(FAMILY_FILE); + Navigator.of(context).pushNamed( + MY_FAMILIY + ); } loading(flag) { diff --git a/lib/pages/DrawerPages/family/my-family.dart b/lib/pages/DrawerPages/family/my-family.dart index fa7d4a6a..0eedf483 100644 --- a/lib/pages/DrawerPages/family/my-family.dart +++ b/lib/pages/DrawerPages/family/my-family.dart @@ -443,7 +443,11 @@ class _MyFamily extends State with TickerProviderStateMixin { Map request = {}; request['ID'] = this.userID; request['IsActive'] = false; - this.familyFileProvider.deativateActivateMemberFile(request).then((value) => refreshFamily(context)); + this.familyFileProvider.deativateActivateMemberFile(request).then((value) { + refreshFamily(context); + GifLoaderDialogUtils.hideDialog(context); + }); + } refreshFamily(context) async { @@ -541,6 +545,7 @@ class _MyFamily extends State with TickerProviderStateMixin { setState(() { }); + } } @@ -561,6 +566,7 @@ class _MyFamily extends State with TickerProviderStateMixin { familySharedRecords = await familyFileProvider.getSharedRecordByStatus(); } sentRecordsList =[]; + familySharedRecordsList =[]; familySharedRecords.getAllSharedRecordsByStatusList.forEach((element) { if (element.status == 3) { familySharedRecordsList.add(element); diff --git a/lib/services/family_files/family_files_provider.dart b/lib/services/family_files/family_files_provider.dart index 7a41f6b9..901d3b42 100644 --- a/lib/services/family_files/family_files_provider.dart +++ b/lib/services/family_files/family_files_provider.dart @@ -138,7 +138,7 @@ class FamilyFilesProvider with ChangeNotifier { } } - Future sendActivationCode(cellNumber, zipCode, patientIdentificationID, responseID) async { + Future sendActivationCode(cellNumber, zipCode, patientIdentificationID, responseID, bool isExcluded) async { try { dynamic localRes; var request = SendActivationRequest(); @@ -152,6 +152,7 @@ class FamilyFilesProvider with ChangeNotifier { request.responseID = responseID; request.status = 2; request.familyRegionID = zipCode == '966' ? 1 : 2; + request.isPatientExcluded = isExcluded; await new BaseAppClient().post(SEND_FAMILY_FILE_ACTIVATION, onSuccess: (dynamic response, int statusCode) { localRes = response; }, onFailure: (String error, int statusCode) { diff --git a/lib/uitl/LocalNotification.dart b/lib/uitl/LocalNotification.dart index d7afaa90..9e0cd11b 100644 --- a/lib/uitl/LocalNotification.dart +++ b/lib/uitl/LocalNotification.dart @@ -31,24 +31,24 @@ class LocalNotification { _initialize() async { try { var initializationSettingsAndroid = new AndroidInitializationSettings('app_icon'); - var initializationSettingsIOS = DarwinInitializationSettings(onDidReceiveLocalNotification: null); - var initializationSettings = InitializationSettings(android: initializationSettingsAndroid, iOS: initializationSettingsIOS); - await flutterLocalNotificationsPlugin.initialize( - initializationSettings, - onDidReceiveNotificationResponse: (NotificationResponse notificationResponse) { - switch (notificationResponse.notificationResponseType) { - case NotificationResponseType.selectedNotification: - // selectNotificationStream.add(notificationResponse.payload); - break; - case NotificationResponseType.selectedNotificationAction: - // if (notificationResponse.actionId == navigationActionId) { - // selectNotificationStream.add(notificationResponse.payload); - // } - break; - } - }, - onDidReceiveBackgroundNotificationResponse: notificationTapBackground, - ); + // var initializationSettingsIOS = DarwinInitializationSettings(onDidReceiveLocalNotification: null); + // var initializationSettings = InitializationSettings(android: initializationSettingsAndroid, iOS: initializationSettingsIOS); + // await flutterLocalNotificationsPlugin.initialize( + // initializationSettings, + // onDidReceiveNotificationResponse: (NotificationResponse notificationResponse) { + // switch (notificationResponse.notificationResponseType) { + // case NotificationResponseType.selectedNotification: + // // selectNotificationStream.add(notificationResponse.payload); + // break; + // case NotificationResponseType.selectedNotificationAction: + // // if (notificationResponse.actionId == navigationActionId) { + // // selectNotificationStream.add(notificationResponse.payload); + // // } + // break; + // } + // }, + // onDidReceiveBackgroundNotificationResponse: notificationTapBackground, + // ); } catch (ex) {} // flutterLocalNotificationsPlugin.initialize(initializationSettings, onDidReceiveNotificationResponse: (NotificationResponse notificationResponse) // { @@ -68,16 +68,16 @@ class LocalNotification { // ); } - void notificationTapBackground(NotificationResponse notificationResponse) { - // ignore: avoid_print - print('notification(${notificationResponse.id}) action tapped: ' - '${notificationResponse.actionId} with' - ' payload: ${notificationResponse.payload}'); - if (notificationResponse.input?.isNotEmpty ?? false) { - // ignore: avoid_print - print('notification action tapped with input: ${notificationResponse.input}'); - } - } + // void notificationTapBackground(NotificationResponse notificationResponse) { + // // ignore: avoid_print + // print('notification(${notificationResponse.id}) action tapped: ' + // '${notificationResponse.actionId} with' + // ' payload: ${notificationResponse.payload}'); + // if (notificationResponse.input?.isNotEmpty ?? false) { + // // ignore: avoid_print + // print('notification action tapped with input: ${notificationResponse.input}'); + // } + // } var _random = new Random(); @@ -96,15 +96,15 @@ class LocalNotification { } Future showNow({@required String title, @required String subtitle, String payload}) { - Future.delayed(Duration(seconds: 1)).then((result) async { - var androidPlatformChannelSpecifics = AndroidNotificationDetails('com.hmg.local_notification', 'HMG', - channelDescription: 'HMG', importance: Importance.max, priority: Priority.high, ticker: 'ticker', vibrationPattern: _vibrationPattern()); - var iOSPlatformChannelSpecifics = DarwinNotificationDetails(); - var platformChannelSpecifics = NotificationDetails(android: androidPlatformChannelSpecifics, iOS: iOSPlatformChannelSpecifics); - await flutterLocalNotificationsPlugin.show(_randomNumber(), title, subtitle, platformChannelSpecifics, payload: payload).catchError((err) { - print(err); - }); - }); + // Future.delayed(Duration(seconds: 1)).then((result) async { + // var androidPlatformChannelSpecifics = AndroidNotificationDetails('com.hmg.local_notification', 'HMG', + // channelDescription: 'HMG', importance: Importance.max, priority: Priority.high, ticker: 'ticker', vibrationPattern: _vibrationPattern()); + // var iOSPlatformChannelSpecifics = DarwinNotificationDetails(); + // var platformChannelSpecifics = NotificationDetails(android: androidPlatformChannelSpecifics, iOS: iOSPlatformChannelSpecifics); + // await flutterLocalNotificationsPlugin.show(_randomNumber(), title, subtitle, platformChannelSpecifics, payload: payload).catchError((err) { + // print(err); + // }); + // }); } Future scheduleNotification({@required DateTime scheduledNotificationDateTime, @required String title, @required String description}) async { @@ -115,31 +115,31 @@ class LocalNotification { vibrationPattern[2] = 5000; vibrationPattern[3] = 2000; - var androidPlatformChannelSpecifics = AndroidNotificationDetails('active-prescriptions', 'ActivePrescriptions', - channelDescription: 'ActivePrescriptionsDescription', - // icon: 'secondary_icon', - sound: RawResourceAndroidNotificationSound('slow_spring_board'), - - ///change it to be as ionic - // largeIcon: DrawableResourceAndroidBitmap('sample_large_icon'),///change it to be as ionic - vibrationPattern: vibrationPattern, - enableLights: true, - color: const Color.fromARGB(255, 255, 0, 0), - ledColor: const Color.fromARGB(255, 255, 0, 0), - ledOnMs: 1000, - ledOffMs: 500); - var iOSPlatformChannelSpecifics = DarwinNotificationDetails(sound: 'slow_spring_board.aiff'); + // var androidPlatformChannelSpecifics = AndroidNotificationDetails('active-prescriptions', 'ActivePrescriptions', + // channelDescription: 'ActivePrescriptionsDescription', + // // icon: 'secondary_icon', + // sound: RawResourceAndroidNotificationSound('slow_spring_board'), + // + // ///change it to be as ionic + // // largeIcon: DrawableResourceAndroidBitmap('sample_large_icon'),///change it to be as ionic + // vibrationPattern: vibrationPattern, + // enableLights: true, + // color: const Color.fromARGB(255, 255, 0, 0), + // ledColor: const Color.fromARGB(255, 255, 0, 0), + // ledOnMs: 1000, + // ledOffMs: 500); + // var iOSPlatformChannelSpecifics = DarwinNotificationDetails(sound: 'slow_spring_board.aiff'); // /change it to be as ionic - var platformChannelSpecifics = NotificationDetails(android: androidPlatformChannelSpecifics, iOS: iOSPlatformChannelSpecifics); - await flutterLocalNotificationsPlugin.schedule(0, title, description, scheduledNotificationDateTime, platformChannelSpecifics); + // var platformChannelSpecifics = NotificationDetails(android: androidPlatformChannelSpecifics, iOS: iOSPlatformChannelSpecifics); + // await flutterLocalNotificationsPlugin.schedule(0, title, description, scheduledNotificationDateTime, platformChannelSpecifics); } ///Repeat notification every day at approximately 10:00:00 am Future showDailyAtTime() async { var time = Time(10, 0, 0); - var androidPlatformChannelSpecifics = AndroidNotificationDetails('repeatDailyAtTime channel id', 'repeatDailyAtTime channel name', channelDescription: 'repeatDailyAtTime description'); - var iOSPlatformChannelSpecifics = DarwinNotificationDetails(); + // var androidPlatformChannelSpecifics = AndroidNotificationDetails('repeatDailyAtTime channel id', 'repeatDailyAtTime channel name', channelDescription: 'repeatDailyAtTime description'); + // var iOSPlatformChannelSpecifics = DarwinNotificationDetails(); // var platformChannelSpecifics = NotificationDetails( // androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics); // await flutterLocalNotificationsPlugin.showDailyAtTime( @@ -153,8 +153,8 @@ class LocalNotification { ///Repeat notification weekly on Monday at approximately 10:00:00 am Future showWeeklyAtDayAndTime() async { var time = Time(10, 0, 0); - var androidPlatformChannelSpecifics = AndroidNotificationDetails('show weekly channel id', 'show weekly channel name', channelDescription: 'show weekly description'); - var iOSPlatformChannelSpecifics = DarwinNotificationDetails(); + // var androidPlatformChannelSpecifics = AndroidNotificationDetails('show weekly channel id', 'show weekly channel name', channelDescription: 'show weekly description'); + // var iOSPlatformChannelSpecifics = DarwinNotificationDetails(); // var platformChannelSpecifics = NotificationDetails( // androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics); // await flutterLocalNotificationsPlugin.showWeeklyAtDayAndTime( diff --git a/lib/uitl/push-notification-handler.dart b/lib/uitl/push-notification-handler.dart index 3e765c17..7ae1ba43 100644 --- a/lib/uitl/push-notification-handler.dart +++ b/lib/uitl/push-notification-handler.dart @@ -303,10 +303,6 @@ class PushNotificationHandler { onToken(token); }); - FirebaseMessaging.instance.getAPNSToken().then((value) { - print("Push APNS getToken: " + value); - }); - FirebaseMessaging.onBackgroundMessage(backgroundMessageHandler); } @@ -349,10 +345,10 @@ class PushNotificationHandler { Future isAndroidPermissionGranted() async { if (Platform.isAndroid) { - final bool granted = await flutterLocalNotificationsPlugin.resolvePlatformSpecificImplementation()?.areNotificationsEnabled() ?? false; - if (!granted) { - await requestPermissions(); - } + // final bool granted = await flutterLocalNotificationsPlugin.resolvePlatfxormSpecificImplementation()?.areNotificationsEnabled() ?? false; + // if (!granted) { + // await requestPermissions(); + // } } }