diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 7c8831eb..6bd1019b 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1847,5 +1847,7 @@ const Map localizedValues = { "lakumUnhold": { "en": "The account has already been activated", "ar": "لقد تم تفعيل الحساب من قبل" }, "lakumDiscontinue": { "en": "The account is closed", "ar": "الحساب مغلق" }, "lakumSuccess": { "en": "The account has been activated successfully", "ar": "تم تفعيل الحساب بنجاح" }, - "deleteAccount": { "en": "Delete my account", "ar": "الحساب احذف" }, + "deleteAccount": { "en": "Deactivate my account", "ar": "الحساب احذف" }, + "deactivateAccount": { "en": "Are you sure you want to deactivate your account?", "ar": "هل أنت متأكد أنك تريد إلغاء تنشيط حسابك؟" }, + "accountDeactivated": { "en": "Your account has been deactivated successfully", "ar": "تم إلغاء تنشيط حسابك بنجاح" }, }; diff --git a/lib/pages/MyAppointments/AppointmentDetails.dart b/lib/pages/MyAppointments/AppointmentDetails.dart index 232bffc1..25bb4b6f 100644 --- a/lib/pages/MyAppointments/AppointmentDetails.dart +++ b/lib/pages/MyAppointments/AppointmentDetails.dart @@ -105,7 +105,7 @@ class _AppointmentDetailsState extends State with SingleTick "", widget.appo.projectName, DateUtil.convertStringToDate(widget.appo.appointmentDate), - widget.appo.startTime.substring(0, 5), + widget.appo.isLiveCareAppointment ? DateUtil.convertStringToDate(widget.appo.appointmentDate).toString().split(" ")[1].substring(0, 5) : widget.appo.startTime.substring(0, 5), null, widget.appo.doctorRate, widget.appo.actualDoctorRate, diff --git a/lib/pages/MyAppointments/MyAppointments.dart b/lib/pages/MyAppointments/MyAppointments.dart index e0eb15a0..cccff881 100644 --- a/lib/pages/MyAppointments/MyAppointments.dart +++ b/lib/pages/MyAppointments/MyAppointments.dart @@ -378,8 +378,8 @@ class _MyAppointmentsState extends State with SingleTickerProvid date: DateUtil.convertStringToDate(_appointmentResult.appointmentDate), isSortByClinic: _isSortByClinic, rating: _appointmentResult.actualDoctorRate + 0.0, - // appointmentTime: _appointmentResult.isLiveCareAppointment ? DateUtil.convertStringToDate(_appointmentResult.appointmentDate).toString().split(" ")[1].substring(0, 5) : _appointmentResult.startTime.substring(0, 5), - appointmentTime: _appointmentResult.startTime.substring(0, 5), + appointmentTime: _appointmentResult.isLiveCareAppointment ? DateUtil.convertStringToDate(_appointmentResult.appointmentDate).toString().split(" ")[1].substring(0, 5) : _appointmentResult.startTime.substring(0, 5), + // appointmentTime: _appointmentResult.startTime.substring(0, 5), remainingTimeInMinutes: (_appointmentResult.patientStatusType == AppointmentType.BOOKED || _appointmentResult.patientStatusType == AppointmentType.CONFIRMED) ? _appointmentResult.remaniningHoursTocanPay : null diff --git a/lib/pages/livecare/widgets/clinic_list.dart b/lib/pages/livecare/widgets/clinic_list.dart index ecd7b8b9..7f74a9fd 100644 --- a/lib/pages/livecare/widgets/clinic_list.dart +++ b/lib/pages/livecare/widgets/clinic_list.dart @@ -237,41 +237,41 @@ class _clinic_listState extends State { dialog.showAlertDialog(context); } - showLiveCareInfoDialog(GetERAppointmentFeesList getERAppointmentFeesList) async { - if (await this.sharedPref.getObject(USER_PROFILE) != null) { - var data = AuthenticatedUser.fromJson(await this.sharedPref.getObject(USER_PROFILE)); - setState(() { - authUser = data; - }); - } - - showGeneralDialog( - barrierColor: Colors.black.withOpacity(0.5), - transitionBuilder: (context, a1, a2, widget) { - final curvedValue = Curves.easeInOutBack.transform(a1.value) - 1.0; - return Transform( - transform: Matrix4.translationValues(0.0, curvedValue * 200, 0.0), - child: Opacity( - opacity: a1.value, - child: LiveCareInfoDialog(), - ), - ); - }, - transitionDuration: Duration(milliseconds: 500), - barrierDismissible: true, - barrierLabel: '', - context: context, - pageBuilder: (context, animation1, animation2) {}) - .then((value) { - if (value) { - if (getERAppointmentFeesList.total == "0" || getERAppointmentFeesList.total == "0.0") { - addNewCallForPatientER(authUser.patientID.toString() + "" + DateTime.now().millisecondsSinceEpoch.toString()); - } else { - navigateToPaymentMethod(getERAppointmentFeesList, context); - } - } - }); - } + // showLiveCareInfoDialog(GetERAppointmentFeesList getERAppointmentFeesList) async { + // if (await this.sharedPref.getObject(USER_PROFILE) != null) { + // var data = AuthenticatedUser.fromJson(await this.sharedPref.getObject(USER_PROFILE)); + // setState(() { + // authUser = data; + // }); + // } + // + // showGeneralDialog( + // barrierColor: Colors.black.withOpacity(0.5), + // transitionBuilder: (context, a1, a2, widget) { + // final curvedValue = Curves.easeInOutBack.transform(a1.value) - 1.0; + // return Transform( + // transform: Matrix4.translationValues(0.0, curvedValue * 200, 0.0), + // child: Opacity( + // opacity: a1.value, + // child: LiveCareInfoDialog(), + // ), + // ); + // }, + // transitionDuration: Duration(milliseconds: 500), + // barrierDismissible: true, + // barrierLabel: '', + // context: context, + // pageBuilder: (context, animation1, animation2) {}) + // .then((value) { + // if (value) { + // if (getERAppointmentFeesList.total == "0" || getERAppointmentFeesList.total == "0.0") { + // addNewCallForPatientER(authUser.patientID.toString() + "" + DateTime.now().millisecondsSinceEpoch.toString()); + // } else { + // navigateToPaymentMethod(getERAppointmentFeesList, context); + // } + // } + // }); + // } Future navigateToPaymentMethod(GetERAppointmentFeesList getERAppointmentFeesList, context) async { AppoitmentAllHistoryResultList appo = new AppoitmentAllHistoryResultList(); diff --git a/lib/pages/settings/profile_setting.dart b/lib/pages/settings/profile_setting.dart index 7cfc3acb..51c43443 100644 --- a/lib/pages/settings/profile_setting.dart +++ b/lib/pages/settings/profile_setting.dart @@ -8,6 +8,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/buttons/defaultButton.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -215,7 +216,9 @@ class _ProfileSettings extends State with TickerProviderStateMi inputWidget(TranslationBase.of(context).emergencyContact, "", emergencyContact), mHeight(10), InkWell( - onTap: () {}, + onTap: () { + deactivateAccount(); + }, child: Text( TranslationBase.of(context).deleteAccount, style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, letterSpacing: -0.64, color: Color(0xffD02127), decoration: TextDecoration.underline), @@ -252,10 +255,6 @@ class _ProfileSettings extends State with TickerProviderStateMi ); } - deactivateAccount() { - - } - Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {String prefix, bool isEnable = true, bool hasSelection = false}) { return Container( padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), @@ -338,12 +337,33 @@ class _ProfileSettings extends State with TickerProviderStateMi ); } + deactivateAccount() { + ConfirmDialog dialog = new ConfirmDialog( + context: context, + confirmMessage: TranslationBase.of(context).deactivateAccount, + okText: TranslationBase.of(context).yes, + cancelText: TranslationBase.of(context).no, + okFunction: () { + Navigator.of(context).pop(); + callDeactivateAccountAPI(); + }, + cancelFunction: () => {}); + dialog.showAlertDialog(context); + } + + callDeactivateAccountAPI() { + GifLoaderDialogUtils.showMyDialog(context); + Map request = {}; + request["IsActive"] = false; + authService.deactivateAccount(request).then((result) { + AppToast.showSuccessToast(message: TranslationBase.of(context).accountDeactivated); + GifLoaderDialogUtils.hideDialog(context); + + }); + } + getSettings() { - // GifLoaderDialogUtils.showMyDialog(AppGlobal.context); - authService.getSettings().then((result) => { - // GifLoaderDialogUtils.hideDialog(AppGlobal.context), - setValue(result["PateintInfoForUpdateList"][0]) - }); + authService.getSettings().then((result) => {setValue(result["PateintInfoForUpdateList"][0])}); } setValue(value) { diff --git a/lib/services/authentication/auth_provider.dart b/lib/services/authentication/auth_provider.dart index dc3a5813..ce49243c 100644 --- a/lib/services/authentication/auth_provider.dart +++ b/lib/services/authentication/auth_provider.dart @@ -2,6 +2,8 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/service/client/base_app_client.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_request.dart'; import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_request_register.dart'; @@ -14,9 +16,12 @@ import 'package:diplomaticquarterapp/models/Authentication/register_user_requet. import 'package:diplomaticquarterapp/models/Authentication/registered_authenticated_user_req.dart'; import 'package:diplomaticquarterapp/models/Authentication/select_device_imei_res.dart'; import 'package:diplomaticquarterapp/models/Request.dart'; +import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:flutter/cupertino.dart'; import 'package:intl/intl.dart'; +import 'package:provider/provider.dart'; + import '../../locator.dart'; // SharedPreferences sharedPref = new SharedPreferences(); @@ -47,6 +52,8 @@ const DASHBOARD = 'Services/Patients.svc/REST/PatientDashboard'; const PROFILE_SETTING = 'Services/Patients.svc/REST/GetPateintInfoForUpdate'; const SAVE_SETTING = 'Services/Patients.svc/REST/UpdatePateintInfo'; +const DEACTIVATE_ACCOUNT = 'Services/Patients.svc/REST/PatientAppleActivation_InsertUpdate'; + class AuthProvider with ChangeNotifier { bool isLogin = false; bool isLoading = true; @@ -468,12 +475,6 @@ class AuthProvider with ChangeNotifier { Future getDashboard() async { Map request = {}; - // request['VersionID'] = VERSION_ID; - // request['Channel'] = CHANNEL; - // request['IPAdress'] = IP_ADDRESS; - // request['generalid'] = GENERAL_ID; - // request['LanguageID'] = LANGUAGE_ID; - // request['DeviceTypeID'] = DeviceTypeID; dynamic localRes; try { @@ -495,16 +496,14 @@ class AuthProvider with ChangeNotifier { dynamic localRes; try { await new BaseAppClient().post(PROFILE_SETTING, onSuccess: (dynamic response, int statusCode) { - localRes = response; //CheckActivationCode.fromJson(); + localRes = response; }, onFailure: (String error, int statusCode) { localRes = error; return Future.value(error); - // throw error; }, body: {}); return Future.value(localRes); } catch (error) { throw error; - //return Future.value(error); } } @@ -512,16 +511,41 @@ class AuthProvider with ChangeNotifier { dynamic localRes; try { await new BaseAppClient().post(SAVE_SETTING, onSuccess: (dynamic response, int statusCode) { - localRes = response; //CheckActivationCode.fromJson(); + localRes = response; }, onFailure: (String error, int statusCode) { localRes = error; return Future.value(error); - // throw error; }, body: request); return Future.value(localRes); } catch (error) { throw error; - //return Future.value(error); } } + + Future deactivateAccount(request) async { + dynamic localRes; + try { + await new BaseAppClient().post(DEACTIVATE_ACCOUNT, onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + localRes = error; + return Future.value(error); + }, body: request); + logout(); + return Future.value(localRes); + } catch (error) { + throw error; + } + } + + logout() async { + await sharedPref.remove(LOGIN_TOKEN_ID); + await sharedPref.remove(PHARMACY_CUSTOMER_ID); + await authenticatedUserObject.getUser(); + Provider.of(AppGlobal.context, listen: false).isLogin = false; + var model = Provider.of(AppGlobal.context, listen: false); + model.setState(0, false, null); + Navigator.of(AppGlobal.context).pushReplacementNamed(HOME); + } + } diff --git a/lib/uitl/gif_loader_dialog_utils.dart b/lib/uitl/gif_loader_dialog_utils.dart index eae84e38..458c59b8 100644 --- a/lib/uitl/gif_loader_dialog_utils.dart +++ b/lib/uitl/gif_loader_dialog_utils.dart @@ -4,7 +4,7 @@ import '../widgets/Loader/gif_loader_container.dart'; class GifLoaderDialogUtils { static showMyDialog(BuildContext context) { - showDialog(context: context, builder: (cxt) => GifLoaderContainer()); + showDialog(context: context, barrierDismissible: false, builder: (cxt) => GifLoaderContainer()); } static hideDialog(BuildContext context) { diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index e7faf572..1b9475ed 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2857,6 +2857,8 @@ class TranslationBase { String get lakumDiscontinue => localizedValues["lakumDiscontinue"][locale.languageCode]; String get lakumSuccess => localizedValues["lakumSuccess"][locale.languageCode]; String get deleteAccount => localizedValues["deleteAccount"][locale.languageCode]; + String get deactivateAccount => localizedValues["deactivateAccount"][locale.languageCode]; + String get accountDeactivated => localizedValues["accountDeactivated"][locale.languageCode]; } diff --git a/lib/widgets/Loader/gif_loader_container.dart b/lib/widgets/Loader/gif_loader_container.dart index 75083d1a..4c2c40cf 100644 --- a/lib/widgets/Loader/gif_loader_container.dart +++ b/lib/widgets/Loader/gif_loader_container.dart @@ -29,14 +29,17 @@ class _GifLoaderContainerState extends State with TickerProv @override Widget build(BuildContext context) { - return Center( - //progress-loading.gif - child: Container( - // margin: EdgeInsets.only(bottom: 40), - child: GifImage( - controller: controller1, - image: AssetImage("assets/images/progress-loading-red.gif"), //NetworkImage("http://img.mp.itc.cn/upload/20161107/5cad975eee9e4b45ae9d3c1238ccf91e.jpg"), - ), - )); + return WillPopScope( + onWillPop: () async => false, + child: Center( + //progress-loading.gif + child: Container( + // margin: EdgeInsets.only(bottom: 40), + child: GifImage( + controller: controller1, + image: AssetImage("assets/images/progress-loading-red.gif"), //NetworkImage("http://img.mp.itc.cn/upload/20161107/5cad975eee9e4b45ae9d3c1238ccf91e.jpg"), + ), + )), + ); } }