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/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/widgets/shared/loader/gif_loader_dialog_utils.dart';
import 'package:flutter/cupertino.dart';
import '../../locator.dart';
import 'base_view_model.dart';
@ -101,16 +103,37 @@ class PatientViewModel extends BaseViewModel {
setState(ViewState.Idle);
}
Future getOutPatientPrescriptions(patient) async {
setState(ViewState.Busy);
Future getOutPatientPrescriptions(patient, {bool isLocalBusy = false, BuildContext context, PatiantInformtion patientInformation}) async {
if (isLocalBusy) {
setState(ViewState.BusyLocal);
} else {
setState(ViewState.Busy);
}
GifLoaderDialogUtils.showMyDialog(context);
await _patientService.getOutPatientPrescriptions(patient);
GifLoaderDialogUtils.hideDialog(context);
if (_patientService.hasError) {
error = _patientService.error;
setState(ViewState.Error);
if (isLocalBusy) {
setState(ViewState.ErrorLocal);
} else {
setState(ViewState.Error);
}
} else
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 {
setState(ViewState.Busy);
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/model/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
@ -26,6 +27,7 @@ class PrescriptionsPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final routeArgs = ModalRoute.of(context).settings.arguments as Map;
PatientViewModel patientViewModel;
PatiantInformtion patient = routeArgs['patient'];
String patientType = routeArgs['patientType'];
String arrivalType = routeArgs['arrivalType'];
@ -33,9 +35,16 @@ class PrescriptionsPage extends StatelessWidget {
bool isFromLiveCare = routeArgs['isFromLiveCare'];
bool isSelectInpatient = routeArgs['isSelectInpatient'];
return BaseView<PrescriptionViewModel>(
onModelReady: (model) => patient.admissionNo == null
? model.getPrescriptions(patient, patientType: patientType)
: model.getMedicationForInPatient(patient),
onModelReady: (model) async {
await model.getOutPatientPrescriptions(
patient.admissionNo == null
? model.getPrescriptions(patient, patientType: patientType)
: model.getMedicationForInPatient(patient),
isLocalBusy: false,
context: context,
patientInformation: patient
);
},
builder: (_, model, w) => AppScaffold(
baseViewModel: model,
isShowAppBar: true,
@ -118,29 +127,24 @@ class PrescriptionsPage extends StatelessWidget {
),
),
),
child: Container(
child: Column(
children: [
AppText(
model.prescriptionsList[index].despensedStatus,
),
DoctorCard(
doctorName:
model.prescriptionsList[index].doctorName,
profileUrl: model
.prescriptionsList[index].doctorImageURL,
branch: model.prescriptionsList[index].name,
clinic: model.prescriptionsList[index]
.clinicDescription,
isPrescriptions: true,
appointmentDate:
AppDateUtils.getDateTimeFromServerFormat(
model.prescriptionsList[index]
.appointmentDate,
),
child: Column(
children: [
DoctorCard(
doctorName:
model.prescriptionsList[index].doctorName,
profileUrl: model
.prescriptionsList[index].doctorImageURL,
branch: model.prescriptionsList[index].name,
clinic: model.prescriptionsList[index]
.clinicDescription,
isPrescriptions: true,
appointmentDate:
AppDateUtils.getDateTimeFromServerFormat(
model.prescriptionsList[index]
.appointmentDate,
),
],
),
),
],
))),
if (model.prescriptionsList.isEmpty &&
patient.patientStatusType != 43)

Loading…
Cancel
Save