From 67cc5e20337fdd2f4aa65fc1052752b404d7c0e9 Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Sun, 22 Nov 2020 14:18:01 +0200 Subject: [PATCH 01/20] fix Prescriptions --- lib/config/config.dart | 4 ++-- .../prescriptions/request_prescription_report.dart | 2 +- lib/core/service/medical/prescriptions_service.dart | 13 +++++++------ .../medical/prescriptions_view_model.dart | 4 ++-- .../prescriptions/prescription_items_page.dart | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index e6cc3f1d..2592d1b2 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -244,8 +244,8 @@ const LANGUAGE = 2; const PATIENT_OUT_SA = 0; const SESSION_ID = 'TMRhVmkGhOsvamErw'; const IS_DENTAL_ALLOWED_BACKEND = false; -const PATIENT_TYPE = 2; -const PATIENT_TYPE_ID = 2; +const PATIENT_TYPE = 1; +const PATIENT_TYPE_ID = 1; var DEVICE_TOKEN = ""; var DeviceTypeID = Platform.isIOS ? 1 : 2; const LANGUAGE_ID = 2; diff --git a/lib/core/model/prescriptions/request_prescription_report.dart b/lib/core/model/prescriptions/request_prescription_report.dart index c8323740..df901a99 100644 --- a/lib/core/model/prescriptions/request_prescription_report.dart +++ b/lib/core/model/prescriptions/request_prescription_report.dart @@ -82,7 +82,7 @@ class RequestPrescriptionReport { data['EpisodeID'] = this.episodeID; data['ClinicID'] = this.clinicID; data['ProjectID'] = this.projectID; - data['DischargeNo'] = this.dischargeNo; + // data['DischargeNo'] = this.dischargeNo; return data; } } diff --git a/lib/core/service/medical/prescriptions_service.dart b/lib/core/service/medical/prescriptions_service.dart index b920499c..15f840d9 100644 --- a/lib/core/service/medical/prescriptions_service.dart +++ b/lib/core/service/medical/prescriptions_service.dart @@ -57,13 +57,14 @@ class PrescriptionsService extends BaseService { List prescriptionReportList = List(); Future getPrescriptionReport( - {int dischargeNo, int projectId, int clinicID, String setupID,int episodeID}) async { + {Prescriptions prescriptions}) async { hasError = false; - _requestPrescriptionReport.dischargeNo = dischargeNo; - _requestPrescriptionReport.projectID = projectId; - _requestPrescriptionReport.clinicID = clinicID; - _requestPrescriptionReport.setupID = setupID; - _requestPrescriptionReport.episodeID = episodeID; + _requestPrescriptionReport.dischargeNo = prescriptions.dischargeNo; + _requestPrescriptionReport.projectID = prescriptions.projectID; + _requestPrescriptionReport.clinicID = prescriptions.clinicID; + _requestPrescriptionReport.setupID = prescriptions.setupID; + _requestPrescriptionReport.episodeID = prescriptions.episodeID; + _requestPrescriptionReport.appointmentNo = prescriptions.appointmentNo; await baseAppClient.post(GET_PRESCRIPTION_REPORT, onSuccess: (dynamic response, int statusCode) { diff --git a/lib/core/viewModels/medical/prescriptions_view_model.dart b/lib/core/viewModels/medical/prescriptions_view_model.dart index 054dc4ef..1cd934e2 100644 --- a/lib/core/viewModels/medical/prescriptions_view_model.dart +++ b/lib/core/viewModels/medical/prescriptions_view_model.dart @@ -103,9 +103,9 @@ class PrescriptionsViewModel extends BaseViewModel { notifyListeners(); } - getPrescriptionReport({int dischargeNo,int projectId,int clinicID,String setupID,int episodeID}) async { + getPrescriptionReport({Prescriptions prescriptions}) async { setState(ViewState.Busy); - await _prescriptionsService.getPrescriptionReport(dischargeNo: dischargeNo,projectId: projectId,clinicID: clinicID,setupID: setupID,episodeID: episodeID); + await _prescriptionsService.getPrescriptionReport(prescriptions: prescriptions); if (_prescriptionsService.hasError) { error = _prescriptionsService.error; setState(ViewState.ErrorLocal); diff --git a/lib/pages/medical/prescriptions/prescription_items_page.dart b/lib/pages/medical/prescriptions/prescription_items_page.dart index d2fdae0b..ba0effc1 100644 --- a/lib/pages/medical/prescriptions/prescription_items_page.dart +++ b/lib/pages/medical/prescriptions/prescription_items_page.dart @@ -20,7 +20,7 @@ class PrescriptionItemsPage extends StatelessWidget { Widget build(BuildContext context) { return BaseView( onModelReady: (model) => - model.getPrescriptionReport(dischargeNo: prescriptions.dischargeNo,setupID:prescriptions.setupID,clinicID: prescriptions.clinicID,projectId: prescriptions.projectID,episodeID: prescriptions.episodeID), + model.getPrescriptionReport(prescriptions: prescriptions), builder: (_, model, widget) => AppScaffold( isShowAppBar: true, appBarTitle: TranslationBase.of(context).prescriptions, From dcbc0de69f9f2517eaed221779418f664a52cf90 Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Mon, 23 Nov 2020 13:27:08 +0200 Subject: [PATCH 02/20] fix prescription --- .../medical/prescriptions_service.dart | 17 +- .../prescription_details_page.dart | 2 +- .../prescription_items_page.dart | 152 ++++++++++++------ 3 files changed, 121 insertions(+), 50 deletions(-) diff --git a/lib/core/service/medical/prescriptions_service.dart b/lib/core/service/medical/prescriptions_service.dart index 15f840d9..d6ad3732 100644 --- a/lib/core/service/medical/prescriptions_service.dart +++ b/lib/core/service/medical/prescriptions_service.dart @@ -66,12 +66,21 @@ class PrescriptionsService extends BaseService { _requestPrescriptionReport.episodeID = prescriptions.episodeID; _requestPrescriptionReport.appointmentNo = prescriptions.appointmentNo; - await baseAppClient.post(GET_PRESCRIPTION_REPORT, + await baseAppClient.post(prescriptions.isInOutPatient? GET_PRESCRIPTION_REPORT_ENH : GET_PRESCRIPTION_REPORT, onSuccess: (dynamic response, int statusCode) { prescriptionReportList.clear(); - response['INP_GetPrescriptionReport_List'].forEach((prescriptions) { - prescriptionReportList.add(PrescriptionReport.fromJson(prescriptions)); - }); + prescriptionReportEnhList.clear(); + if(prescriptions.isInOutPatient){ + response['ListPRM'].forEach((prescriptions) { + prescriptionReportEnhList.add(PrescriptionReportEnh.fromJson(prescriptions)); + }); + }else{ + response['INP_GetPrescriptionReport_List'].forEach((prescriptions) { + prescriptionReportList.add(PrescriptionReport.fromJson(prescriptions)); + }); + } + + }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; diff --git a/lib/pages/medical/prescriptions/prescription_details_page.dart b/lib/pages/medical/prescriptions/prescription_details_page.dart index 4416b9fa..024de17c 100644 --- a/lib/pages/medical/prescriptions/prescription_details_page.dart +++ b/lib/pages/medical/prescriptions/prescription_details_page.dart @@ -136,7 +136,7 @@ class PrescriptionDetailsPage extends StatelessWidget { height: 50, width: double.infinity, child: Center( - child: Text(prescriptionReport.frequencyN))), + child: Text(prescriptionReport.frequencyN?? ''))), Container( color: Colors.white, height: 50, diff --git a/lib/pages/medical/prescriptions/prescription_items_page.dart b/lib/pages/medical/prescriptions/prescription_items_page.dart index ba0effc1..696ea2db 100644 --- a/lib/pages/medical/prescriptions/prescription_items_page.dart +++ b/lib/pages/medical/prescriptions/prescription_items_page.dart @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/prescriptions/Prescriptions.dart'; +import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_report.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/prescriptions_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescription_details_page.dart'; @@ -27,56 +28,117 @@ class PrescriptionItemsPage extends StatelessWidget { baseViewModel: model, body: Container( height: MediaQuery.of(context).size.height * 0.8, - child: ListView.builder( - itemBuilder: (context, index) => InkWell( - onTap: () => Navigator.push( - context, - FadePage( - page: PrescriptionDetailsPage( - prescriptionReport: model.prescriptionReportList[index], + child: Column( + children: [ + + if(!prescriptions.isInOutPatient) + ...List.generate(model.prescriptionReportList.length, (index) => InkWell( + onTap: () => Navigator.push( + context, + FadePage( + page: PrescriptionDetailsPage( + prescriptionReport: model.prescriptionReportList[index], + ), + ), ), - ), - ), - child: Container( - width: double.infinity, - margin: EdgeInsets.only(top: 10, left: 10, right: 10), - padding: EdgeInsets.all(8.0), - decoration: BoxDecoration( + child: Container( + width: double.infinity, + margin: EdgeInsets.only(top: 10, left: 10, right: 10), + padding: EdgeInsets.all(8.0), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(10.0), + ), + border: Border.all(color: Colors.grey[200], width: 0.5), + ), + child: Row( + children: [ + ClipRRect( + borderRadius: BorderRadius.all(Radius.circular(5)), + child: Image.network( + model.prescriptionReportList[index].imageSRCUrl, + fit: BoxFit.cover, + width: 60, + height: 70, + ), + ), + Expanded( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Texts(model.prescriptionReportList[index].itemDescription.isNotEmpty? + model.prescriptionReportList[index].itemDescription :model + .prescriptionReportList[index].itemDescriptionN)), + )), + Icon( + Icons.arrow_forward_ios, + size: 18, + color: Colors.grey[500], + ) + ], + ), + ), + )) + + else + ...List.generate( + model.prescriptionReportEnhList.length, + (index) => InkWell( + onTap: (){ + PrescriptionReport prescriptionReport = PrescriptionReport( + imageSRCUrl: model.prescriptionReportEnhList[index].imageSRCUrl, + itemDescription: model.prescriptionReportEnhList[index].itemDescription, + itemDescriptionN: model.prescriptionReportEnhList[index].itemDescription, + routeN: model.prescriptionReportEnhList[index].route, + frequency: model.prescriptionReportEnhList[index].frequency, + frequencyN: model.prescriptionReportEnhList[index].frequency, + doseDailyQuantity: model.prescriptionReportEnhList[index].doseDailyQuantity, + days: model.prescriptionReportEnhList[index].days, + itemID: model.prescriptionReportEnhList[index].itemID, + remarks: model.prescriptionReportEnhList[index].remarks + ); + Navigator.push( + context, + FadePage( + page: PrescriptionDetailsPage( + prescriptionReport:prescriptionReport, + ), + ), + ); + }, + child: Container( + margin: EdgeInsets.all(8.0), color: Colors.white, - borderRadius: BorderRadius.all( - Radius.circular(10.0), + child: Row( + children: [ + ClipRRect( + borderRadius: BorderRadius.all(Radius.circular(5)), + child: Image.network( + model.prescriptionReportEnhList[index].imageSRCUrl, + fit: BoxFit.cover, + width: 60, + height: 70, + ), + ), + Expanded( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts(model.prescriptionReportEnhList[index] + .itemDescription), + ], + ), + ), + ), + ], ), - border: Border.all(color: Colors.grey[200], width: 0.5), ), - child: Row( - children: [ - ClipRRect( - borderRadius: BorderRadius.all(Radius.circular(5)), - child: Image.network( - model.prescriptionReportList[index].imageSRCUrl, - fit: BoxFit.cover, - width: 60, - height: 70, - ), ), - Expanded( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Center( - child: Texts(model.prescriptionReportList[index].itemDescription.isNotEmpty? - model.prescriptionReportList[index].itemDescription :model - .prescriptionReportList[index].itemDescriptionN)), - )), - Icon( - Icons.arrow_forward_ios, - size: 18, - color: Colors.grey[500], - ) - ], - ), - ), - ), - itemCount: model.prescriptionReportList.length, + ) + ], ), ), bottomSheet: Container( From 91cada69015e6d15a3c328f1c5191752c9ba0204 Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Mon, 23 Nov 2020 13:54:56 +0200 Subject: [PATCH 03/20] fix Advance Payment --- lib/core/viewModels/medical/my_balance_view_model.dart | 2 +- .../medical/balance/dialogs/SelectPatientFamilyDialog.dart | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/core/viewModels/medical/my_balance_view_model.dart b/lib/core/viewModels/medical/my_balance_view_model.dart index af4e126e..8225d97e 100644 --- a/lib/core/viewModels/medical/my_balance_view_model.dart +++ b/lib/core/viewModels/medical/my_balance_view_model.dart @@ -154,7 +154,7 @@ class MyBalanceViewModel extends BaseViewModel { Future getFamilyFiles() async { setState(ViewState.Busy); - await _myBalanceService.getFamilyFiles(); + await _myBalanceService.getSharedRecordByStatus(); if (_myBalanceService.hasError) { error = _myBalanceService.error; setState(ViewState.ErrorLocal); diff --git a/lib/pages/medical/balance/dialogs/SelectPatientFamilyDialog.dart b/lib/pages/medical/balance/dialogs/SelectPatientFamilyDialog.dart index bb9afd6c..7d69f084 100644 --- a/lib/pages/medical/balance/dialogs/SelectPatientFamilyDialog.dart +++ b/lib/pages/medical/balance/dialogs/SelectPatientFamilyDialog.dart @@ -35,9 +35,11 @@ class _SelectPatientFamilyDialogState extends State { (index) => Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ + if(widget.getAllSharedRecordsByStatusList[index].status==3) SizedBox( height: 2, ), + if(widget.getAllSharedRecordsByStatusList[index].status==3) Row( children: [ Expanded( @@ -65,6 +67,8 @@ class _SelectPatientFamilyDialogState extends State { ) ], ), + if(widget.getAllSharedRecordsByStatusList[index].status==3) + SizedBox( height: 5.0, ), From 8d499704dcaf013115d79536ecb6d5cfc355ac2a Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Tue, 24 Nov 2020 10:03:24 +0300 Subject: [PATCH 04/20] family file changes --- lib/core/service/client/base_app_client.dart | 6 +- lib/main.dart | 7 +- .../DrawerPages/family/add-family-member.dart | 30 +- .../DrawerPages/family/add-family_type.dart | 5 +- lib/pages/DrawerPages/family/my-family.dart | 281 ++++++++++++------ lib/pages/landing/landing_page.dart | 58 +++- lib/pages/login/confirm-login.dart | 3 +- lib/pages/login/login.dart | 1 + lib/pages/login/register-info.dart | 36 +-- lib/pages/settings/general_setting.dart | 61 +--- .../family_files/family_files_provider.dart | 41 +++ lib/theme/theme_value.dart | 2 +- lib/widgets/drawer/app_drawer_widget.dart | 6 +- 13 files changed, 347 insertions(+), 190 deletions(-) diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 115485a6..11095fd3 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -35,7 +35,7 @@ class BaseAppClient { //Map profile = await sharedPref.getObj(DOCTOR_PROFILE); String token = await sharedPref.getString(TOKEN); var languageID = - await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); + await sharedPref.getString(APP_LANGUAGE); var user = await sharedPref.getObject(USER_PROFILE); if (body.containsKey('SetupID')) { body['SetupID'] = body.containsKey('SetupID') @@ -87,8 +87,8 @@ class BaseAppClient { body['PatientTypeID'] = body.containsKey('PatientTypeID') ? body['PatientTypeID'] != null ? body['PatientTypeID'] - : user['PatientTypeID'] != null - ? user['PatientTypeID'] + :user['PatientType'] != null + ? user['PatientType'] : PATIENT_TYPE_ID : PATIENT_TYPE_ID; if (user != null) { diff --git a/lib/main.dart b/lib/main.dart index f44411a0..b93aa83e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -23,6 +23,7 @@ void main() async { class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { + final themeNotifier = Provider.of(context); return LayoutBuilder( builder: (context, constraints) { @@ -48,6 +49,7 @@ class MyApp extends StatelessWidget { ], child: Consumer( builder: (context, projectProvider, child) => MaterialApp( + showSemanticsDebugger: false, title: 'Diplomatic Quarter App', locale: projectProvider.appLocal, @@ -61,8 +63,9 @@ class MyApp extends StatelessWidget { const Locale('ar', ''), // Arabic const Locale('en', ''), // English ], - theme: ThemeData( - fontFamily: projectProvider.isArabic? 'Cairo' : 'WorkSans', + //theme: themeNotifier.getTheme(), + theme:ThemeData( + fontFamily:projectProvider.isArabic ? 'Cairo' : 'WorkSans', primarySwatch: Colors.blue, visualDensity: VisualDensity.adaptivePlatformDensity, brightness: Brightness.light, diff --git a/lib/pages/DrawerPages/family/add-family-member.dart b/lib/pages/DrawerPages/family/add-family-member.dart index 35b19ccd..084b43e6 100644 --- a/lib/pages/DrawerPages/family/add-family-member.dart +++ b/lib/pages/DrawerPages/family/add-family-member.dart @@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/services/family_files/family_files_provider.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.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/widgets/buttons/defaultButton.dart'; @@ -144,7 +145,7 @@ class _AddMember extends State { request.zipCode = countryCode; request.isRegister = false; request.patientStatus = 2; - loading(true); + GifLoaderDialogUtils.showMyDialog(context); familyFileProvider .addFamilyFile(request) .then((value) => manageFamily(value)) @@ -154,18 +155,21 @@ class _AddMember extends State { } manageFamily(addMemberResult) { - loading(false); - ConfirmDialog dialog = new ConfirmDialog( - context: context, - confirmMessage: addMemberResult['ShareFamilyFileObj']['Message'], - okText: TranslationBase.of(context).confirm, - cancelText: TranslationBase.of(context).cancel_nocaps, - okFunction: () => { - insertFamilyData(addMemberResult), - ConfirmDialog.closeAlertDialog(context) - }, - cancelFunction: () => {}); - dialog.showAlertDialog(context); + GifLoaderDialogUtils.hideDialog(context); + if(addMemberResult is String ==false){ + ConfirmDialog dialog = new ConfirmDialog( + context: context, + confirmMessage: addMemberResult['ShareFamilyFileObj']['Message'], + okText: TranslationBase.of(context).confirm, + cancelText: TranslationBase.of(context).cancel_nocaps, + okFunction: () => { + insertFamilyData(addMemberResult), + ConfirmDialog.closeAlertDialog(context) + }, + cancelFunction: () => {}); + dialog.showAlertDialog(context); + } + } insertFamilyData(addMemberResult) { diff --git a/lib/pages/DrawerPages/family/add-family_type.dart b/lib/pages/DrawerPages/family/add-family_type.dart index 96e055b3..2c85b043 100644 --- a/lib/pages/DrawerPages/family/add-family_type.dart +++ b/lib/pages/DrawerPages/family/add-family_type.dart @@ -75,7 +75,7 @@ class AddFamilyMemberType extends StatelessWidget { ), AppText( TranslationBase.of(context) - .nationalID, + .idNo, fontSize: SizeConfig .textMultiplier * 2, @@ -113,9 +113,10 @@ class AddFamilyMemberType extends StatelessWidget { AppText( TranslationBase.of(context) .fileNo, + textAlign: TextAlign.center, fontSize: SizeConfig .textMultiplier * - 2, + 1.8, ) ], ), diff --git a/lib/pages/DrawerPages/family/my-family.dart b/lib/pages/DrawerPages/family/my-family.dart index d3de1b62..0e6d86bf 100644 --- a/lib/pages/DrawerPages/family/my-family.dart +++ b/lib/pages/DrawerPages/family/my-family.dart @@ -1,7 +1,10 @@ +import 'dart:ui'; + import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_response.dart'; import 'package:diplomaticquarterapp/models/FamilyFiles/GetAllSharedRecordByStatusResponse.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/widgets/BranchView.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/services/family_files/family_files_provider.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; @@ -31,7 +34,7 @@ class _MyFamily extends State with TickerProviderStateMixin { AppSharedPreferences sharedPref = new AppSharedPreferences(); var userID; TabController _tabController; - + int _tabIndex = 0; @override void initState() { _tabController = new TabController(length: 2, vsync: this, initialIndex: 0); @@ -41,41 +44,102 @@ class _MyFamily extends State with TickerProviderStateMixin { bool expandFlag = false; Widget build(BuildContext context) { - // return Scaffold( - // appBar: AppBar( - // bottom: TabBar( - // indicatorColor: Colors.red, - // tabs: [ - // Padding( - // padding: EdgeInsets.all(6), - // child: AppText( - // TranslationBase.of(context).family, - // color: Colors.white, - // )), - // Padding( - // padding: EdgeInsets.all(6), - // child: AppText( - // TranslationBase.of(context).request, - // color: Colors.white, - // )), - // ], - // controller: _tabController, - // ), - // - // ), - // body: TabBarView( - // // physics: NeverScrollableScrollPhysics(), - // children: [myFamilyDetails(context), myFamilyRequest(context)], - // controller: _tabController), - // ); - // //bottomNavigationBar: BottomBarSearch()); + return AppScaffold( + appBarTitle: TranslationBase.of(context).myFamilyFiles, + isShowAppBar: widget.isAppbarVisible, + body: Scaffold( + extendBodyBehindAppBar: true, + appBar: PreferredSize( + preferredSize: Size.fromHeight(65.0), + child: Stack( + children: [ + Positioned( + bottom: 1, + left: 0, + right: 0, + child: BackdropFilter( + filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10), + child: Container( + color: Theme.of(context) + .scaffoldBackgroundColor + .withOpacity(0.8), + height: 70.0, + ), + ), + ), + Center( + child: Container( + height: 60.0, + margin: EdgeInsets.only(top: 10.0), + width: MediaQuery.of(context).size.width * 0.92, // 0.9, + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: Theme.of(context).dividerColor, + width: 0.9), //width: 0.7 + ), + color: Colors.white), + child: Center( + child: TabBar( + isScrollable: true, + controller: _tabController, + indicatorWeight: 5.0, + //indicatorSize: TabBarIndicatorSize.label, + indicatorSize: TabBarIndicatorSize.tab, + + indicatorColor: Colors.red[800], + labelColor: Theme.of(context).primaryColor, + labelPadding: + EdgeInsets.only(top: 4.0, left: 35.0, right: 35.0), + unselectedLabelColor: Colors.grey[800], + tabs: [ + + Container( + width: MediaQuery.of(context).size.width * 0.30, + child: Center( + child: AppText(TranslationBase.of(context).family), + ), + ), + Container( + width: MediaQuery.of(context).size.width * 0.30, + child: Center( + child: AppText(TranslationBase.of(context).request), + ), + ), + ], + ), + ), + ), + ), + ], + ), + ), + body: Column( + children: [ + Expanded( + child: TabBarView( + physics: BouncingScrollPhysics(), + controller: _tabController, + children: [ + myFamilyDetails(context), + myFamilyRequest(context) + ], + ), + ) + ], + ), + ), + ); + + + return AppScaffold( appBarTitle: TranslationBase.of(context).myFamilyFiles, isShowAppBar: widget.isAppbarVisible, body: SingleChildScrollView( child: Container( - height: SizeConfig.screenHeight, + height: SizeConfig.screenHeight *.9, width: SizeConfig.realScreenWidth, padding: EdgeInsets.all(20), child: Stack( @@ -84,12 +148,11 @@ class _MyFamily extends State with TickerProviderStateMixin { controller: _tabController, indicatorColor: Colors.red, tabs: [ - Padding( - padding: EdgeInsets.all(6), - child: Text(TranslationBase.of(context).family)), - Padding( - padding: EdgeInsets.all(6), - child: Text(TranslationBase.of(context).request)), + Tab( // padding: EdgeInsets.all(6), + child:AppText(TranslationBase.of(context).family)), + Tab( + // padding: EdgeInsets.all(6), + child:AppText(TranslationBase.of(context).request)), ], ), TabBarView( @@ -228,7 +291,7 @@ class _MyFamily extends State with TickerProviderStateMixin { SingleChildScrollView( child: Container( height: MediaQuery.of(context).size.height, - margin: EdgeInsets.only(top:50), + margin: EdgeInsets.only(top:65), child: Column( children: [ RoundedContainer( @@ -255,34 +318,37 @@ class _MyFamily extends State with TickerProviderStateMixin { else return Column( children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Expanded( - flex: 3, - child: Text(TranslationBase.of(context) - .request)), - Expanded( - flex: 2, - child: Text( - TranslationBase.of(context) - .switchUser, - )), - Expanded( - flex: 1, - child: Text( - TranslationBase.of(context) - .deleteView, - )), - ], - ), + // Padding(padding: EdgeInsets.only(left:10, right:10), + // child: + // Row( + // mainAxisAlignment: + // MainAxisAlignment.spaceBetween, + // children: [ + // Expanded( + // flex: 3, + // child: Text(TranslationBase.of(context) + // .request)), + // Expanded( + // flex: 2, + // child: Text( + // TranslationBase.of(context) + // .switchUser, + // )), + // Expanded( + // flex: 1, + // child: Text( + // TranslationBase.of(context) + // .deleteView, + // )), + // ], + // )), Column(children: [ - Row(children: [ + Padding( + padding: EdgeInsets.only(left:10, right:10), child:Row(children: [ Expanded(flex: 3, child: AppText('Name')), Expanded(flex: 1, child: AppText('Allow')), Expanded(flex: 1, child: AppText('Reject')), - ]), + ])), Column( children:familyFileProvider.allSharedRecordsByStatusResponse.getAllSharedRecordsByStatusList .map((result) { @@ -302,8 +368,8 @@ class _MyFamily extends State with TickerProviderStateMixin { color: Colors.black, ), onPressed: () { - acceptRequest( - result, context); + acceptRemoveRequest( + result.iD, 3, context); }, )), Expanded( @@ -314,8 +380,8 @@ class _MyFamily extends State with TickerProviderStateMixin { color: Colors.black, ), onPressed: () { - deleteRequest( - result, context); + acceptRemoveRequest( + result.iD,4, context); }, )) ], @@ -371,7 +437,7 @@ class _MyFamily extends State with TickerProviderStateMixin { flex: 2, child: AppText( result.statusDescription, - color: Colors.red, + color: result.status==3 ? Colors.green: Colors.red, )), ], )); @@ -405,31 +471,36 @@ class _MyFamily extends State with TickerProviderStateMixin { else return Column( children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Expanded( - flex: 3, - child: Text( - TranslationBase.of(context).request)), - Expanded( - flex: 2, - child: Text( - TranslationBase.of(context).switchUser, - )), - Expanded( - flex: 1, - child: Text( - TranslationBase.of(context).deleteView, - )), - ], - ), + // 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: [ - Row(children: [ + Padding( + padding:EdgeInsets.only(left:10, right:10), + child: Row(children: [ Expanded(flex: 3, child: AppText('Name')), Expanded(flex: 1, child: AppText('Delete')), - ]), + ])), Column( children: familyFileProvider.allSharedRecordsByStatusResponse.getAllSharedRecordsByStatusList .map((result) { @@ -439,7 +510,7 @@ class _MyFamily extends State with TickerProviderStateMixin { children: [ Expanded( flex: 3, - child: Text(result.patientName)), + child: AppText(result.patientName)), Expanded( flex: 1, child: IconButton( @@ -448,8 +519,8 @@ class _MyFamily extends State with TickerProviderStateMixin { color: Colors.black, ), onPressed: () { - deleteRequest( - result, context); + deactivateRequest(result.iD, + 5, context); }, )), ], @@ -514,8 +585,10 @@ class _MyFamily extends State with TickerProviderStateMixin { } refreshFamily(context) { - sharedPref.remove(FAMILY_FILE); - (context as Element).reassemble(); + //sharedPref.remove(FAMILY_FILE); + setState(() { + sharedPref.remove(FAMILY_FILE); + }); } switchUser(user, context) { @@ -541,6 +614,24 @@ class _MyFamily extends State with TickerProviderStateMixin { ); } - deleteRequest(result, context) {} - acceptRequest(result, context) {} + deactivateRequest(ID, status, context) { + GifLoaderDialogUtils.showMyDialog(context); + Map request = {}; + request["ID"] = ID; + request["Status"] = status; + this.familyFileProvider.deactivateFamily(request).then((value) => { + GifLoaderDialogUtils.hideDialog(context), + refreshFamily(context) + }); + } + acceptRemoveRequest(ID, status, context) { + GifLoaderDialogUtils.showMyDialog(context); + Map request = {}; + request["ID"] = ID; + request["Status"] = status; + this.familyFileProvider.acceptRejectFamily(request).then((value) => { + GifLoaderDialogUtils.hideDialog(context), + refreshFamily(context) + }); + } } diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart index 346b8ae8..8d522b1d 100644 --- a/lib/pages/landing/landing_page.dart +++ b/lib/pages/landing/landing_page.dart @@ -15,6 +15,8 @@ import 'package:diplomaticquarterapp/pages/livecare/incoming_call.dart'; import 'package:diplomaticquarterapp/pages/medical/medical_profile_page.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/services/robo_search/event_provider.dart'; +import 'package:diplomaticquarterapp/theme/theme_notifier.dart'; +import 'package:diplomaticquarterapp/theme/theme_value.dart'; import 'package:diplomaticquarterapp/uitl/CalendarUtils.dart'; import 'package:diplomaticquarterapp/uitl/LocalNotification.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -46,9 +48,9 @@ class LandingPage extends StatefulWidget { class _LandingPageState extends State with WidgetsBindingObserver { int currentTab = 0; PageController pageController; - ProjectViewModel projectProvider; + ProjectViewModel projectViewModel; var notificationCount = ''; - + var themeNotifier; ///inject the user data AuthenticatedUserObject authenticatedUserObject = locator(); @@ -91,6 +93,7 @@ class _LandingPageState extends State with WidgetsBindingObserver { print("didChangeAppLifecycleState"); print('state = $state'); AppGlobal.context = context; + if (state == AppLifecycleState.resumed) { print(LandingPage.isOpenCallPage); if (LandingPage.isOpenCallPage) { @@ -135,6 +138,9 @@ class _LandingPageState extends State with WidgetsBindingObserver { pageController = PageController(keepPage: true); _firebaseMessaging.setAutoInitEnabled(true); + + + if (Platform.isIOS) { _firebaseMessaging.requestNotificationPermissions(); } @@ -149,7 +155,7 @@ class _LandingPageState extends State with WidgetsBindingObserver { }).catchError((err) { print(err); }); - + Future.delayed(Duration.zero, () => setTheme()); //_firebase Background message handler // _firebaseMessaging.configure( // onMessage: (Map message) async { @@ -334,8 +340,9 @@ class _LandingPageState extends State with WidgetsBindingObserver { @override Widget build(BuildContext context) { - ProjectViewModel projectViewModel = Provider.of(context); - + projectViewModel = Provider.of(context); + themeNotifier = Provider.of(context); + //setTheme(); return Scaffold( appBar: AppBar( elevation: 0, @@ -460,7 +467,46 @@ class _LandingPageState extends State with WidgetsBindingObserver { return TranslationBase.of(context).services; } } - + setTheme() async{ + // + // defaultTheme = + // ThemeData( + // fontFamily:projectViewModel.isArabic ? 'Cairo' : 'WorkSans', + // primarySwatch: Colors.blue, + // visualDensity: VisualDensity.adaptivePlatformDensity, + // brightness: Brightness.light, + // pageTransitionsTheme: const PageTransitionsTheme( + // builders: { + // TargetPlatform.android: ZoomPageTransitionsBuilder(), + // TargetPlatform.iOS: CupertinoPageTransitionsBuilder(), + // }, + // ), + // hintColor: Colors.grey[400], + // disabledColor: Colors.grey[300], + // errorColor: Color.fromRGBO(235, 80, 60, 1.0), + // scaffoldBackgroundColor: Color(0xffEEEEEE), + // textSelectionColor: Color.fromRGBO(80, 100, 253, 0.5), + // textSelectionHandleColor: Colors.grey, + // canvasColor: Colors.white, + // backgroundColor: Colors.white, + // highlightColor: Colors.grey[100].withOpacity(0.4), + // splashColor: Colors.transparent, + // primaryColor: Color(0xff40ACC9), + // bottomSheetTheme: BottomSheetThemeData(backgroundColor: Color(0xffE0E0E0)), + // cursorColor: Colors.grey, + // cardColor: Colors.white, + // iconTheme: IconThemeData(), + // appBarTheme: AppBarTheme( + // color: Color(0xff40ACC9), + // brightness: Brightness.dark, + // elevation: 10.0, + // actionsIconTheme: IconThemeData( + // color: Color(0xff40ACC9), + // ), + // ), + // ); + // themeNotifier.setTheme(defaultTheme); + } void checkUserStatus(token) async { authService .selectDeviceImei(token) diff --git a/lib/pages/login/confirm-login.dart b/lib/pages/login/confirm-login.dart index e016776e..229e0a0f 100644 --- a/lib/pages/login/confirm-login.dart +++ b/lib/pages/login/confirm-login.dart @@ -460,7 +460,7 @@ class _ConfirmLogin extends State { this.deviceToken = await sharedPref.getString(PUSH_TOKEN); this.lastLogin = await sharedPref.getInt(LAST_LOGIN) != null ? await sharedPref.getInt(LAST_LOGIN) - : user.logInType !=null ? user.logInType : null; + : user !=null ? user.logInType : null; //this.cs.sharedService.getStorage(AuthenticationService.LAST_LOGIN); } @@ -525,6 +525,7 @@ class _ConfirmLogin extends State { } else { + sharedPref.remove(FAMILY_FILE), result.list.isFamily = false, userData = result.list, sharedPref.setObject(MAIN_USER, result.list), diff --git a/lib/pages/login/login.dart b/lib/pages/login/login.dart index 700a0d0c..25ad13bb 100644 --- a/lib/pages/login/login.dart +++ b/lib/pages/login/login.dart @@ -241,6 +241,7 @@ class _Login extends State { } // request.isRegister = false; this.authService.checkActivationCode(request, code).then((result) => { + sharedPref.remove(FAMILY_FILE), result = CheckActivationCode.fromJson(result), result.list.isFamily =false, this.sharedPref.setObject(USER_PROFILE, result.list), diff --git a/lib/pages/login/register-info.dart b/lib/pages/login/register-info.dart index 467068cc..8a99a128 100644 --- a/lib/pages/login/register-info.dart +++ b/lib/pages/login/register-info.dart @@ -296,6 +296,7 @@ class _RegisterInfo extends State { }else { + sharedPref.remove(FAMILY_FILE), result.list.isFamily = false, sharedPref.setObject(USER_PROFILE, result.list), this.sharedPref.setObject(MAIN_USER, result.list), @@ -303,20 +304,21 @@ class _RegisterInfo extends State { sharedPref.setString(TOKEN, result.authenticationTokenID), Navigator.of(context).pushNamed(HOME) } - }).catchError((err) { - GifLoaderDialogUtils.hideDialog(context); - ConfirmDialog dialog = new ConfirmDialog( - context: context, - confirmMessage: err, - okText: TranslationBase.of(context).confirm, - cancelText: TranslationBase.of(context).cancel_nocaps, - okFunction: () => { - ConfirmDialog.closeAlertDialog(context) - }, - cancelFunction: () => {ConfirmDialog.closeAlertDialog(context)}); - dialog.showAlertDialog(context); - - }); + }); + // .catchError((err) { + // GifLoaderDialogUtils.hideDialog(context); + // ConfirmDialog dialog = new ConfirmDialog( + // context: context, + // confirmMessage: err, + // okText: TranslationBase.of(context).confirm, + // cancelText: TranslationBase.of(context).cancel_nocaps, + // okFunction: () => { + // ConfirmDialog.closeAlertDialog(context) + // }, + // cancelFunction: () => {ConfirmDialog.closeAlertDialog(context)}); + // dialog.showAlertDialog(context); + // + // }); } getRegisterInfo() async { @@ -349,15 +351,15 @@ class _RegisterInfo extends State { "PatientOutSA": registerd_data.zipCode == '966' ? 0 : 1, "FirstNameN":registerInfo.firstNameAr =='-' ?"": registerInfo.firstNameAr, "FirstName": registerInfo.firstNameEn =='-' ?"":registerInfo.firstNameEn, - "MiddleNameN":registerInfo.secondNameAr =='-' ? "" : registerInfo.secondNameAr, - "MiddleName":registerInfo.secondNameEn == '-' ? "": registerInfo.secondNameEn, + "MiddleNameN":registerInfo.secondNameAr, + "MiddleName":registerInfo.secondNameEn, "LastNameN": registerInfo.lastNameAr =='-'? "" : registerInfo.lastNameAr, "LastName": registerInfo.lastNameEn =='-' ? "": registerInfo.lastNameEn, "StrDateofBirth": registerInfo.dateOfBirth, "DateofBirth": DateUtil.convertISODateToJsonDate( registerInfo.dateOfBirth.replaceAll('/', '-')), "Gender": registerInfo.gender == 'M' ? 1 : 2, - "NationalityID": registerInfo.nationality, + "NationalityID": registerInfo.nationalityCode, "DateofBirthN": date, "EmailAddress": email, "SourceType": location, diff --git a/lib/pages/settings/general_setting.dart b/lib/pages/settings/general_setting.dart index 7085150a..7becd17d 100644 --- a/lib/pages/settings/general_setting.dart +++ b/lib/pages/settings/general_setting.dart @@ -20,10 +20,10 @@ class _GeneralSettings extends State with TickerProviderStateMixin { var themeNotifier; int blindValue = 0; - bool vibration =false; - bool accsibility =false; - bool camera =false; - bool location =false; + bool vibration =false; + bool accsibility =false; + bool camera =false; + bool location =false; var sharedPref = new AppSharedPreferences(); var permission = new PermissionService(); var mediaQueryData; @@ -81,7 +81,7 @@ class _GeneralSettings extends State setState(() { accsibility = value; }); - //setAccisibility(value); + //setAccessibility(value); }, activeTrackColor: Colors.lightGreenAccent, activeColor: Colors.green, @@ -238,43 +238,7 @@ class _GeneralSettings extends State break; case 1: { - themeNotifier.setTheme(ThemeData( - fontFamily: await sharedPref.getString(APP_LANGUAGE) == 'ar' ? 'Cairo' : 'WorkSans', - primarySwatch: Colors.grey, - visualDensity: VisualDensity.adaptivePlatformDensity, - brightness: Brightness.light, - pageTransitionsTheme: const PageTransitionsTheme( - builders: { - TargetPlatform.android: ZoomPageTransitionsBuilder(), - TargetPlatform.iOS: CupertinoPageTransitionsBuilder(), - }, - ), - hintColor: Colors.grey[400], - cardColor: Colors.black, - buttonColor: Colors.grey[400], - disabledColor: Colors.grey[300], - errorColor: Color.fromRGBO(235, 80, 60, 1.0), - scaffoldBackgroundColor: Colors.grey, - textSelectionColor: Color.fromRGBO(80, 100, 253, 0.5), - textSelectionHandleColor: Colors.grey, - canvasColor: Colors.white, - backgroundColor: Colors.grey, - highlightColor: Colors.grey[100].withOpacity(0.4), - splashColor: Colors.transparent, - primaryColor: Colors.grey, - bottomSheetTheme: BottomSheetThemeData(backgroundColor: Color(0xffE0E0E0)), - cursorColor: Colors.grey, - - iconTheme: IconThemeData(), - appBarTheme: AppBarTheme( - color: Colors.grey, - brightness: Brightness.dark, - elevation: 10.0, - actionsIconTheme: IconThemeData( - color: Colors.grey, - ), - ), - )); + themeNotifier.setTheme(await getTheme(value)); Screen.setBrightness(1.0); } break; @@ -295,14 +259,14 @@ class _GeneralSettings extends State } break; } - //permission.setTheme(value); + permission.setTheme(value); } setVibration(value){ permission.setVibrationPermission(value); } - setAccisibility(){ + setAccessibility(){ if(!accsibility){ } @@ -311,12 +275,13 @@ class _GeneralSettings extends State getValues() async{ blindValue= permission.isThemeEnabled() == null ? 0 : permission.isThemeEnabled(); vibration = permission.isVibrationEnabled() ==null ? false : permission.isVibrationEnabled(); - accsibility =mediaQueryData.accessibleNavigation; + // accsibility = mediaQueryData.accessibleNavigation; } getTheme(value) async{ + if(value ==1){ return ThemeData( - fontFamily: await sharedPref.getString(APP_LANGUAGE) == 'ar' ? 'Cairo' : 'WorkSans', + fontFamily: await sharedPref.getString(APP_LANGUAGE) == 'en' ? 'WorkSans' : 'Cairo', primarySwatch: Colors.grey, visualDensity: VisualDensity.adaptivePlatformDensity, brightness: Brightness.light, @@ -355,7 +320,7 @@ class _GeneralSettings extends State }else if(value ==3){ return ThemeData( - fontFamily: await sharedPref.getString(APP_LANGUAGE) == 'ar' ? 'Cairo' : 'WorkSans', + fontFamily: await sharedPref.getString(APP_LANGUAGE) == 'en' ? 'WorkSans' : 'Cairo', primarySwatch: Colors.grey, visualDensity: VisualDensity.adaptivePlatformDensity, brightness: Brightness.light, @@ -394,7 +359,7 @@ class _GeneralSettings extends State }else { return ThemeData( - fontFamily: await sharedPref.getString(APP_LANGUAGE) == 'ar' ? 'Cairo' : 'WorkSans', + fontFamily: await sharedPref.getString(APP_LANGUAGE) == 'en' ? 'WorkSans' : 'Cairo', primarySwatch: Colors.blue, visualDensity: VisualDensity.adaptivePlatformDensity, brightness: Brightness.light, diff --git a/lib/services/family_files/family_files_provider.dart b/lib/services/family_files/family_files_provider.dart index 79ea67d0..ea2b87fd 100644 --- a/lib/services/family_files/family_files_provider.dart +++ b/lib/services/family_files/family_files_provider.dart @@ -37,6 +37,8 @@ const String SENT_REQUEST_URL = 'Services/Authentication.svc/REST/GetAllSharedRecordsByStatus'; const String RECEVIED_REQUEST_URL = 'Services/Authentication.svc/REST/GetAllPendingRecordsByResponseId'; +const ACCEPT_REJECT_FAMILY = 'Services/Authentication.svc/REST/Update_FileStatus'; +const DEACTIVATE_FAMILY = 'Services/Authentication.svc/REST/DeactivateRequestByRensponse'; class FamilyFilesProvider with ChangeNotifier { bool isLogin = false; @@ -300,4 +302,43 @@ class FamilyFilesProvider with ChangeNotifier { throw error; } } + + Future acceptRejectFamily(request) async { + try { + dynamic localRes; + + await new BaseAppClient().post(ACCEPT_REJECT_FAMILY, + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + AppToast.showErrorToast(message: error); + throw error; + }, body: request); + + return Future.value(localRes); + } catch (error) { + print(error); + throw error; + } + } + Future deactivateFamily(request) async { + try { + dynamic localRes; + + await new BaseAppClient().post(DEACTIVATE_FAMILY, + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + AppToast.showErrorToast(message: error); + throw error; + }, body: request); + + return Future.value(localRes); + } catch (error) { + print(error); + throw error; + } + } + + } diff --git a/lib/theme/theme_value.dart b/lib/theme/theme_value.dart index d19e13b2..bc80f47c 100644 --- a/lib/theme/theme_value.dart +++ b/lib/theme/theme_value.dart @@ -53,7 +53,7 @@ final blueBackground = Color(0xFFFFFFFF); ), ); - final defaultTheme = ThemeData( + var defaultTheme = ThemeData( //fontFamily: ProjectViewModel().isArabic? 'Cairo' : 'WorkSans', primarySwatch: Colors.blue, visualDensity: VisualDensity.adaptivePlatformDensity, diff --git a/lib/widgets/drawer/app_drawer_widget.dart b/lib/widgets/drawer/app_drawer_widget.dart index c8af1ccb..f29ea4c6 100644 --- a/lib/widgets/drawer/app_drawer_widget.dart +++ b/lib/widgets/drawer/app_drawer_widget.dart @@ -265,10 +265,12 @@ class _AppDrawerState extends State { ), Expanded( flex: 7, - child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + child: Padding( + padding:EdgeInsets.only(left:5, right:5), + child:Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ AppText(result.patientName, color: result.responseID == user.patientID ? Color(0xFF40ACC9) : Colors.black), AppText(TranslationBase.of(context).fileno + ": " + result.iD.toString(), color: result.responseID == user.patientID ? Color(0xFF40ACC9) : Colors.black), - ])), + ]))), ], ))) : SizedBox(); From 8429f83d7cd1dfc9eede6423d0c48c3ff0378aed Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Tue, 24 Nov 2020 12:32:13 +0300 Subject: [PATCH 05/20] registration done --- lib/config/config.dart | 4 ++-- lib/pages/login/register-info.dart | 33 ++++++++++++++++++++++-------- lib/pages/login/register.dart | 4 ++-- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 2592d1b2..58ade1bc 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -7,8 +7,8 @@ import 'package:diplomaticquarterapp/widgets/mobile-no/mobile_no.dart'; const MAX_SMALL_SCREEN = 660; -//const BASE_URL = 'https://uat.hmgwebservices.com/'; - const BASE_URL = 'https://hmgwebservices.com/'; +const BASE_URL = 'https://uat.hmgwebservices.com/'; + //const BASE_URL = 'https://hmgwebservices.com/'; const GET_PROJECT = 'Services/Lists.svc/REST/GetProject'; ///Doctor diff --git a/lib/pages/login/register-info.dart b/lib/pages/login/register-info.dart index 8a99a128..4ede2683 100644 --- a/lib/pages/login/register-info.dart +++ b/lib/pages/login/register-info.dart @@ -1,5 +1,9 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; +import 'package:diplomaticquarterapp/core/viewModels/appointment_rate_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/models/Authentication/check_paitent_authentication_req.dart'; import 'package:diplomaticquarterapp/models/Authentication/register_info_response.dart'; import 'package:diplomaticquarterapp/models/Authentication/register_user_requet.dart'; @@ -7,6 +11,7 @@ import 'package:diplomaticquarterapp/pages/login/login-type.dart'; import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -20,6 +25,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:hijri/hijri_calendar.dart'; import 'package:intl/intl.dart'; +import 'package:provider/provider.dart'; class RegisterInfo extends StatefulWidget { @override @@ -45,6 +51,11 @@ class _RegisterInfo extends State { String email = ''; String location = '1'; + AuthenticatedUserObject authenticatedUserObject = + locator(); + AppointmentRateViewModel appointmentRateViewModel = + locator(); + ProjectViewModel projectViewModel; @override void initState() { @@ -56,6 +67,7 @@ class _RegisterInfo extends State { @override Widget build(BuildContext context) { + projectViewModel = Provider.of(context); return AppScaffold( appBarTitle: TranslationBase.of(context).register, isShowAppBar: true, @@ -297,12 +309,17 @@ class _RegisterInfo extends State { }else { sharedPref.remove(FAMILY_FILE), - result.list.isFamily = false, - sharedPref.setObject(USER_PROFILE, result.list), - this.sharedPref.setObject(MAIN_USER, result.list), - sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID), - sharedPref.setString(TOKEN, result.authenticationTokenID), - Navigator.of(context).pushNamed(HOME) + result['List'][0]['IsFamily'] = false, + sharedPref.setObject(USER_PROFILE, result['List'][0]), + this.sharedPref.setObject(MAIN_USER, result['List'][0]), + sharedPref.setObject(LOGIN_TOKEN_ID, result["LogInTokenID"]), + sharedPref.setString(TOKEN, result["AuthenticationTokenID"]), + authenticatedUserObject.isLogin = true, + appointmentRateViewModel.isLogin = true, + projectViewModel.isLogin = true, + + Navigator.of(context).pushNamed(HOME), + AppToast.showSuccessToast(message: result["ErrorEndUserMessage"]) } }); // .catchError((err) { @@ -376,8 +393,8 @@ class _RegisterInfo extends State { } bool isValid() { - if (location != null || - language != null || + if (location != null && + language != null && Utils.validEmail(email) == true) { return true; } else { diff --git a/lib/pages/login/register.dart b/lib/pages/login/register.dart index ea47a4fa..042f56fe 100644 --- a/lib/pages/login/register.dart +++ b/lib/pages/login/register.dart @@ -298,7 +298,7 @@ class _Register extends State { // DOB: this.dateOption === '1' ? this.dateOfBirth : moment(this.dateOfBirth).format('DD/MM/YYYY'), // IsHijri: Number(this.dateOption) // } - showLoader(true); + GifLoaderDialogUtils.showMyDialog(context); var request = CheckUserStatusRequest(); request.patientIdentificationID = nationalIDorFile.text; request.dOB = isHijri == 1 @@ -307,7 +307,7 @@ class _Register extends State { request.isHijri = isHijri; request.patientOutSA = countryCode == '966' ? 0 : 1; this.authService.checkUserStatus(request).then((result) => { - showLoader(false), + GifLoaderDialogUtils.hideDialog(context), if (result is Map) { result = CheckUserStatusResponse.fromJson(result), From d284ceac0426acf1935dd016fa3dd375eae53f1d Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 24 Nov 2020 17:26:13 +0300 Subject: [PATCH 06/20] advance payment & payment flow issues fixed --- .../service/medical/my_balance_service.dart | 19 +++--- .../medical/my_balance_view_model.dart | 4 +- lib/pages/Blood/confirm_payment_page.dart | 3 + lib/pages/BookAppointment/BookSuccess.dart | 3 + lib/pages/ToDoList/ToDo.dart | 3 + lib/pages/livecare/widgets/clinic_list.dart | 3 + .../medical/balance/advance_payment_page.dart | 61 +++++++++++++------ .../medical/balance/confirm_payment_page.dart | 12 +++- .../appointment_services/GetDoctorsList.dart | 15 +++-- lib/widgets/in_app_browser/InAppBrowser.dart | 32 ++++++---- 10 files changed, 103 insertions(+), 52 deletions(-) diff --git a/lib/core/service/medical/my_balance_service.dart b/lib/core/service/medical/my_balance_service.dart index c456b38c..e3be9bcf 100644 --- a/lib/core/service/medical/my_balance_service.dart +++ b/lib/core/service/medical/my_balance_service.dart @@ -1,5 +1,3 @@ -import 'dart:convert'; - import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/model/my_balance/AdvanceModel.dart'; @@ -24,7 +22,8 @@ class MyBalanceService extends BaseService { String logInTokenID; String verificationCode; - AuthenticatedUserObject authenticatedUserObject = locator(); + AuthenticatedUserObject authenticatedUserObject = + locator(); getPatientAdvanceBalanceAmount() async { hasError = false; @@ -61,13 +60,14 @@ class MyBalanceService extends BaseService { }, body: body); } - getPatientInfoByPatientIDAndMobileNumber() async { + getPatientInfoByPatientIDAndMobileNumber(AdvanceModel advanceModel) async { hasError = false; super.error = ""; Map body = Map(); body['isDentalAllowedBackend'] = false; - body['MobileNo'] = authenticatedUserObject.user.mobileNumber; - body['ProjectID'] = authenticatedUserObject.user.projectID; + body['MobileNo'] = advanceModel.mobileNumber; + body['ProjectID'] = advanceModel.hospitalsModel.iD; + body['PatientID'] = advanceModel.fileNumber; await baseAppClient.post(GET_PATIENT_INFO_BY_ID_AND_MOBILE_NUMBER, onSuccess: (response, statusCode) async { @@ -81,7 +81,7 @@ class MyBalanceService extends BaseService { }, body: body); } - sendActivationCodeForAdvancePayment({int patientID,int projectID}) async { + sendActivationCodeForAdvancePayment({int patientID, int projectID}) async { hasError = false; super.error = ""; Map body = Map(); @@ -111,9 +111,8 @@ class MyBalanceService extends BaseService { body['LogInTokenID'] = logInTokenID; await baseAppClient.post(CHECK_ACTIVATION_CODE_FOR_ADVANCE_PAYMENT, - onSuccess: (response, statusCode) async { - - }, onFailure: (String error, int statusCode) { + onSuccess: (response, statusCode) async {}, + onFailure: (String error, int statusCode) { hasError = true; super.error = error; super.error = error; diff --git a/lib/core/viewModels/medical/my_balance_view_model.dart b/lib/core/viewModels/medical/my_balance_view_model.dart index 8225d97e..62b7868b 100644 --- a/lib/core/viewModels/medical/my_balance_view_model.dart +++ b/lib/core/viewModels/medical/my_balance_view_model.dart @@ -112,10 +112,10 @@ class MyBalanceViewModel extends BaseViewModel { } } - Future getPatientInfoByPatientIDAndMobileNumber() async { + Future getPatientInfoByPatientIDAndMobileNumber(AdvanceModel advanceModel) async { setState(ViewState.Busy); await _myBalanceService - .getPatientInfoByPatientIDAndMobileNumber(); + .getPatientInfoByPatientIDAndMobileNumber(advanceModel); if (_myBalanceService.hasError) { error = _myBalanceService.error; setState(ViewState.ErrorLocal); diff --git a/lib/pages/Blood/confirm_payment_page.dart b/lib/pages/Blood/confirm_payment_page.dart index 3d9fccb2..9ad6d68f 100644 --- a/lib/pages/Blood/confirm_payment_page.dart +++ b/lib/pages/Blood/confirm_payment_page.dart @@ -213,6 +213,9 @@ class ConfirmPaymentPage extends StatelessWidget { appo.projectID.toString(), authenticatedUser.emailAddress, paymentMethod, + authenticatedUser.patientType, + authenticatedUser.firstName, + authenticatedUser.patientID, authenticatedUser, browser); } diff --git a/lib/pages/BookAppointment/BookSuccess.dart b/lib/pages/BookAppointment/BookSuccess.dart index 39e290a1..82248560 100644 --- a/lib/pages/BookAppointment/BookSuccess.dart +++ b/lib/pages/BookAppointment/BookSuccess.dart @@ -573,6 +573,9 @@ class _BookSuccessState extends State { appo.projectID.toString(), authenticatedUser.emailAddress, paymentMethod, + authenticatedUser.patientType, + authenticatedUser.firstName, + authenticatedUser.patientID, authenticatedUser, widget.browser); } diff --git a/lib/pages/ToDoList/ToDo.dart b/lib/pages/ToDoList/ToDo.dart index b0315d28..96835d7b 100644 --- a/lib/pages/ToDoList/ToDo.dart +++ b/lib/pages/ToDoList/ToDo.dart @@ -606,6 +606,9 @@ class _ToDoState extends State { appo.projectID.toString(), authenticatedUser.emailAddress, paymentMethod, + authenticatedUser.patientType, + authenticatedUser.firstName, + authenticatedUser.patientID, authenticatedUser, widget.browser); } diff --git a/lib/pages/livecare/widgets/clinic_list.dart b/lib/pages/livecare/widgets/clinic_list.dart index d2e52b72..8ce3b7b0 100644 --- a/lib/pages/livecare/widgets/clinic_list.dart +++ b/lib/pages/livecare/widgets/clinic_list.dart @@ -285,6 +285,9 @@ class _clinic_listState extends State { "12", authenticatedUser.emailAddress, paymentMethod, + authenticatedUser.patientType, + authenticatedUser.firstName, + authenticatedUser.patientID, authenticatedUser, browser); } diff --git a/lib/pages/medical/balance/advance_payment_page.dart b/lib/pages/medical/balance/advance_payment_page.dart index f19b03ed..9b255711 100644 --- a/lib/pages/medical/balance/advance_payment_page.dart +++ b/lib/pages/medical/balance/advance_payment_page.dart @@ -29,7 +29,6 @@ import 'new_text_Field.dart'; enum BeneficiaryType { MyAccount, MyFamilyFiles, OtherAccount, NON } - class AdvancePaymentPage extends StatefulWidget { @override _AdvancePaymentPageState createState() => _AdvancePaymentPageState(); @@ -238,13 +237,35 @@ class _AdvancePaymentPageState extends State { _fileTextController.text.isEmpty || _selectedHospital == null, onTap: () { + var mobileNum; + var patientName; + + if (beneficiaryType == BeneficiaryType.MyFamilyFiles) { + mobileNum = selectedPatientFamily.mobileNumber; + patientName = selectedPatientFamily.patientName; + } + + if (beneficiaryType == BeneficiaryType.MyAccount) { + mobileNum = model.user.mobileNumber; + patientName = model.user.firstName; + } + + if (beneficiaryType == BeneficiaryType.OtherAccount) { + mobileNum = _selectedPatientInfo.mobileNumber; + patientName = _selectedPatientInfo.fullName; + } + advanceModel.fileNumber = _fileTextController.text; advanceModel.hospitalsModel = _selectedHospital; advanceModel.note = _notesTextController.text; advanceModel.email = email ?? model.user.emailAddress; advanceModel.amount = amount; + advanceModel.mobileNumber = mobileNum; + advanceModel.patientName = patientName; - model.getPatientInfoByPatientIDAndMobileNumber().then((value) { + model + .getPatientInfoByPatientIDAndMobileNumber(advanceModel) + .then((value) { if (model.state != ViewState.Error && model.state != ViewState.ErrorLocal) { Utils.hideKeyboard(context); @@ -269,8 +290,8 @@ class _AdvancePaymentPageState extends State { ); } }).showProgressBar( - text: "Loading", - backgroundColor: Colors.blue.withOpacity(0.6)); + text: "Loading", + backgroundColor: Colors.blue.withOpacity(0.6)); }, ), )), @@ -331,22 +352,22 @@ class _AdvancePaymentPageState extends State { void confirmSelectFamilyDialog( List getAllSharedRecordsByStatusList) { - if(getAllSharedRecordsByStatusList.isNotEmpty) - showDialog( - context: context, - child: SelectPatientFamilyDialog( - getAllSharedRecordsByStatusList: getAllSharedRecordsByStatusList, - selectedPatientFamily: selectedPatientFamily, - onValueSelected: (value) { - setState(() { - selectedPatientFamily = value; - _fileTextController.text = - selectedPatientFamily.patientID.toString(); - advanceModel.depositorName = value.patientName; - }); - }, - ), - ); + if (getAllSharedRecordsByStatusList.isNotEmpty) + showDialog( + context: context, + child: SelectPatientFamilyDialog( + getAllSharedRecordsByStatusList: getAllSharedRecordsByStatusList, + selectedPatientFamily: selectedPatientFamily, + onValueSelected: (value) { + setState(() { + selectedPatientFamily = value; + _fileTextController.text = + selectedPatientFamily.responseID.toString(); + advanceModel.depositorName = value.patientName; + }); + }, + ), + ); } String getBeneficiaryType() { diff --git a/lib/pages/medical/balance/confirm_payment_page.dart b/lib/pages/medical/balance/confirm_payment_page.dart index dbc2537f..4954653d 100644 --- a/lib/pages/medical/balance/confirm_payment_page.dart +++ b/lib/pages/medical/balance/confirm_payment_page.dart @@ -137,7 +137,11 @@ class ConfirmPaymentPage extends StatelessWidget { ), NewTextFields( hintText: TranslationBase.of(context).depositorName, - initialValue: advanceModel.depositorName, + initialValue: model.user.firstName + + " " + + model.user.middleName + + " " + + model.user.lastName, isEnabled: false, ), SizedBox( @@ -217,6 +221,9 @@ class ConfirmPaymentPage extends StatelessWidget { advanceModel.hospitalsModel.iD.toString(), advanceModel.email, paymentMethod, + patientInfoAndMobileNumber.patientType, + advanceModel.patientName, + advanceModel.fileNumber, authenticatedUser, browser); } @@ -276,6 +283,9 @@ class ConfirmPaymentPage extends StatelessWidget { res['Amount'], res['Fort_id'], res['PaymentMethod'], + patientInfoAndMobileNumber.patientType, + advanceModel.patientName, + advanceModel.fileNumber, AppGlobal.context) .then((res) { print(res['OnlineCheckInAppointments'][0]['AdvanceNumber']); diff --git a/lib/services/appointment_services/GetDoctorsList.dart b/lib/services/appointment_services/GetDoctorsList.dart index eb1ab98f..579c0e10 100644 --- a/lib/services/appointment_services/GetDoctorsList.dart +++ b/lib/services/appointment_services/GetDoctorsList.dart @@ -1168,6 +1168,9 @@ class DoctorsListService extends BaseService { double payedAmount, String paymentReference, String paymentMethodName, + dynamic patientType, + String patientName, + dynamic patientID, BuildContext context) async { Map request; if (await this.sharedPref.getObject(USER_PROFILE) != null) { @@ -1179,12 +1182,12 @@ class DoctorsListService extends BaseService { Request req = appGlobal.getPublicRequest(); request = { - "CustName": authUser.firstName + " " + authUser.lastName, - "CustID": authUser.patientID, + "CustName": patientName, + "CustID": patientID, "SetupID": "010266", "ProjectID": projectID, - "PatientID": authUser.patientID, - "AccountID": authUser.patientID, + "PatientID": patientID, + "AccountID": patientID, "PaymentAmount": payedAmount, "NationalityID": null, "DepositorName": authUser.firstName + " " + authUser.lastName, @@ -1201,8 +1204,8 @@ class DoctorsListService extends BaseService { "SessionID": "YckwoXhUmWBsnHKEKig", "isDentalAllowedBackend": false, "TokenID": "@dm!n", - "PatientTypeID": authUser.patientType, - "PatientType": authUser.patientType + "PatientTypeID": patientType, + "PatientType": patientType }; dynamic localRes; await baseAppClient.post(HIS_CREATE_ADVANCE_PAYMENT, diff --git a/lib/widgets/in_app_browser/InAppBrowser.dart b/lib/widgets/in_app_browser/InAppBrowser.dart index 203eef12..e465db39 100644 --- a/lib/widgets/in_app_browser/InAppBrowser.dart +++ b/lib/widgets/in_app_browser/InAppBrowser.dart @@ -107,13 +107,16 @@ class MyInAppBrowser extends InAppBrowser { String projId, String emailId, String paymentMethod, + dynamic patientType, + String patientName, + dynamic patientID, AuthenticatedUser authenticatedUser, InAppBrowser browser) { getDeviceToken(); this.browser = browser; this.browser.openUrl( url: generateURL(amount, orderDesc, transactionID, projId, emailId, - paymentMethod, authenticatedUser)); + paymentMethod, patientType, patientName, patientID, authenticatedUser)); } openBrowser(String url) { @@ -128,6 +131,9 @@ class MyInAppBrowser extends InAppBrowser { String projId, String emailId, String paymentMethod, + dynamic patientType, + String patientName, + dynamic patientID, AuthenticatedUser authUser, [var patientData, var servID, @@ -136,11 +142,11 @@ class MyInAppBrowser extends InAppBrowser { String currentLanguageID = getLanguageID() == 'ar' ? 'AR' : 'EN'; String form = getForm(); - if (authUser != null) { - form = form.replaceFirst("EMAIL_VALUE", authUser.emailAddress); - } else { + // if (authUser != null) { + // form = form.replaceFirst("EMAIL_VALUE", authUser.emailAddress); + // } else { form = form.replaceFirst("EMAIL_VALUE", emailId); - } + // } form = form.replaceFirst('AMOUNT_VALUE', amount.toString()); form = form.replaceFirst('ORDER_DESCRIPTION_VALUE', orderDesc); @@ -152,7 +158,7 @@ class MyInAppBrowser extends InAppBrowser { form = form.replaceFirst('PATIENT_OUT_SA', authUser.outSA == 0 ? false.toString() : true.toString()); form = form.replaceFirst('PATIENT_TYPE_ID', - patientData == null ? authUser.patientType.toString() : "1"); + patientData == null ? patientType.toString() : "1"); // form = form.replaceFirst('DEVICE_TOKEN', this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false) + "," + this.cs.sharedService.getSharedData(AuthenticationService.APNS_TOKEN, false)); // form = form.replaceFirst('LATITUDE_VALUE', this.cs.sharedService.getSharedData('userLat', false)); @@ -172,13 +178,13 @@ class MyInAppBrowser extends InAppBrowser { form = form.replaceFirst('LIVE_SERVICE_ID', "2"); } - if (patientData == null) { - form = form.replaceFirst('CUSTNAME_VALUE', authUser.firstName); - form = form.replaceFirst('CUSTID_VALUE', authUser.patientID.toString()); - } else { - form = form.replaceFirst('CUSTNAME_VALUE', patientData.depositorName); - form = form.replaceFirst('CUSTID_VALUE', patientData.fileNumber); - } + // if (patientData == null) { + form = form.replaceFirst('CUSTNAME_VALUE', patientName); + form = form.replaceFirst('CUSTID_VALUE', patientID.toString()); + // } else { + // form = form.replaceFirst('CUSTNAME_VALUE', patientData.depositorName); + // form = form.replaceFirst('CUSTID_VALUE', patientData.fileNumber); + // } form = form.replaceFirst('LATITUDE_VALUE', "24.708488"); form = form.replaceFirst('LONGITUDE_VALUE', "46.665925"); From 571bda91005158bf6e7de46be44607bd5c322125 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Wed, 25 Nov 2020 09:42:05 +0300 Subject: [PATCH 07/20] permission --- android/app/src/debug/AndroidManifest.xml | 1 + android/app/src/profile/AndroidManifest.xml | 1 + lib/pages/settings/general_setting.dart | 208 +++++++++--------- lib/pages/settings/profile_setting.dart | 82 +++++-- .../authentication/auth_provider.dart | 39 +++- .../permission/permission_service.dart | 30 ++- pubspec.yaml | 2 +- 7 files changed, 242 insertions(+), 121 deletions(-) diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml index d8fd4e88..beeadd9e 100644 --- a/android/app/src/debug/AndroidManifest.xml +++ b/android/app/src/debug/AndroidManifest.xml @@ -3,5 +3,6 @@ + diff --git a/android/app/src/profile/AndroidManifest.xml b/android/app/src/profile/AndroidManifest.xml index d8fd4e88..71c11607 100644 --- a/android/app/src/profile/AndroidManifest.xml +++ b/android/app/src/profile/AndroidManifest.xml @@ -4,4 +4,5 @@ to allow setting breakpoints, to provide hot reload, etc. --> + diff --git a/lib/pages/settings/general_setting.dart b/lib/pages/settings/general_setting.dart index 7becd17d..86167b7d 100644 --- a/lib/pages/settings/general_setting.dart +++ b/lib/pages/settings/general_setting.dart @@ -19,6 +19,7 @@ class GeneralSettings extends StatefulWidget { class _GeneralSettings extends State with TickerProviderStateMixin { var themeNotifier; + var mediaQueryData; int blindValue = 0; bool vibration =false; bool accsibility =false; @@ -26,7 +27,6 @@ class _GeneralSettings extends State bool location =false; var sharedPref = new AppSharedPreferences(); var permission = new PermissionService(); - var mediaQueryData; @override void initState() { getValues(); @@ -81,104 +81,104 @@ class _GeneralSettings extends State setState(() { accsibility = value; }); - //setAccessibility(value); + permission.openSettings(); }, activeTrackColor: Colors.lightGreenAccent, activeColor: Colors.green, ) ], )), - Container( - padding: EdgeInsets.all(10), - child: AppText( - TranslationBase.of(context).blindMode, - color: Colors.black, - fontWeight: FontWeight.bold, - ), - ), - new Container( - color: Colors.white, - padding: EdgeInsets.all(8.0), - child: new Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - new Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - new Text( - TranslationBase.of(context).offTheme, - style: new TextStyle(fontSize: 16.0), - ), - Radio( - value: 0, - groupValue: blindValue, - onChanged: (value) { - setState(() => {this.blindValue = value}); - setTheme(value); - }, - ), - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - new Text( - TranslationBase.of(context).invertTheme, - style: new TextStyle( - fontSize: 16.0, - ), - ), - new Radio( - value: 1, - groupValue: blindValue, - onChanged: (value) { - setState(() => {this.blindValue = value}); - setTheme(value); - }, - ) - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - new Text( - TranslationBase.of(context).dimTheme, - style: new TextStyle(fontSize: 16.0), - ), - new Radio( - value: 2, - groupValue: blindValue, - onChanged: (value) { - setState(() => {this.blindValue = value}); - setTheme(value); - }, - ), - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - new Text( - TranslationBase.of(context).bwTheme, - style: new TextStyle(fontSize: 16.0), - ), - new Radio( - value: 3, - groupValue: blindValue, - onChanged: (value) { - setState(() => {this.blindValue = value}); - - setTheme(value); - }, - ), - ], - ), - ], - ) - ])), + // Container( + // padding: EdgeInsets.all(10), + // child: AppText( + // TranslationBase.of(context).blindMode, + // color: Colors.black, + // fontWeight: FontWeight.bold, + // ), + // ), + // new Container( + // color: Colors.white, + // padding: EdgeInsets.all(8.0), + // child: new Column( + // mainAxisAlignment: MainAxisAlignment.center, + // children: [ + // new Column( + // mainAxisAlignment: MainAxisAlignment.center, + // children: [ + // Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // new Text( + // TranslationBase.of(context).offTheme, + // style: new TextStyle(fontSize: 16.0), + // ), + // Radio( + // value: 0, + // groupValue: blindValue, + // onChanged: (value) { + // setState(() => {this.blindValue = value}); + // setTheme(value); + // }, + // ), + // ], + // ), + // Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // new Text( + // TranslationBase.of(context).invertTheme, + // style: new TextStyle( + // fontSize: 16.0, + // ), + // ), + // new Radio( + // value: 1, + // groupValue: blindValue, + // onChanged: (value) { + // setState(() => {this.blindValue = value}); + // setTheme(value); + // }, + // ) + // ], + // ), + // Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // new Text( + // TranslationBase.of(context).dimTheme, + // style: new TextStyle(fontSize: 16.0), + // ), + // new Radio( + // value: 2, + // groupValue: blindValue, + // onChanged: (value) { + // setState(() => {this.blindValue = value}); + // setTheme(value); + // }, + // ), + // ], + // ), + // Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // new Text( + // TranslationBase.of(context).bwTheme, + // style: new TextStyle(fontSize: 16.0), + // ), + // new Radio( + // value: 3, + // groupValue: blindValue, + // onChanged: (value) { + // setState(() => {this.blindValue = value}); + // + // setTheme(value); + // }, + // ), + // ], + // ), + // ], + // ) + // ])), Container( padding: EdgeInsets.all(10), child: AppText( @@ -200,6 +200,7 @@ class _GeneralSettings extends State setState(() { camera = value; }); + permission.setCameraLocationPermission(context); }, activeTrackColor: Colors.lightGreenAccent, activeColor: Colors.green, @@ -219,6 +220,7 @@ class _GeneralSettings extends State setState(() { location = value; }); + permission.setCameraLocationPermission(context); }, activeTrackColor: Colors.lightGreenAccent, activeColor: Colors.green, @@ -266,16 +268,18 @@ class _GeneralSettings extends State permission.setVibrationPermission(value); } - setAccessibility(){ - if(!accsibility){ - - } - // permission.setVibrationPermission(value); - } getValues() async{ - blindValue= permission.isThemeEnabled() == null ? 0 : permission.isThemeEnabled(); - vibration = permission.isVibrationEnabled() ==null ? false : permission.isVibrationEnabled(); - // accsibility = mediaQueryData.accessibleNavigation; + blindValue= permission.isThemeEnabled() == null ? 0 : permission.isThemeEnabled(); + vibration = permission.isVibrationEnabled() ==null ? false : permission.isVibrationEnabled(); + camera = await permission.isCameraEnabled(); + location = await permission.isLocationEnabled(); + setState(() { + location =location; + camera = camera; + vibration = vibration; + blindValue =blindValue; + accsibility = mediaQueryData.accessibleNavigation; + }); } getTheme(value) async{ diff --git a/lib/pages/settings/profile_setting.dart b/lib/pages/settings/profile_setting.dart index 0658e2e6..c9089351 100644 --- a/lib/pages/settings/profile_setting.dart +++ b/lib/pages/settings/profile_setting.dart @@ -1,5 +1,8 @@ +import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/viewModels/dashboard_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; @@ -8,17 +11,31 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class ProfileSettings extends StatefulWidget { + @override _ProfileSettings createState() => _ProfileSettings(); } class _ProfileSettings extends State with TickerProviderStateMixin { + bool smsAlert = true; + bool emailAlert = true; + int language = 1; + final authService = new AuthProvider(); + TextEditingController emergencyContact = new TextEditingController(); + TextEditingController emailController = new TextEditingController(); + TextEditingController emergencyContactName = new TextEditingController(); + @override + void initState() { + Future.delayed(new Duration(seconds: 0), () { + getSettings(context); + }); + super.initState(); + } Widget build(BuildContext context) { - bool isVibration = true; - var language = 1; + return BaseView( - onModelReady: (model) => model.getPatientRadOrders(), + onModelReady: (model) =>{}, builder: (_, model, wi) => Container( child: ListView(scrollDirection: Axis.vertical, children: [ @@ -62,7 +79,10 @@ class _ProfileSettings extends State value: 2, groupValue: language, onChanged: (value) { - language = value; + setState(() { + language = value; + }); + }, ) ], @@ -79,7 +99,10 @@ class _ProfileSettings extends State value: 1, groupValue: language, onChanged: (value) { - language = value; + setState(() { + language = value; + }); + }, ) ], @@ -97,10 +120,10 @@ class _ProfileSettings extends State children: [ AppText(TranslationBase.of(context).emailAlert), Switch( - value: isVibration, + value: emailAlert, onChanged: (value) { setState(() { - isVibration = value; + emailAlert = value; }); }, activeTrackColor: Colors.lightGreenAccent, @@ -117,10 +140,10 @@ class _ProfileSettings extends State children: [ AppText(TranslationBase.of(context).smsAlert), Switch( - value: isVibration, + value: smsAlert, onChanged: (value) { setState(() { - isVibration = value; + smsAlert = value; }); }, activeTrackColor: Colors.lightGreenAccent, @@ -141,7 +164,7 @@ class _ProfileSettings extends State children: [ AppText(TranslationBase.of(context).email), TextField( - style: TextStyle(color: Colors.red), + controller: emailController, decoration: InputDecoration( suffixIcon: Icon(Icons.edit), )) @@ -156,7 +179,7 @@ class _ProfileSettings extends State children: [ AppText(TranslationBase.of(context).emergencyName), TextField( - style: TextStyle(color: Colors.red), + controller: emergencyContactName, decoration: InputDecoration( suffixIcon: Icon(Icons.edit), )) @@ -171,7 +194,7 @@ class _ProfileSettings extends State children: [ AppText(TranslationBase.of(context).emergencyContact), TextField( - style: TextStyle(color: Colors.red), + controller: emergencyContact, decoration: InputDecoration( suffixIcon: Icon(Icons.edit), ), @@ -186,11 +209,44 @@ class _ProfileSettings extends State child: DefaultButton( TranslationBase.of(context).submit, () { -// print(mobileNo.text); + saveSettings(); }, )), ], )) ]))); } + + getSettings(context){ + GifLoaderDialogUtils.showMyDialog(context); + authService.getSettings().then((result)=>{ + GifLoaderDialogUtils.hideDialog(context), + setValue(result["PateintInfoForUpdateList"][0]) + }); + } + setValue(value){ + setState(() { + this.language = int.parse(value["PreferredLanguage"]); + this.emailAlert = value["IsEmailAlertRequired"]; + this.smsAlert = value["IsSMSAlertRequired"]; + this.emailController.text = value["EmailAddress"]; + this.emergencyContact.text = value["EmergencyContactNo"]; + this.emergencyContactName.text = value["EmergencyContactName"]; + }); + + } + saveSettings(){ + GifLoaderDialogUtils.showMyDialog(context); + Map request = {}; + request["EmailAddress"] =this.emailController.text; + request["EmergencyContactName"] = this.emergencyContactName.text; + request["EmergencyContactNo"] = this.emergencyContact.text; + request["IsEmailAlertRequired"] = this.emailAlert; + request["IsSMSAlertRequired"] = this.smsAlert; + request["PreferredLanguage"] = this.language.toString(); + authService.saveSettings(request).then((result)=>{ + print(result), + GifLoaderDialogUtils.hideDialog(context) + }); + } } diff --git a/lib/services/authentication/auth_provider.dart b/lib/services/authentication/auth_provider.dart index a8517a1e..4dedb37f 100644 --- a/lib/services/authentication/auth_provider.dart +++ b/lib/services/authentication/auth_provider.dart @@ -48,7 +48,8 @@ const LOGGED_IN_USER_URL = const FORGOT_PATIENT_ID = 'Services/Authentication.svc/REST/SendPatientIDSMSByMobileNumber'; const DASHBOARD = 'Services/Patients.svc/REST/PatientDashboard'; - +const PROFILE_SETTING = 'Services/Patients.svc/REST/GetPateintInfoForUpdate'; +const SAVE_SETTING = 'Services/Patients.svc/REST/UpdatePateintInfo'; class AuthProvider with ChangeNotifier { bool isLogin = false; bool isLoading = true; @@ -457,4 +458,40 @@ class AuthProvider with ChangeNotifier { //return Future.value(error); } } + getSettings() async{ + + dynamic localRes; + try { + await new BaseAppClient().post(PROFILE_SETTING, + onSuccess: (dynamic response, int statusCode) { + localRes = response; //CheckActivationCode.fromJson(); + }, 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); + } + } + Future saveSettings(request) async{ + + dynamic localRes; + try { + await new BaseAppClient().post(SAVE_SETTING, + onSuccess: (dynamic response, int statusCode) { + localRes = response; //CheckActivationCode.fromJson(); + }, 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); + } + } } diff --git a/lib/services/permission/permission_service.dart b/lib/services/permission/permission_service.dart index 6f01f3c8..7123529c 100644 --- a/lib/services/permission/permission_service.dart +++ b/lib/services/permission/permission_service.dart @@ -1,3 +1,4 @@ +import 'package:android_intent/android_intent.dart'; import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; @@ -8,7 +9,8 @@ import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:localstorage/localstorage.dart'; - +import 'package:permission_handler/permission_handler.dart'; +import 'package:vibration/vibration.dart'; class PermissionService extends BaseService { final LocalStorage storage = new LocalStorage("permission"); @@ -21,9 +23,11 @@ class PermissionService extends BaseService { isVibrationEnabled() { return storage.getItem('isVibration') ==null ? false :true; } - vibrate(){ + vibrate() async{ if(isVibrationEnabled() ==true){ - HapticFeedback.vibrate(); + if (await Vibration.hasVibrator()) { + Vibration.vibrate(duration: 100); + } } } @@ -35,5 +39,23 @@ class PermissionService extends BaseService { isThemeEnabled() { return storage.getItem('isTheme'); } - + cameraPermission() async{ + Map statuses = await [ + Permission.camera, + ].request(); + } + isCameraEnabled() async{ + print(await Permission.camera.status); + return await Permission.camera.status == PermissionStatus.granted ? true : false; + } + setCameraLocationPermission(context) async{ + Navigator.pop(context); + openAppSettings(); + } + isLocationEnabled() async{ + return await Permission.location.status == PermissionStatus.granted ? true : false; + } + openSettings() async{ + openAppSettings(); + } } diff --git a/pubspec.yaml b/pubspec.yaml index 875fd8b7..26fafc7f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -152,7 +152,7 @@ dependencies: after_layout: ^1.0.7 twilio_programmable_video: ^0.5.0+3 flutter_tts: ^1.2.6 - + vibration: ^1.7.2 speech_to_text: path: speech_to_text From 857fc813cd93e491a4b88b882969f378285667d9 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Wed, 25 Nov 2020 11:40:49 +0300 Subject: [PATCH 08/20] button feedback --- lib/services/permission/permission_service.dart | 15 +++++++++++---- lib/widgets/buttons/button.dart | 2 +- lib/widgets/buttons/defaultButton.dart | 2 +- lib/widgets/buttons/floatingActionButton.dart | 2 +- lib/widgets/buttons/mini_button.dart | 2 +- lib/widgets/buttons/secondary_button.dart | 2 +- 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/services/permission/permission_service.dart b/lib/services/permission/permission_service.dart index 7123529c..b1779c5a 100644 --- a/lib/services/permission/permission_service.dart +++ b/lib/services/permission/permission_service.dart @@ -23,12 +23,19 @@ class PermissionService extends BaseService { isVibrationEnabled() { return storage.getItem('isVibration') ==null ? false :true; } - vibrate() async{ + vibrate(callback, context) async{ + + if (callback == null) + return null; if(isVibrationEnabled() ==true){ - if (await Vibration.hasVibrator()) { - Vibration.vibrate(duration: 100); - } + if (await Vibration.hasVibrator()) { + Vibration.vibrate(duration: 100); + callback(); + } + }else{ + callback(); } + } diff --git a/lib/widgets/buttons/button.dart b/lib/widgets/buttons/button.dart index 597106c9..457a1d42 100644 --- a/lib/widgets/buttons/button.dart +++ b/lib/widgets/buttons/button.dart @@ -90,7 +90,7 @@ class _ButtonState extends State