From 29336a9ef32f56ca001ab85079a3d246c03ae998 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Mon, 20 Sep 2021 15:14:52 +0300 Subject: [PATCH] fix the design of all sick leave --- lib/config/localized_values.dart | 2 +- .../sick_leave/sickleave_service.dart | 10 +- lib/core/viewModel/sick_leave_view_model.dart | 4 +- lib/screens/sick-leave/add-sickleave.dart | 423 ++++++++++-------- lib/screens/sick-leave/sick_leave.dart | 30 +- 5 files changed, 248 insertions(+), 221 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 46af5dea..d6a06be3 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -249,7 +249,7 @@ const Map> localizedValues = { "extended": {"en": "Extended", "ar": "تمديد"}, "pending": {"en": "Pending", "ar": "قيد الانتظار"}, "leave-start-date": {"en": "Leave start date", "ar": "تاريخ بدء المغادرة"}, - "days-sick-leave": {"en": "DAYS OF SICK LEAVE", "ar": "أيام الإجازة المرضية"}, + "days-sick-leave": {"en": "Leave Days: ", "ar": "أيام الإجازة "}, "extend": {"en": "Extend", "ar": "تمديد"}, "extend-sickleave": {"en": "EXTEND SICK LEAVE", "ar": "قم بتمديد الإجازة المرضية"}, "chiefComplaintLength": { diff --git a/lib/core/service/patient_medical_file/sick_leave/sickleave_service.dart b/lib/core/service/patient_medical_file/sick_leave/sickleave_service.dart index e1fca881..8b1438f0 100644 --- a/lib/core/service/patient_medical_file/sick_leave/sickleave_service.dart +++ b/lib/core/service/patient_medical_file/sick_leave/sickleave_service.dart @@ -55,20 +55,16 @@ class SickLeaveService extends BaseService { } Future addSickLeave(AddSickLeaveRequest addSickLeaveRequest) async { - // addSickLeaveRequest.appointmentNo = '2016054661'; - // addSickLeaveRequest.patientMRN = '3120746'; hasError = false; + if(_sickLeaveResponse!= null) _sickLeaveResponse.clear(); await baseAppClient.post( ADD_SICK_LEAVE, onSuccess: (dynamic response, int statusCode) { - _sickLeaveResponse = response; - return Future.value(response); }, onFailure: (String error, int statusCode) { - DrAppToastMsg.showErrorToast(error); - // hasError = true; - // super.error = error; + hasError = true; + super.error = error; }, body: addSickLeaveRequest.toJson(), ); diff --git a/lib/core/viewModel/sick_leave_view_model.dart b/lib/core/viewModel/sick_leave_view_model.dart index e80318f6..a4332534 100644 --- a/lib/core/viewModel/sick_leave_view_model.dart +++ b/lib/core/viewModel/sick_leave_view_model.dart @@ -22,11 +22,11 @@ class SickLeaveViewModel extends BaseViewModel { get getAllSIckLeavePatient => [..._sickLeaveService.getAllSickLeavePatient, ..._sickLeaveService.getAllSickLeaveDoctor]; Future addSickLeave(AddSickLeaveRequest addSickLeaveRequest) async { - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _sickLeaveService.addSickLeave(addSickLeaveRequest); if (_sickLeaveService.hasError) { error = _sickLeaveService.error; - setState(ViewState.Error); + setState(ViewState.ErrorLocal); } else setState(ViewState.Idle); } diff --git a/lib/screens/sick-leave/add-sickleave.dart b/lib/screens/sick-leave/add-sickleave.dart index fb0968b9..d80b44bd 100644 --- a/lib/screens/sick-leave/add-sickleave.dart +++ b/lib/screens/sick-leave/add-sickleave.dart @@ -1,22 +1,27 @@ +import 'package:cached_network_image/cached_network_image.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/model/sick_leave/sick_leave_patient_model.dart'; import 'package:doctor_app_flutter/core/service/AnalyticsService.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/sick_leave_view_model.dart'; +import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/locator.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/models/sickleave/get_all_sickleave_response.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/sick-leave/sick_leave.dart'; import 'package:doctor_app_flutter/util/date-utils.dart'; +import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/add-order/addNewOrder.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/patient-profile-app-bar.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/card_with_bg_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/error_message.dart'; import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/user-guid/CusomRow.dart'; import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; @@ -33,52 +38,62 @@ class AddSickLeavScreen extends StatelessWidget { patient = routeArgs['patient']; bool isInpatient = routeArgs['isInpatient']; return BaseView( - onModelReady: (model) async { - await model - .getSickLeavePatient(patient.patientMRN ?? patient.patientId); - await model - .getSickLeaveDoctor(patient.patientMRN ?? patient.patientId); - }, - builder: (_, model, w) => AppScaffold( - baseViewModel: model, - isShowAppBar: true, - backgroundColor: Colors.grey[100], - appBar: PatientProfileAppBar( - patient, - isInpatient: isInpatient, - ), - body: SingleChildScrollView( - child: Column(children: [ - patient.patientStatusType == 43 - ? Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.all(10), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox(height: SizeConfig.isHeightVeryShort?30:SizeConfig.isHeightShort?35: 10,), - if (!projectsProvider.isArabic) - AppText( - TranslationBase.of(context).patient, - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() * (SizeConfig.isWidthLarge? 3: 4), - fontWeight: FontWeight.w700, - letterSpacing:-0.72, - color: Color(0xFF2E303A), - - ), - AppText(TranslationBase.of(context).sickLeave, - fontSize:SizeConfig.getTextMultiplierBasedOnWidth() * (SizeConfig.isWidthLarge? 6: 6), - fontWeight: FontWeight.bold, - letterSpacing:-1.44, - color: Color(0xFF2E303A), - ), - ], - )), - - AddNewOrder(label: TranslationBase.of(context) - .noSickLeaveApplied, onTap: () async { + onModelReady: (model) async { + await model + .getSickLeavePatient(patient.patientMRN ?? patient.patientId); + await model.getSickLeaveDoctor(patient.patientMRN ?? patient.patientId); + }, + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + isShowAppBar: true, + backgroundColor: Colors.grey[100], + appBar: PatientProfileAppBar( + patient, + isInpatient: isInpatient, + ), + body: Column( + children: [ + patient.patientStatusType == 43 + ? Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.all(10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: SizeConfig.isHeightVeryShort + ? 30 + : SizeConfig.isHeightShort + ? 35 + : 10, + ), + if (!projectsProvider.isArabic) + AppText( + TranslationBase.of(context).patient, + fontSize: + SizeConfig.getTextMultiplierBasedOnWidth() * + (SizeConfig.isWidthLarge ? 3 : 4), + fontWeight: FontWeight.w700, + letterSpacing: -0.72, + color: Color(0xFF2E303A), + ), + AppText( + TranslationBase.of(context).sickLeave, + fontSize: + SizeConfig.getTextMultiplierBasedOnWidth() * + (SizeConfig.isWidthLarge ? 6 : 6), + fontWeight: FontWeight.bold, + letterSpacing: -1.44, + color: Color(0xFF2E303A), + ), + ], + ), + ), + AddNewOrder( + label: TranslationBase.of(context).noSickLeaveApplied, + onTap: () async { await locator().logEvent( eventCategory: "Add Sick Leave Screen" "Leave Screen", @@ -89,155 +104,170 @@ class AddSickLeavScreen extends StatelessWidget { false, ); }), - ], - ) - : SizedBox(), - model.getAllSIckLeavePatient.length > 0 - ? ListView.builder( + ], + ) + : SizedBox(), + model.getAllSIckLeavePatient.length > 0 + ? Expanded( + child: FractionallySizedBox( + widthFactor: 0.95, + child: Expanded( + child: ListView.builder( scrollDirection: Axis.vertical, shrinkWrap: true, itemCount: model.getAllSIckLeavePatient.length, itemBuilder: (BuildContext ctxt, int index) { - var item = model.getAllSIckLeavePatient[index]; - return Container( - padding: EdgeInsets.all(10), - child: Row( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - Expanded( - flex: 4, - child: Wrap( - // mainAxisAlignment: - // MainAxisAlignment.start, - children: [ - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - padding: EdgeInsets.all(3), - child: AppText( - item = model.getAllSIckLeavePatient[index].doctorName ?? "", - // item.status == 1 - // ? TranslationBase.of( - // context) - // .hold - // : item.status == 2 - // ? TranslationBase - // .of( - // context) - // .active - // : TranslationBase - // .of(context) - // .all, - fontWeight: - FontWeight.bold, - // color: item.status == 1 - // ? Colors.yellow[800] - // : item.status == 2 - // ? Colors.green - // : Colors.black, - color: Colors.red, - ), - ), - Row( - children: [ - AppText(TranslationBase - .of(context) - .daysSickleave + - ": "), - AppText( - (item.sickLeaveDays - .toString() != - null && - item.sickLeaveDays - .toString() != - "null") - ? item.sickLeaveDays - .toString() - : item.noOfDays - .toString(), - fontWeight: - FontWeight.bold, - ), - ], - ), - Row( + SickLeavePatientModel item = + model.getAllSIckLeavePatient[index]; + return Column( + children: [ + CardWithBgWidget( + padding: 0, + marginLeft: 10, + marginSymmetric: 10, + hasBorder: false, + bgColor: Colors.black, + widget: Container( + color: Colors.white, + padding: EdgeInsets.all(10), + child: InkWell( + child: Column( + children: [ + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, children: [ - AppText( - TranslationBase.of( - context) - .startDate + - ' ' ?? - "", - ), - Flexible( + Expanded( + // width: MediaQuery.of(context).size.width*0.51, child: AppText( - AppDateUtils.getDayMonthYearDateFormatted(item - .startDate - .contains( - "/Date(") - ? AppDateUtils - .convertStringToDate(item - .startDate) - : DateTime.parse( - item.startDate)), - fontWeight: - FontWeight.bold, + Helpers.capitalize( + item.doctorName ?? ""), + fontSize: 16, + color: Color(0xff2e303a), + fontWeight: FontWeight.w700, + fontFamily: 'Poppins', + textOverflow: + TextOverflow.ellipsis, ), - ) - ], - ), - Row( - children: [ - AppText( - TranslationBase.of( - context) - .endDate + - ' ' ?? - "", ), - Flexible( - child: AppText( - AppDateUtils.getDayMonthYearDateFormatted(item - .startDate - .contains( - "/Date(") - ? AppDateUtils.convertStringToDate( - item.endDate ?? - "") - .add(Duration( - days: item.noOfDays ?? - item - .sickLeaveDays)) - : DateTime.parse( - item.startDate ?? "") - .add(Duration(days: item.noOfDays ?? ""))), - fontWeight: - FontWeight.bold, + ]), + Row( + children: [ + ClipRRect( + borderRadius: + BorderRadius.circular(50.0), + child: CachedNetworkImage( + imageUrl: item.doctorImageURL ?? + "https://hmgwebservices.com/Images/MobileImages/DUBAI/unkown.png", + height: 30, + width: 30, + errorWidget: + (context, url, error) => + AppText( + 'No Image', + fontSize: 10, + ), + ), + ), + SizedBox( + width: 10, + ), + Column( + children: [ + CustomRow( + label: TranslationBase.of( + context) + .daysSickleave + + ": ", + value: (item.sickLeaveDays + .toString() != + null && + item.sickLeaveDays + .toString() != + "null") + ? item.sickLeaveDays + .toString() + : item.noOfDays + .toString(), + ), + CustomRow( + label: TranslationBase.of( + context) + .startDate + + ' ' ?? + "", + value: AppDateUtils + .getDayMonthYearDateFormatted( + item.startDate + .contains("/Date(") + ? AppDateUtils + .convertStringToDate( + item.startDate) + : DateTime.parse( + item.startDate), + ), ), - ) - ], - ), - ], - ), - SizedBox( - width: 20, - ), - ], + CustomRow( + label: TranslationBase.of( + context) + .endDate + + ' ' ?? + "", + value: AppDateUtils + .getDayMonthYearDateFormatted( + item.startDate + .contains("/Date(") + ? AppDateUtils + .convertStringToDate( + item.endDate ?? + "") + .add( + Duration( + days: item + .noOfDays ?? + item.sickLeaveDays), + ) + : DateTime.parse( + item.startDate ?? + "") + .add( + Duration( + days: + item.noOfDays ?? + ""), + ), + ), + ), + ], + crossAxisAlignment: + CrossAxisAlignment.start, + ), + ], + ), + ], + ), ), ), - ], - )); - }) - : patient.patientStatusType != 43 - ? ErrorMessage( - error: TranslationBase.of(context) - .noSickLeave, + ), + ], + ); + }), + ), + ), ) - : SizedBox() - ])))); + : patient.patientStatusType != 43 + ? ErrorMessage( + error: TranslationBase.of(context).noSickLeave, + ) + : SizedBox(), + SizedBox( + height: 100, + ) + ]), + ), + ); } openSickLeave(BuildContext context, isExtend, @@ -248,18 +278,19 @@ class AddSickLeavScreen extends StatelessWidget { // return new Container( // child: Navigator.push( - context, - FadePage( - page: SickLeaveScreen( - appointmentNo: isExtend == true - ? extendedData.appointmentNo - : patient.appointmentNo, - //extendedData.appointmentNo, - patientMRN: isExtend == true - ? extendedData.patientMRN - : patient.patientMRN, - isExtended: isExtend, - extendedData: extendedData, - patient: patient))); + context, + FadePage( + page: SickLeaveScreen( + appointmentNo: isExtend == true + ? extendedData.appointmentNo + : patient.appointmentNo, + //extendedData.appointmentNo, + patientMRN: + isExtend == true ? extendedData.patientMRN : patient.patientMRN, + isExtended: isExtend, + extendedData: extendedData, + patient: patient), + ), + ); } } diff --git a/lib/screens/sick-leave/sick_leave.dart b/lib/screens/sick-leave/sick_leave.dart index be8e38f1..3eb51a01 100644 --- a/lib/screens/sick-leave/sick_leave.dart +++ b/lib/screens/sick-leave/sick_leave.dart @@ -16,6 +16,7 @@ import 'package:doctor_app_flutter/util/translations_delegate_base.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/buttons/app_buttons_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/app_text_form_field.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -348,24 +349,18 @@ class _SickLeaveScreenState extends State { } else if (addSickLeave.startDate == null) { DrAppToastMsg.showErrorToast(TranslationBase.of(context).pleaseEnterDate); } else { + GifLoaderDialogUtils.showMyDialog(context); addSickLeave.patientMRN = widget.patient.patientMRN.toString(); addSickLeave.appointmentNo = widget.patient.appointmentNo.toString(); await model2.addSickLeave(addSickLeave); + if(model2.state == ViewState.ErrorLocal){ + Helpers.showErrorToast(model2.error); + } else { + DrAppToastMsg.showSuccesToast(TranslationBase.of(context).replySuccessfully); + } - if (model2.sickleaveResponse['SickLeavesList']['success'] != null) - DrAppToastMsg.showSuccesToast( - model2.sickleaveResponse['SickLeavesList']['success']); + GifLoaderDialogUtils.hideDialog(context); } - // Navigator.push( - // context, - // MaterialPageRoute(builder: (context) => AddSickLeavScreen()), - // ); - - // Navigator.of(context).popUntil((route) { - // return route.settings.name == PATIENTS_PROFILE; - // }); - // Navigator.of(context) - // .pushNamed(ADD_SICKLEAVE, arguments: {'patient': widget.patient}); } catch (err) { print(err); } @@ -402,9 +397,14 @@ class _SickLeaveScreenState extends State { } else { addSickLeave.patientMRN = widget.patient.patientMRN.toString(); addSickLeave.appointmentNo = widget.patient.appointmentNo.toString(); - await model2.addSickLeave(addSickLeave).then((value) => print(value)); + await model2.addSickLeave(addSickLeave); + if(model2.state == ViewState.ErrorLocal){ + Helpers.showErrorToast(model2.error); + } else { + DrAppToastMsg.showSuccesToast(TranslationBase.of(context).replySuccessfully); + } - DrAppToastMsg.showSuccesToast(model2.sickleaveResponse['ListSickLeavesToExtent']['success']); + GifLoaderDialogUtils.hideDialog(context); Navigator.of(context).popUntil((route) { return route.settings.name == PATIENTS_PROFILE; });