fix loader in prescriptions_page

merge-requests/967/head
RoaaGhali98 4 years ago
parent ce978db2dd
commit e10c07f6a4

@ -18,6 +18,8 @@ import 'package:doctor_app_flutter/core/model/patient/prescription/prescription_
import 'package:doctor_app_flutter/core/model/patient/prescription/prescription_res_model.dart'; import 'package:doctor_app_flutter/core/model/patient/prescription/prescription_res_model.dart';
import 'package:doctor_app_flutter/core/model/patient/radiology/radiology_res_model.dart'; import 'package:doctor_app_flutter/core/model/patient/radiology/radiology_res_model.dart';
import 'package:doctor_app_flutter/core/model/patient/vital_sign/vital_sign_res_model.dart'; import 'package:doctor_app_flutter/core/model/patient/vital_sign/vital_sign_res_model.dart';
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
import 'package:flutter/cupertino.dart';
import '../../locator.dart'; import '../../locator.dart';
import 'base_view_model.dart'; import 'base_view_model.dart';
@ -101,16 +103,37 @@ class PatientViewModel extends BaseViewModel {
setState(ViewState.Idle); setState(ViewState.Idle);
} }
Future getOutPatientPrescriptions(patient) async { Future getOutPatientPrescriptions(patient, {bool isLocalBusy = false, BuildContext context, PatiantInformtion patientInformation}) async {
setState(ViewState.Busy); if (isLocalBusy) {
setState(ViewState.BusyLocal);
} else {
setState(ViewState.Busy);
}
GifLoaderDialogUtils.showMyDialog(context);
await _patientService.getOutPatientPrescriptions(patient); await _patientService.getOutPatientPrescriptions(patient);
GifLoaderDialogUtils.hideDialog(context);
if (_patientService.hasError) { if (_patientService.hasError) {
error = _patientService.error; error = _patientService.error;
setState(ViewState.Error); if (isLocalBusy) {
setState(ViewState.ErrorLocal);
} else {
setState(ViewState.Error);
}
} else } else
setState(ViewState.Idle); setState(ViewState.Idle);
} }
// async {
// setState(ViewState.Busy);
// await _patientService.getOutPatientPrescriptions(patient);
// if (_patientService.hasError) {
// error = _patientService.error;
// setState(ViewState.Error);
// } else
// setState(ViewState.Idle);
// }
Future getInPatientPrescriptions(patient) async { Future getInPatientPrescriptions(patient) async {
setState(ViewState.Busy); setState(ViewState.Busy);
await _patientService.getInPatientPrescriptions(patient); await _patientService.getInPatientPrescriptions(patient);

@ -1,3 +1,4 @@
import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart';
import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart';
@ -26,6 +27,7 @@ class PrescriptionsPage extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final routeArgs = ModalRoute.of(context).settings.arguments as Map; final routeArgs = ModalRoute.of(context).settings.arguments as Map;
PatientViewModel patientViewModel;
PatiantInformtion patient = routeArgs['patient']; PatiantInformtion patient = routeArgs['patient'];
String patientType = routeArgs['patientType']; String patientType = routeArgs['patientType'];
String arrivalType = routeArgs['arrivalType']; String arrivalType = routeArgs['arrivalType'];
@ -33,9 +35,16 @@ class PrescriptionsPage extends StatelessWidget {
bool isFromLiveCare = routeArgs['isFromLiveCare']; bool isFromLiveCare = routeArgs['isFromLiveCare'];
bool isSelectInpatient = routeArgs['isSelectInpatient']; bool isSelectInpatient = routeArgs['isSelectInpatient'];
return BaseView<PrescriptionViewModel>( return BaseView<PrescriptionViewModel>(
onModelReady: (model) => patient.admissionNo == null onModelReady: (model) async {
? model.getPrescriptions(patient, patientType: patientType) await model.getOutPatientPrescriptions(
: model.getMedicationForInPatient(patient), patient.admissionNo == null
? model.getPrescriptions(patient, patientType: patientType)
: model.getMedicationForInPatient(patient),
isLocalBusy: false,
context: context,
patientInformation: patient
);
},
builder: (_, model, w) => AppScaffold( builder: (_, model, w) => AppScaffold(
baseViewModel: model, baseViewModel: model,
isShowAppBar: true, isShowAppBar: true,
@ -118,29 +127,24 @@ class PrescriptionsPage extends StatelessWidget {
), ),
), ),
), ),
child: Container( child: Column(
child: Column( children: [
children: [ DoctorCard(
AppText( doctorName:
model.prescriptionsList[index].despensedStatus, model.prescriptionsList[index].doctorName,
), profileUrl: model
DoctorCard( .prescriptionsList[index].doctorImageURL,
doctorName: branch: model.prescriptionsList[index].name,
model.prescriptionsList[index].doctorName, clinic: model.prescriptionsList[index]
profileUrl: model .clinicDescription,
.prescriptionsList[index].doctorImageURL, isPrescriptions: true,
branch: model.prescriptionsList[index].name, appointmentDate:
clinic: model.prescriptionsList[index] AppDateUtils.getDateTimeFromServerFormat(
.clinicDescription, model.prescriptionsList[index]
isPrescriptions: true, .appointmentDate,
appointmentDate:
AppDateUtils.getDateTimeFromServerFormat(
model.prescriptionsList[index]
.appointmentDate,
),
), ),
], ),
), ],
))), ))),
if (model.prescriptionsList.isEmpty && if (model.prescriptionsList.isEmpty &&
patient.patientStatusType != 43) patient.patientStatusType != 43)

Loading…
Cancel
Save