From 88ee50f7cb467e2285a48aed8bb01e5a31c8426a Mon Sep 17 00:00:00 2001 From: mosazaid Date: Sun, 3 Jan 2021 12:21:17 +0200 Subject: [PATCH] change make referral page loading behaviour --- .../viewModel/patient-referral-viewmodel.dart | 6 +++--- .../referral/refer-patient-screen.dart | 19 +++++++++++++++---- lib/widgets/shared/app_loader_widget.dart | 5 +++-- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/lib/core/viewModel/patient-referral-viewmodel.dart b/lib/core/viewModel/patient-referral-viewmodel.dart index e5657883..251407ef 100644 --- a/lib/core/viewModel/patient-referral-viewmodel.dart +++ b/lib/core/viewModel/patient-referral-viewmodel.dart @@ -41,7 +41,7 @@ class PatientReferralViewModel extends BaseViewModel { } Future getBranches() async { - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _referralPatientService.getProjectsList(); if (_referralPatientService.hasError) { error = _referralPatientService.error; @@ -52,7 +52,7 @@ class PatientReferralViewModel extends BaseViewModel { } Future getClinics(int projectId) async { - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _referralPatientService.getClinicsList(projectId); await _referralPatientService.getProjectInfo(projectId); if (_referralPatientService.hasError) { @@ -63,7 +63,7 @@ class PatientReferralViewModel extends BaseViewModel { } Future getClinicDoctors(String clinicId) async { - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _referralPatientService.getDoctorsList(clinicId); if (_referralPatientService.hasError) { error = _referralPatientService.error; diff --git a/lib/screens/patients/profile/referral/refer-patient-screen.dart b/lib/screens/patients/profile/referral/refer-patient-screen.dart index 69540176..e46ab6d5 100644 --- a/lib/screens/patients/profile/referral/refer-patient-screen.dart +++ b/lib/screens/patients/profile/referral/refer-patient-screen.dart @@ -10,6 +10,7 @@ import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/patient-page-header-widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_loader_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/dialogs/dailog-list-select.dart'; @@ -55,7 +56,8 @@ class _PatientMakeReferralScreenState extends State { final screenSize = MediaQuery.of(context).size; return BaseView( - onModelReady: (model) => model.getMasterLookup(MasterKeysService.physiotherapyGoals), + onModelReady: (model) => + model.getMasterLookup(MasterKeysService.physiotherapyGoals), builder: (_, model, w) => AppScaffold( baseViewModel: model, appBarTitle: TranslationBase.of(context).referPatient, @@ -64,6 +66,14 @@ class _PatientMakeReferralScreenState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ + if (model.state == ViewState.BusyLocal) + Container( + color: Colors.white, + width: 50, + height: 50, + child: AppLoaderWidget( + containerColor: Colors.white, + )), Column( children: [ PatientPageHeaderWidget(patient), @@ -333,14 +343,15 @@ class _PatientMakeReferralScreenState extends State { _remarksController.text == null) return; model .makeReferral( - patient, + patient, appointmentDate.toIso8601String(), _selectedBranch['ID'], _selectedClinic['ClinicID'], _selectedDoctor['DoctorID'], _remarksController.text) .then((_) { - DrAppToastMsg.showSuccesToast(TranslationBase.of(context).referralSuccessMsg); + DrAppToastMsg.showSuccesToast( + TranslationBase.of(context).referralSuccessMsg); Navigator.pop(context); }); }, @@ -368,7 +379,7 @@ class _PatientMakeReferralScreenState extends State { setState(() { appointmentDate = picked; }); - /* model + /* model .getPatientArrivalList(DateUtils.convertStringToDateFormat( appointmentDate.toString(), "yyyy-MM-dd")) .then((_) { diff --git a/lib/widgets/shared/app_loader_widget.dart b/lib/widgets/shared/app_loader_widget.dart index aeb7f5b2..65a5f231 100644 --- a/lib/widgets/shared/app_loader_widget.dart +++ b/lib/widgets/shared/app_loader_widget.dart @@ -9,9 +9,10 @@ import 'package:progress_hud_v2/progress_hud.dart'; *@desc: AppLoaderWidget to create loader */ class AppLoaderWidget extends StatefulWidget { - AppLoaderWidget({Key key, this.title}) : super(key: key); + AppLoaderWidget({Key key, this.title, this.containerColor}) : super(key: key); final String title; + final Color containerColor; @override _AppLoaderWidgetState createState() => new _AppLoaderWidgetState(); @@ -30,7 +31,7 @@ class _AppLoaderWidgetState extends State { *@desc: create loader the desing */ _progressHUD = new ProgressHUD( - backgroundColor: Colors.black12, + backgroundColor: widget.containerColor == null ? Colors.black12 : widget.containerColor, color: Colors.black, // containerColor: Colors.blue, borderRadius: 5.0,