From aaca94e93cd50b3d3b21982dfaab2c02efde04fa Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Mon, 20 Sep 2021 10:34:59 +0300 Subject: [PATCH 1/9] first step form sick leave --- lib/config/config.dart | 4 +- lib/screens/sick-leave/add-sickleave.dart | 392 +++++++++------------- 2 files changed, 166 insertions(+), 230 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index b8e34330..407d4ff6 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -5,8 +5,8 @@ const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z &'\"]"; const ONLY_DATE = "[0-9/]"; const BASE_URL_LIVE_CARE = 'https://livecare.hmg.com/'; -const BASE_URL = 'https://hmgwebservices.com/'; -// const BASE_URL = 'https://uat.hmgwebservices.com/'; +// const BASE_URL = 'https://hmgwebservices.com/'; +const BASE_URL = 'https://uat.hmgwebservices.com/'; const PHARMACY_ITEMS_URL = "Services/Lists.svc/REST/GetPharmcyItems_Region_enh"; const PHARMACY_LIST_URL = "Services/Patients.svc/REST/GetPharmcyList"; const PATIENT_PROGRESS_NOTE_URL = "Services/DoctorApplication.svc/REST/GetProgressNoteForInPatient"; diff --git a/lib/screens/sick-leave/add-sickleave.dart b/lib/screens/sick-leave/add-sickleave.dart index 3cdeb180..fb0968b9 100644 --- a/lib/screens/sick-leave/add-sickleave.dart +++ b/lib/screens/sick-leave/add-sickleave.dart @@ -11,9 +11,11 @@ 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/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/errors/error_message.dart'; import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'; import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; @@ -56,250 +58,184 @@ class AddSickLeavScreen extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ + SizedBox(height: SizeConfig.isHeightVeryShort?30:SizeConfig.isHeightShort?35: 10,), if (!projectsProvider.isArabic) - AppText( - TranslationBase.of(context).patient, - fontWeight: FontWeight.bold, - ), AppText( - TranslationBase.of(context).sickLeave, - fontSize: 24, + 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), ), ], )), - InkWell( - onTap: () async { - await locator().logEvent( - eventCategory: "Add Sick Leave Screen" - "Leave Screen", - eventAction: "apply For Sick Leave", - ); - openSickLeave( - context, - false, - ); - }, - child: Container( - width: SizeConfig.screenWidth, - margin: EdgeInsets.only( - left: 20, right: 20, top: 10, bottom: 10), - padding: EdgeInsets.all(20), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: HexColor('#EAEAEA')), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Container( - child: Container( - decoration: BoxDecoration( - color: Colors.grey, - borderRadius: - BorderRadius.circular(10)), - padding: EdgeInsets.all(3), - child: IconButton( - icon: Icon( - Icons.add, - size: 35, - color: Colors.white, - ), - // onPressed: () { - // openSickLeave( - // context, - // false, - // ); - // }, - ), - )), - Padding( - child: AppText( - TranslationBase.of(context) - .noSickLeaveApplied, - fontWeight: FontWeight.bold, - fontFamily: 'Poppins', - fontSize: 16, - textAlign: TextAlign.center, - color: HexColor('#7E7E7E')), - padding: EdgeInsets.all(10), - ), - ], - )), - ), + + AddNewOrder(label: TranslationBase.of(context) + .noSickLeaveApplied, onTap: () async { + await locator().logEvent( + eventCategory: "Add Sick Leave Screen" + "Leave Screen", + eventAction: "apply For Sick Leave", + ); + openSickLeave( + context, + false, + ); + }), ], ) : SizedBox(), model.getAllSIckLeavePatient.length > 0 - ? Column( - children: model.getAllSIckLeavePatient - .map((SickLeavePatientModel item) { - return RoundedContainer( - margin: EdgeInsets.all(10), - child: Column( - children: [ - Container( - // decoration: BoxDecoration( - // border: Border( - // left: BorderSide( - // // color: item.status == 1 - // // ? Colors.yellow[800] - // // : item.status == 2 - // // ? Colors.green - // // : Colors.black, - // color: Colors.red, - // width: 5.0, - // ))), - padding: EdgeInsets.all(10), - child: Row( - mainAxisAlignment: - MainAxisAlignment.start, + ? 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: [ - Expanded( - flex: 4, - child: Wrap( - // mainAxisAlignment: - // MainAxisAlignment.start, - children: [ - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - padding: EdgeInsets.all(3), - child: AppText( - item.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( - children: [ - AppText( - TranslationBase.of( - context) - .startDate + - ' ' ?? - "", - ), - Flexible( - child: AppText( - AppDateUtils.getDayMonthYearDateFormatted(item - .startDate - .contains( - "/Date(") - ? AppDateUtils - .convertStringToDate(item - .startDate) - : DateTime.parse( - item.startDate)), - fontWeight: - FontWeight.bold, - ), - ) - ], + 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( + children: [ + AppText( + TranslationBase.of( + context) + .startDate + + ' ' ?? + "", + ), + Flexible( + child: AppText( + AppDateUtils.getDayMonthYearDateFormatted(item + .startDate + .contains( + "/Date(") + ? AppDateUtils + .convertStringToDate(item + .startDate) + : DateTime.parse( + item.startDate)), + fontWeight: + FontWeight.bold, ), - 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: [ + 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, ), - ], - ), - SizedBox( - width: 20, - ), - ], - ), + ) + ], + ), + ], + ), + SizedBox( + width: 20, ), ], - )), - ], - )); - }).toList(), - ) + ), + ), + ], + )); + }) : patient.patientStatusType != 43 - ? Center( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox( - height: 100, - ), - Image.asset('assets/images/no-data.png'), - Padding( - padding: const EdgeInsets.all(8.0), - child: AppText( - TranslationBase.of(context).noSickLeave), - ) - ], - ), - ) + ? ErrorMessage( + error: TranslationBase.of(context) + .noSickLeave, + ) : SizedBox() ])))); } From 29336a9ef32f56ca001ab85079a3d246c03ae998 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Mon, 20 Sep 2021 15:14:52 +0300 Subject: [PATCH 2/9] 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; }); From ff07686bf7646ec4181dca4057aa5c9ee7d5e4be Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Mon, 20 Sep 2021 17:34:41 +0300 Subject: [PATCH 3/9] fix sick leave design --- lib/screens/sick-leave/add-sickleave.dart | 11 +- lib/screens/sick-leave/sick_leave.dart | 545 +++++++++--------- .../text_fields/app-textfield-custom.dart | 2 - 3 files changed, 273 insertions(+), 285 deletions(-) diff --git a/lib/screens/sick-leave/add-sickleave.dart b/lib/screens/sick-leave/add-sickleave.dart index d80b44bd..dc52b86e 100644 --- a/lib/screens/sick-leave/add-sickleave.dart +++ b/lib/screens/sick-leave/add-sickleave.dart @@ -129,7 +129,7 @@ class AddSickLeavScreen extends StatelessWidget { bgColor: Colors.black, widget: Container( color: Colors.white, - padding: EdgeInsets.all(10), + padding: EdgeInsets.all(20), child: InkWell( child: Column( children: [ @@ -144,7 +144,7 @@ class AddSickLeavScreen extends StatelessWidget { child: AppText( Helpers.capitalize( item.doctorName ?? ""), - fontSize: 16, + fontSize: 18, color: Color(0xff2e303a), fontWeight: FontWeight.w700, fontFamily: 'Poppins', @@ -153,6 +153,7 @@ class AddSickLeavScreen extends StatelessWidget { ), ), ]), + SizedBox(height: 10,), Row( children: [ ClipRRect( @@ -181,6 +182,8 @@ class AddSickLeavScreen extends StatelessWidget { context) .daysSickleave + ": ", + labelSize: SizeConfig.getTextMultiplierBasedOnWidth() * 3.3, + valueSize: SizeConfig.getTextMultiplierBasedOnWidth() * 4, value: (item.sickLeaveDays .toString() != null && @@ -198,6 +201,8 @@ class AddSickLeavScreen extends StatelessWidget { .startDate + ' ' ?? "", + labelSize: SizeConfig.getTextMultiplierBasedOnWidth() * 3.3, + valueSize: SizeConfig.getTextMultiplierBasedOnWidth() * 4, value: AppDateUtils .getDayMonthYearDateFormatted( item.startDate @@ -215,6 +220,8 @@ class AddSickLeavScreen extends StatelessWidget { .endDate + ' ' ?? "", + labelSize: SizeConfig.getTextMultiplierBasedOnWidth() * 3.3, + valueSize: SizeConfig.getTextMultiplierBasedOnWidth() * 4, value: AppDateUtils .getDayMonthYearDateFormatted( item.startDate diff --git a/lib/screens/sick-leave/sick_leave.dart b/lib/screens/sick-leave/sick_leave.dart index 3eb51a01..9cbd94f1 100644 --- a/lib/screens/sick-leave/sick_leave.dart +++ b/lib/screens/sick-leave/sick_leave.dart @@ -17,9 +17,11 @@ 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-textfield-custom.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'; +import 'package:flutter/services.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:intl/intl.dart'; @@ -31,7 +33,14 @@ class SickLeaveScreen extends StatefulWidget { final appointmentNo; final patientMRN; final patient; - SickLeaveScreen({this.appointmentNo, this.patientMRN, this.isExtended = false, this.extendedData, this.patient}); + + SickLeaveScreen( + {this.appointmentNo, + this.patientMRN, + this.isExtended = false, + this.extendedData, + this.patient}); + @override _SickLeaveScreenState createState() => _SickLeaveScreenState(); } @@ -39,9 +48,15 @@ class SickLeaveScreen extends StatefulWidget { class _SickLeaveScreenState extends State { DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); TextEditingController _toDateController = new TextEditingController(); + TextEditingController _numberOfController = new TextEditingController(); + TextEditingController _clinicController = new TextEditingController(); + TextEditingController _doctorController = new TextEditingController(); + TextEditingController _remarkController = new TextEditingController(); + String _selectedClinic; Map profile = {}; AddSickLeaveRequest addSickLeave = AddSickLeaveRequest(); + void _presentDatePicker(id) { showDatePicker( context: context, @@ -72,9 +87,14 @@ class _SickLeaveScreenState extends State { @override Widget build(BuildContext context) { return BaseView( - onModelReady: (model) => model.getClinicsList(), + onModelReady: (model) async { + await model.getClinicsList(); + _clinicController.text = getClinicName(model); + _doctorController.text = profile['DoctorName']; + }, builder: (_, model, w) => BaseView( - onModelReady: (model2) => model2.preSickLeaveStatistics(widget.appointmentNo, widget.patientMRN), + onModelReady: (model2) => model2.preSickLeaveStatistics( + widget.appointmentNo, widget.patientMRN), builder: (_, model2, w) => GestureDetector( onTap: () { FocusScope.of(context).requestFocus(new FocusNode()); @@ -92,296 +112,252 @@ class _SickLeaveScreenState extends State { widthFactor: 0.9, child: ListView( children: [ - // Padding( - // child: AppText( - // widget.isExtended == true - // ? TranslationBase.of(context) - // .extendSickLeave - // : TranslationBase.of(context) - // .addSickLeave, - // fontWeight: FontWeight.bold, - // ), - // padding: EdgeInsets.all(10)), - Container( - margin: EdgeInsets.only(left: 10, right: 10), - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"), - ), - color: Colors.white), - padding: EdgeInsets.all(5), - child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - Padding( - padding: EdgeInsets.only(top: 5, left: 10, right: 10), - child: AppText(TranslationBase.of(context).sickLeave + - ' ' + - TranslationBase.of(context).days)), - AppTextFormField( - borderColor: Colors.white, - onChanged: (value) { - addSickLeave.noOfDays = value; - if (widget.extendedData != null) { - widget.extendedData.noOfDays = int.parse(value); - } - }, - hintText: - widget.extendedData != null ? widget.extendedData.noOfDays.toString() : '', - // validator: (value) { - // return TextValidator().validateName(value); - // }, - textInputType: TextInputType.number, - inputFormatter: ONLY_NUMBERS) - ]), + SizedBox( + height: 30, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + hintText: widget.extendedData != null + ? widget.extendedData.noOfDays.toString() + : TranslationBase.of(context).sickLeave + + ' ' + + TranslationBase.of(context).days, + maxLines: 1, + minLines: 1, + dropDownColor: Colors.white, + + isTextFieldHasSuffix: true, + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp(ONLY_NUMBERS)) + ], + controller: _numberOfController, + onChanged: (value) { + addSickLeave.noOfDays = value; + if (widget.extendedData != null) { + widget.extendedData.noOfDays = + int.parse(value); + } + }, + // validationError: isFormSubmitted && + // _selectedMedicationFrequency == + // null + // ? TranslationBase + // .of(context) + // .emptyMessage + // : null, ), SizedBox( height: 10, ), - Container( - margin: EdgeInsets.only(left: 10, right: 10), - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(6.0)), - border: Border.all(width: 1.0, color: HexColor("#CCCCCC")), - color: Colors.white, - ), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only(top: 5, left: 10, right: 10), - child: AppText( - TranslationBase.of(context).sickLeaveDate, - )), - AppTextFormField( - hintText: widget.extendedData != null ? widget.extendedData.startDate : '', - borderColor: Colors.white, - prefix: IconButton(icon: Icon(Icons.calendar_today)), - textInputType: TextInputType.number, - controller: _toDateController, - onTap: () { - _presentDatePicker('_selectedToDate'); - }, - inputFormatter: ONLY_DATE, - onChanged: (value) { - addSickLeave.startDate = value; - if (widget.extendedData != null) { - widget.extendedData.startDate = value; - } - }), - ], - )), - Container( - margin: EdgeInsets.only(top: 10, left: 10, right: 10), - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(6.0)), - border: Border.all(width: 1.0, color: HexColor("#CCCCCC")), - color: Colors.white, - ), - width: double.infinity, - child: Padding( - padding: EdgeInsets.only( - top: SizeConfig.widthMultiplier * 0.9, - bottom: SizeConfig.widthMultiplier * 0.9, - right: SizeConfig.widthMultiplier * 3, - left: SizeConfig.widthMultiplier * 3), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only(top: 5), - child: AppText( - TranslationBase.of(context).clinicName, - )), - Row( - mainAxisSize: MainAxisSize.max, - children: [ - Expanded( - // add Expanded to have your dropdown button fill remaining space - child: DropdownButtonHideUnderline( - child: new IgnorePointer( - ignoring: true, - child: DropdownButton( - isExpanded: true, - value: getClinicName(model) ?? "", - iconSize: 0, - elevation: 16, - selectedItemBuilder: (BuildContext context) { - return model.getClinicNameList().map((item) { - return Row( - mainAxisSize: MainAxisSize.max, - children: [ - AppText( - item, - fontSize: SizeConfig.textMultiplier * 2.1, - color: Colors.grey, - ), - ], - ); - }).toList(); - }, - onChanged: (newValue) => {}, - items: model.getClinicNameList().map((item) { - return DropdownMenuItem( - value: item.toString(), - child: Text( - item, - textAlign: TextAlign.end, - ), - ); - }).toList(), - ))), - ), - ], - ) - ], - ), - )), - model2.sickLeaveStatistics['recommendedSickLeaveDays'] != null - ? Padding( - child: AppText( - model2.sickLeaveStatistics['recommendedSickLeaveDays'], - fontWeight: FontWeight.bold, - textAlign: TextAlign.start, - ), - padding: EdgeInsets.all(10), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + onClick: () { + _presentDatePicker('_selectedToDate'); + }, + hintText: widget.extendedData != null + ? widget.extendedData.startDate + : TranslationBase.of(context).sickLeaveDate, + enabled: false, + maxLines: 1, + minLines: 1, + isTextFieldHasSuffix: true, + suffixIcon: IconButton( + icon: Icon(Icons.calendar_today)), + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp(ONLY_NUMBERS)) + ], + controller: _toDateController, + onChanged: (value) { + addSickLeave.startDate = value; + if (widget.extendedData != null) { + widget.extendedData.startDate = value; + } + }, + ), + + SizedBox( + height: 5, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + hintText: + TranslationBase.of(context).clinicName, + enabled: false, + maxLines: 1, + minLines: 1, + dropDownColor: Colors.white, + isTextFieldHasSuffix: true, + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp(ONLY_NUMBERS)) + ], + controller: _clinicController, + onChanged: (value) {}, + ), + SizedBox( + height: 10, + ), + model2.sickLeaveStatistics[ + 'recommendedSickLeaveDays'] != + null + ? AppText( + model2.sickLeaveStatistics[ + 'recommendedSickLeaveDays'], + fontWeight: FontWeight.bold, + textAlign: TextAlign.start, + fontSize: 15, ) : SizedBox( height: 10, ), - Container( - margin: EdgeInsets.only(left: 10, right: 10), - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(6.0)), - border: Border.all(width: 1.0, color: HexColor("#CCCCCC")), - color: Colors.white, - ), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only(top: 5, left: 10, right: 10), - child: AppText( - TranslationBase.of(context).doctorName, - )), - new IgnorePointer( - ignoring: true, - child: AppTextFormField( - readOnly: true, - hintText: profile['DoctorName'], - borderColor: Colors.white, - onSaved: (value) {}, - // validator: (value) { - // return TextValidator().validateName(value); - // }, - inputFormatter: ONLY_NUMBERS)) - ], - ), + + SizedBox( + height: 10, + ), + + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + hintText: + TranslationBase.of(context).doctorName, + enabled: false, + maxLines: 1, + minLines: 1, + dropDownColor: Colors.white, + isTextFieldHasSuffix: true, + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp(ONLY_NUMBERS)) + ], + controller: _doctorController, + onChanged: (value) {}, ), SizedBox( height: 10, ), - Container( - margin: EdgeInsets.only(left: 10, right: 10), - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(6.0)), - border: Border.all(width: 1.0, color: HexColor("#CCCCCC")), - color: Colors.white, - ), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only(top: 5, left: 10, right: 10), - child: AppText( - TranslationBase.of(context).remarks, - )), - TextField( - maxLines: 3, - decoration: InputDecoration( - contentPadding: EdgeInsets.all(20.0), - border: InputBorder.none, - hintText: widget.extendedData != null ? widget.extendedData.remarks : ''), - onChanged: (value) { - addSickLeave.remarks = value; - if (widget.extendedData != null) { - widget.extendedData.remarks = value; - } - }, - ) - ], - ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + hintText: widget.extendedData != null + ? widget.extendedData.remarks + : TranslationBase.of(context).remarks, + maxLines: 30, + minLines: 5, + dropDownColor: Colors.white, + isTextFieldHasSuffix: true, + controller: _remarkController, + onChanged: (value) { + addSickLeave.remarks = value; + if (widget.extendedData != null) { + widget.extendedData.remarks = value; + } + }, ), - Container( - margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - title: widget.isExtended == true - ? TranslationBase.of(context).extend - : TranslationBase.of(context).addSickLeaverequest, - color: Colors.green, - onPressed: () async { - if (widget.isExtended) { - await model2.extendSickLeave(widget.extendedData); - DrAppToastMsg.showSuccesToast( - model2.sickleaveResponse['ListSickLeavesToExtent']['success']); - Navigator.of(context).popUntil((route) { - return route.settings.name == PATIENTS_PROFILE; - }); - Navigator.of(context) - .pushNamed(ADD_SICKLEAVE, arguments: {'patient': widget.patient}); - //print(value); - //}); - } else { - try { - if (addSickLeave.noOfDays == null) { - DrAppToastMsg.showErrorToast( - TranslationBase.of(context).pleaseEnterNoOfDays); - } else if (addSickLeave.remarks == null) { - DrAppToastMsg.showErrorToast( - TranslationBase.of(context).pleaseEnterRemarks); - } 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); - } - - GifLoaderDialogUtils.hideDialog(context); - } - } catch (err) { - print(err); - } - } - }, - ), - ], - ), - ), - // Column( - // children: [ - // AppText(TranslationBase.of(context) - // .previousSickLeaveIssue + - // ' ') - // ], - // ) ], ), ), ), ), + bottomSheet: model2.state ==ViewState.Busy || model.state == ViewState.Busy?Container(height: 0,): Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(0.0), + ), + border: Border.all(color: HexColor('#707070'), width: 0), + ), + height: SizeConfig.heightMultiplier * + (SizeConfig.isHeightVeryShort ? 12 : 10), + width: double.infinity, + child: Column( + children: [ + SizedBox( + height: 10, + ), + FractionallySizedBox( + widthFactor: 0.9, + child: AppButton( + title: widget.isExtended == true + ? TranslationBase.of(context).extend + : TranslationBase.of(context) + .addSickLeaverequest, + color: Colors.green, + onPressed: () async { + if (widget.isExtended) { + await model2.extendSickLeave( + widget.extendedData); + + DrAppToastMsg.showSuccesToast( + model2.sickleaveResponse[ + 'ListSickLeavesToExtent'] + ['success']); + Navigator.of(context) + .popUntil((route) { + return route.settings.name == + PATIENTS_PROFILE; + }); + Navigator.of(context).pushNamed( + ADD_SICKLEAVE, + arguments: { + 'patient': widget.patient + }); + //print(value); + //}); + } else { + try { + if (addSickLeave.noOfDays == null) { + DrAppToastMsg.showErrorToast( + TranslationBase.of(context) + .pleaseEnterNoOfDays); + } else if (addSickLeave.remarks == + null) { + DrAppToastMsg.showErrorToast( + TranslationBase.of(context) + .pleaseEnterRemarks); + } 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); + } + + GifLoaderDialogUtils.hideDialog( + context); + } + } catch (err) { + print(err); + } + } + }, + ), + ), + SizedBox( + height: 5, + ), + ], + ), + ) + ), ))); } @@ -389,26 +365,31 @@ class _SickLeaveScreenState extends State { void _validateInputs(model2) async { try { if (addSickLeave.noOfDays == null) { - DrAppToastMsg.showErrorToast(TranslationBase.of(context).pleaseEnterNoOfDays); + DrAppToastMsg.showErrorToast( + TranslationBase.of(context).pleaseEnterNoOfDays); } else if (addSickLeave.remarks == null) { - DrAppToastMsg.showErrorToast(TranslationBase.of(context).pleaseEnterRemarks); + DrAppToastMsg.showErrorToast( + TranslationBase.of(context).pleaseEnterRemarks); } else if (addSickLeave.startDate == null) { - DrAppToastMsg.showErrorToast(TranslationBase.of(context).pleaseEnterDate); + DrAppToastMsg.showErrorToast( + TranslationBase.of(context).pleaseEnterDate); } else { addSickLeave.patientMRN = widget.patient.patientMRN.toString(); addSickLeave.appointmentNo = widget.patient.appointmentNo.toString(); await model2.addSickLeave(addSickLeave); - if(model2.state == ViewState.ErrorLocal){ + if (model2.state == ViewState.ErrorLocal) { Helpers.showErrorToast(model2.error); } else { - DrAppToastMsg.showSuccesToast(TranslationBase.of(context).replySuccessfully); + DrAppToastMsg.showSuccesToast( + TranslationBase.of(context).replySuccessfully); } GifLoaderDialogUtils.hideDialog(context); Navigator.of(context).popUntil((route) { return route.settings.name == PATIENTS_PROFILE; }); - Navigator.of(context).pushNamed(ADD_SICKLEAVE, arguments: {'patient': widget.patient}); + Navigator.of(context) + .pushNamed(ADD_SICKLEAVE, arguments: {'patient': widget.patient}); } } catch (err) { print(err); @@ -423,7 +404,9 @@ class _SickLeaveScreenState extends State { } getClinicName(model) { - var clinicInfo = model.clinicsList.where((i) => i['ClinicID'] == this.profile['ClinicID']).toList(); + var clinicInfo = model.clinicsList + .where((i) => i['ClinicID'] == this.profile['ClinicID']) + .toList(); return clinicInfo.length > 0 ? clinicInfo[0]['ClinicDescription'] : ""; } } diff --git a/lib/widgets/shared/text_fields/app-textfield-custom.dart b/lib/widgets/shared/text_fields/app-textfield-custom.dart index da3ee466..cd97c8d4 100644 --- a/lib/widgets/shared/text_fields/app-textfield-custom.dart +++ b/lib/widgets/shared/text_fields/app-textfield-custom.dart @@ -30,8 +30,6 @@ class AppTextFieldCustom extends StatefulWidget { final bool isPrscription; final bool isSecure; final bool focus; - - ///TODO Rename it to isCustomSearchablFiels final bool isSearchTextField; AppTextFieldCustom({ From f05455fddf1d7484935f6fd9c3254c76503ad7f3 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 21 Sep 2021 11:43:18 +0300 Subject: [PATCH 4/9] finish sick leave design --- .../sick_leave/sickleave_service.dart | 6 - lib/core/viewModel/sick_leave_view_model.dart | 7 +- .../subjective/medication/add_medication.dart | 787 +++++++++--------- lib/screens/sick-leave/add-sickleave.dart | 5 - lib/screens/sick-leave/sick_leave.dart | 521 ++++++------ pubspec.lock | 85 +- 6 files changed, 707 insertions(+), 704 deletions(-) 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 8b1438f0..2b3062ee 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 @@ -27,12 +27,9 @@ class SickLeaveService extends BaseService { dynamic get postReschedule => _postReschedule; dynamic _postReschedule; - dynamic get sickLeaveResponse => _sickLeaveResponse; - dynamic _sickLeaveResponse; List getAllSickLeavePatient = List(); List getAllSickLeaveDoctor = List(); - //getAllSickLeavePatient.addAll(getAllSickLeaveDoctor); SickLeavePatientRequestModel _sickLeavePatientRequestModel = SickLeavePatientRequestModel(); GetSickLeaveDoctorRequestModel _sickLeaveDoctorRequestModel = GetSickLeaveDoctorRequestModel(); @@ -56,8 +53,6 @@ class SickLeaveService extends BaseService { Future addSickLeave(AddSickLeaveRequest addSickLeaveRequest) async { hasError = false; - if(_sickLeaveResponse!= null) - _sickLeaveResponse.clear(); await baseAppClient.post( ADD_SICK_LEAVE, onSuccess: (dynamic response, int statusCode) { @@ -80,7 +75,6 @@ class SickLeaveService extends BaseService { await baseAppClient.post( EXTEND_SICK_LEAVE, onSuccess: (dynamic response, int statusCode) { - _sickLeaveResponse = response; return Future.value(response); }, onFailure: (String error, int statusCode) { diff --git a/lib/core/viewModel/sick_leave_view_model.dart b/lib/core/viewModel/sick_leave_view_model.dart index a4332534..bc7c9568 100644 --- a/lib/core/viewModel/sick_leave_view_model.dart +++ b/lib/core/viewModel/sick_leave_view_model.dart @@ -10,8 +10,7 @@ class SickLeaveViewModel extends BaseViewModel { SickLeaveService _sickLeaveService = locator(); get sickLeaveStatistics => _sickLeaveService.sickLeavestatisitics; get getAllSIckLeave => _sickLeaveService.getAllSickLeave; - //get getAllSIckLeavePatient => _sickLeaveService.getAllSickLeavePatient; - get sickleaveResponse => _sickLeaveService.sickLeaveResponse; + List get allOffTime => _sickLeaveService.getOffTimeList; List get allReasons => _sickLeaveService.getReasons; @@ -32,11 +31,11 @@ class SickLeaveViewModel extends BaseViewModel { } Future extendSickLeave(GetAllSickLeaveResponse extendSickLeaveRequest) async { - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _sickLeaveService.extendSickLeave(extendSickLeaveRequest); if (_sickLeaveService.hasError) { error = _sickLeaveService.error; - setState(ViewState.Error); + setState(ViewState.ErrorLocal); } else setState(ViewState.Idle); } diff --git a/lib/screens/patients/profile/soap_update/subjective/medication/add_medication.dart b/lib/screens/patients/profile/soap_update/subjective/medication/add_medication.dart index db31fb95..72330be3 100644 --- a/lib/screens/patients/profile/soap_update/subjective/medication/add_medication.dart +++ b/lib/screens/patients/profile/soap_update/subjective/medication/add_medication.dart @@ -46,7 +46,7 @@ class _AddMedicationState extends State { GetMedicationResponseModel _selectedMedication; GlobalKey key = - new GlobalKey>(); + new GlobalKey>(); bool isFormSubmitted = false; @override @@ -54,424 +54,395 @@ class _AddMedicationState extends State { ProjectViewModel projectViewModel = Provider.of(context); return FractionallySizedBox( child: BaseView( - onModelReady: (model) async { - model.onAddMedicationStart(); - }, - builder: (_, model, w) => - AppScaffold( - baseViewModel: model, - isShowAppBar: true, - appBar: BottomSheetTitle( - title: TranslationBase - .of(context) - .addMedication, - ), - body: Center( - child: Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( + onModelReady: (model) async { + model.onAddMedicationStart(); + }, + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + isShowAppBar: true, + appBar: BottomSheetTitle( + title: TranslationBase.of(context).addMedication, + ), + body: Center( + child: Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( height: 10, ), Expanded( child: FractionallySizedBox( - widthFactor: 0.9, - child: SingleChildScrollView( - child: Column( + widthFactor: 0.9, + child: SingleChildScrollView( + child: Column( children: [ - SizedBox( - height: SizeConfig.heightMultiplier * ( - SizeConfig.isHeightVeryShort ?2:SizeConfig.isHeightShort? - 2:2), - ), - Container( - // height: screenSize.height * 0.070, - child: InkWell( - onTap: model.allMedicationList != null - ? () { - setState(() { - _selectedMedication = null; - }); - } - : null, - child: _selectedMedication == null - ? CustomAutoCompleteTextField( - isShowError: isFormSubmitted && - _selectedMedication == null, - child: AutoCompleteTextField< - GetMedicationResponseModel>( - decoration: TextFieldsUtils - .textFieldSelectorDecoration( - TranslationBase - .of( - context) - .searchMedicineNameHere, - null, - true, - suffixIcon: - Icons.search), - itemSubmitted: (item) => - setState(() => - _selectedMedication = - item), - key: key, - suggestions: - model.allMedicationList, - itemBuilder: (context, - suggestion) => - new Padding( - child: AppText(suggestion - .description + - '/' + - suggestion - .genericName), - padding: - EdgeInsets.all( - 8.0)), - itemSorter: (a, b) => 1, - itemFilter: (suggestion, - input) => - suggestion.genericName.toLowerCase() - .startsWith(input.toLowerCase()) || - suggestion.description - .toLowerCase() - .startsWith(input - .toLowerCase()) || - suggestion.keywords - .toLowerCase() - .startsWith(input - .toLowerCase()), - ), - ) - : AppTextFieldCustom( - height: Helpers.getTextFieldHeight(), - hintText: _selectedMedication != - null - ? _selectedMedication - .description + - (' (${_selectedMedication.genericName} )') - : TranslationBase - .of( - context) - .searchMedicineNameHere, - minLines: 1, - maxLines: 1, - isTextFieldHasSuffix: true, - suffixIcon: IconButton( - icon: Icon( - Icons.search, - color: Colors.grey.shade600, - )), - enabled: false, - ), - ), - ), - - if(_selectedMedication != null) - Column( - children: [ - SizedBox( - height: 3, - ), - Container( - width: MediaQuery - .of(context) - .size - .width * 0.7, - child: AppText( - _selectedMedication.description + - (' (${_selectedMedication.genericName} )'), - color: Color(0xFF575757), - fontSize: 10, - fontWeight: FontWeight.w700, - letterSpacing: -0.4, - ), - ), - ], - ), - SizedBox( - height: 5, - ), - AppTextFieldCustom( - height: Helpers.getTextFieldHeight(), - enabled: false, - onClick: model.medicationDoseTimeList != - null - ? () { - MasterKeyDailog dialog = - MasterKeyDailog( - list: model - .medicationDoseTimeList, - okText: - TranslationBase - .of(context) - .ok, - selectedValue: - _selectedMedicationDose, - okFunction: (selectedValue) { - setState(() { - _selectedMedicationDose = - selectedValue; - - doseController - .text = projectViewModel - .isArabic - ? _selectedMedicationDose - .nameAr - : _selectedMedicationDose - .nameEn; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: - (BuildContext context) { - return dialog; - }, - ); - } - : null, - hintText: - TranslationBase - .of(context) - .doseTime, - maxLines: 1, - minLines: 1, - isTextFieldHasSuffix: true, - controller: doseController, - validationError: isFormSubmitted && - _selectedMedicationDose == null - ? TranslationBase - .of(context) - .emptyMessage - : null, - ), - SizedBox( - height: 5, - ), - AppTextFieldCustom( - height: Helpers.getTextFieldHeight(), - enabled: false, - isTextFieldHasSuffix: true, - onClick: model.medicationStrengthList != - null - ? () { - MasterKeyDailog dialog = - MasterKeyDailog( - list: model - .medicationStrengthList, - okText: - TranslationBase - .of(context) - .ok, - selectedValue: - _selectedMedicationStrength, - okFunction: (selectedValue) { - setState(() { - _selectedMedicationStrength = - selectedValue; + SizedBox( + height: SizeConfig.heightMultiplier * + (SizeConfig.isHeightVeryShort + ? 2 + : SizeConfig.isHeightShort + ? 2 + : 2), + ), + Container( + // height: screenSize.height * 0.070, + child: InkWell( + onTap: model.allMedicationList != null + ? () { + setState(() { + _selectedMedication = null; + }); + } + : null, + child: _selectedMedication == null + ? CustomAutoCompleteTextField( + isShowError: isFormSubmitted && + _selectedMedication == null, + child: AutoCompleteTextField< + GetMedicationResponseModel>( + decoration: TextFieldsUtils + .textFieldSelectorDecoration( + TranslationBase.of( + context) + .searchMedicineNameHere, + null, + true, + suffixIcon: + Icons.search), + itemSubmitted: (item) => + setState(() => + _selectedMedication = + item), + key: key, + suggestions: + model.allMedicationList, + itemBuilder: (context, + suggestion) => + new Padding( + child: AppText(suggestion + .description + + '/' + + suggestion + .genericName), + padding: EdgeInsets.all( + 8.0)), + itemSorter: (a, b) => 1, + itemFilter: (suggestion, + input) => + suggestion.genericName.toLowerCase().startsWith( + input.toLowerCase()) || + suggestion.description + .toLowerCase() + .startsWith(input + .toLowerCase()) || + suggestion.keywords + .toLowerCase() + .startsWith(input + .toLowerCase()), + ), + ) + : AppTextFieldCustom( + height: + Helpers.getTextFieldHeight(), + hintText: _selectedMedication != + null + ? _selectedMedication + .description + + (' (${_selectedMedication.genericName} )') + : TranslationBase.of(context) + .searchMedicineNameHere, + minLines: 1, + maxLines: 1, + isTextFieldHasSuffix: true, + suffixIcon: IconButton( + icon: Icon( + Icons.search, + color: Colors.grey.shade600, + )), + enabled: false, + ), + ), + ), + if (_selectedMedication != null) + Column( + children: [ + SizedBox( + height: 3, + ), + Container( + width: MediaQuery.of(context) + .size + .width * + 0.7, + child: AppText( + _selectedMedication.description + + (' (${_selectedMedication.genericName} )'), + color: Color(0xFF575757), + fontSize: 10, + fontWeight: FontWeight.w700, + letterSpacing: -0.4, + ), + ), + ], + ), + SizedBox( + height: 5, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + enabled: false, + onClick: model.medicationDoseTimeList != + null + ? () { + MasterKeyDailog dialog = + MasterKeyDailog( + list: + model.medicationDoseTimeList, + okText: + TranslationBase.of(context) + .ok, + selectedValue: + _selectedMedicationDose, + okFunction: (selectedValue) { + setState(() { + _selectedMedicationDose = + selectedValue; - strengthController - .text = projectViewModel - .isArabic - ? _selectedMedicationStrength - .nameAr - : _selectedMedicationStrength - .nameEn; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: - (BuildContext context) { - return dialog; - }, - ); - } - : null, - hintText: - TranslationBase - .of(context) - .strength, - maxLines: 1, - minLines: 1, - controller: strengthController, - validationError: isFormSubmitted && - _selectedMedicationStrength == - null - ? TranslationBase - .of(context) - .emptyMessage - : null, - ), - SizedBox( - height: 5, - ), - SizedBox( - height: 5, - ), - AppTextFieldCustom( - height: Helpers.getTextFieldHeight(), - enabled: false, - isTextFieldHasSuffix: true, - onClick: model.medicationRouteList != null - ? () { - MasterKeyDailog dialog = - MasterKeyDailog( - list: model.medicationRouteList, - selectedValue: - _selectedMedicationRoute, - okText: - TranslationBase - .of(context) - .ok, - okFunction: (selectedValue) { - setState(() { - _selectedMedicationRoute = - selectedValue; + doseController + .text = projectViewModel + .isArabic + ? _selectedMedicationDose + .nameAr + : _selectedMedicationDose + .nameEn; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + hintText: + TranslationBase.of(context).doseTime, + maxLines: 1, + minLines: 1, + isTextFieldHasSuffix: true, + controller: doseController, + validationError: isFormSubmitted && + _selectedMedicationDose == null + ? TranslationBase.of(context) + .emptyMessage + : null, + ), + SizedBox( + height: 5, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + enabled: false, + isTextFieldHasSuffix: true, + onClick: model.medicationStrengthList != + null + ? () { + MasterKeyDailog dialog = + MasterKeyDailog( + list: + model.medicationStrengthList, + okText: + TranslationBase.of(context) + .ok, + selectedValue: + _selectedMedicationStrength, + okFunction: (selectedValue) { + setState(() { + _selectedMedicationStrength = + selectedValue; - routeController - .text = projectViewModel - .isArabic - ? _selectedMedicationRoute - .nameAr - : _selectedMedicationRoute - .nameEn; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: - (BuildContext context) { - return dialog; - }, - ); - } - : null, - hintText: - TranslationBase - .of(context) - .route, - maxLines: 1, - minLines: 1, - controller: routeController, - validationError: isFormSubmitted && - _selectedMedicationRoute == null - ? TranslationBase - .of(context) - .emptyMessage - : null, - ), - SizedBox( - height: 5, - ), - SizedBox( - height: 5, - ), - AppTextFieldCustom( - height: Helpers.getTextFieldHeight(), - onClick: model.medicationFrequencyList != - null - ? () { - MasterKeyDailog dialog = - MasterKeyDailog( - list: model - .medicationFrequencyList, - okText: - TranslationBase - .of(context) - .ok, - selectedValue: - _selectedMedicationFrequency, - okFunction: (selectedValue) { - setState(() { - _selectedMedicationFrequency = - selectedValue; + strengthController + .text = projectViewModel + .isArabic + ? _selectedMedicationStrength + .nameAr + : _selectedMedicationStrength + .nameEn; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + hintText: + TranslationBase.of(context).strength, + maxLines: 1, + minLines: 1, + controller: strengthController, + validationError: isFormSubmitted && + _selectedMedicationStrength == null + ? TranslationBase.of(context) + .emptyMessage + : null, + ), + SizedBox( + height: 5, + ), + SizedBox( + height: 5, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + enabled: false, + isTextFieldHasSuffix: true, + onClick: model.medicationRouteList != null + ? () { + MasterKeyDailog dialog = + MasterKeyDailog( + list: model.medicationRouteList, + selectedValue: + _selectedMedicationRoute, + okText: + TranslationBase.of(context) + .ok, + okFunction: (selectedValue) { + setState(() { + _selectedMedicationRoute = + selectedValue; - frequencyController - .text = projectViewModel - .isArabic - ? _selectedMedicationFrequency - .nameAr - : _selectedMedicationFrequency - .nameEn; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: - (BuildContext context) { - return dialog; - }, - ); - } - : null, - hintText: - TranslationBase - .of(context) - .frequency, - enabled: false, - maxLines: 1, - minLines: 1, - isTextFieldHasSuffix: true, - controller: frequencyController, - validationError: isFormSubmitted && - _selectedMedicationFrequency == - null - ? TranslationBase - .of(context) - .emptyMessage - : null, - ), - SizedBox( - height: SizeConfig.heightMultiplier * - (SizeConfig.isHeightVeryShort ? 20 : SizeConfig - .isHeightShort ? 15 : 10), - ), + routeController + .text = projectViewModel + .isArabic + ? _selectedMedicationRoute + .nameAr + : _selectedMedicationRoute + .nameEn; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + hintText: TranslationBase.of(context).route, + maxLines: 1, + minLines: 1, + controller: routeController, + validationError: isFormSubmitted && + _selectedMedicationRoute == null + ? TranslationBase.of(context) + .emptyMessage + : null, + ), + SizedBox( + height: 5, + ), + SizedBox( + height: 5, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + onClick: model.medicationFrequencyList != + null + ? () { + MasterKeyDailog dialog = + MasterKeyDailog( + list: + model.medicationFrequencyList, + okText: + TranslationBase.of(context) + .ok, + selectedValue: + _selectedMedicationFrequency, + okFunction: (selectedValue) { + setState(() { + _selectedMedicationFrequency = + selectedValue; - ], + frequencyController + .text = projectViewModel + .isArabic + ? _selectedMedicationFrequency + .nameAr + : _selectedMedicationFrequency + .nameEn; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + hintText: + TranslationBase.of(context).frequency, + enabled: false, + maxLines: 1, + minLines: 1, + isTextFieldHasSuffix: true, + controller: frequencyController, + validationError: isFormSubmitted && + _selectedMedicationFrequency == null + ? TranslationBase.of(context) + .emptyMessage + : null, + ), + SizedBox( + height: SizeConfig.heightMultiplier * + (SizeConfig.isHeightVeryShort + ? 20 + : SizeConfig.isHeightShort + ? 15 + : 10), + ), + ], + ), + )), ), - )), + ]), ), - ]), - ), - ), - bottomSheet: model.state != ViewState.Idle - ? Container( - height: 0, - ) - : BottomSheetDialogButton( - label: - TranslationBase.of(context).addMedication, - onTap: () { - setState(() { - isFormSubmitted = true; - }); - if (_selectedMedication != null && - _selectedMedicationDose != null && - _selectedMedicationStrength != null && - _selectedMedicationRoute != null && - _selectedMedicationFrequency != null) { - widget.medicationController.text = widget - .medicationController.text + - '${_selectedMedication.description} (${TranslationBase.of(context).doseTime} ) ${doseController.text} (${TranslationBase.of(context).strength}) ${strengthController.text} (${TranslationBase.of(context).route}) ${routeController.text} (${TranslationBase.of(context).frequency}) ${frequencyController.text} \n \n'; - Navigator.of(context).pop(); - } - }, - ) - ) - , - ) - , + ), + bottomSheet: model.state != ViewState.Idle + ? Container( + height: 0, + ) + : BottomSheetDialogButton( + label: TranslationBase.of(context).addMedication, + onTap: () { + setState(() { + isFormSubmitted = true; + }); + if (_selectedMedication != null && + _selectedMedicationDose != null && + _selectedMedicationStrength != null && + _selectedMedicationRoute != null && + _selectedMedicationFrequency != null) { + widget.medicationController.text = widget + .medicationController.text + + '${_selectedMedication.description} (${TranslationBase.of(context).doseTime} ) ${doseController.text} (${TranslationBase.of(context).strength}) ${strengthController.text} (${TranslationBase.of(context).route}) ${routeController.text} (${TranslationBase.of(context).frequency}) ${frequencyController.text} \n \n'; + Navigator.of(context).pop(); + } + }, + )), + ), ); } } diff --git a/lib/screens/sick-leave/add-sickleave.dart b/lib/screens/sick-leave/add-sickleave.dart index dc52b86e..df03db37 100644 --- a/lib/screens/sick-leave/add-sickleave.dart +++ b/lib/screens/sick-leave/add-sickleave.dart @@ -279,11 +279,6 @@ class AddSickLeavScreen extends StatelessWidget { openSickLeave(BuildContext context, isExtend, {GetAllSickLeaveResponse extendedData}) { - // showModalBottomSheet( - // context: context, - // builder: (context) { - // return new Container( - // child: Navigator.push( context, FadePage( diff --git a/lib/screens/sick-leave/sick_leave.dart b/lib/screens/sick-leave/sick_leave.dart index 9cbd94f1..3b496d16 100644 --- a/lib/screens/sick-leave/sick_leave.dart +++ b/lib/screens/sick-leave/sick_leave.dart @@ -48,14 +48,14 @@ class SickLeaveScreen extends StatefulWidget { class _SickLeaveScreenState extends State { DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); TextEditingController _toDateController = new TextEditingController(); - TextEditingController _numberOfController = new TextEditingController(); + TextEditingController _numberOfDayController = new TextEditingController(); TextEditingController _clinicController = new TextEditingController(); TextEditingController _doctorController = new TextEditingController(); TextEditingController _remarkController = new TextEditingController(); - String _selectedClinic; Map profile = {}; AddSickLeaveRequest addSickLeave = AddSickLeaveRequest(); + bool isFormSubmitted = false; void _presentDatePicker(id) { showDatePicker( @@ -100,299 +100,266 @@ class _SickLeaveScreenState extends State { FocusScope.of(context).requestFocus(new FocusNode()); }, child: AppScaffold( - baseViewModel: model2, - appBarTitle: widget.isExtended == true - ? TranslationBase.of(context).extendSickLeave - : TranslationBase.of(context).addSickLeave, - isShowAppBar: true, - body: Center( - child: Container( - margin: EdgeInsets.only(top: 10), - child: FractionallySizedBox( - widthFactor: 0.9, - child: ListView( - children: [ - SizedBox( - height: 30, - ), - AppTextFieldCustom( - height: Helpers.getTextFieldHeight(), - hintText: widget.extendedData != null - ? widget.extendedData.noOfDays.toString() - : TranslationBase.of(context).sickLeave + - ' ' + - TranslationBase.of(context).days, - maxLines: 1, - minLines: 1, - dropDownColor: Colors.white, - - isTextFieldHasSuffix: true, - inputFormatters: [ - FilteringTextInputFormatter.allow( - RegExp(ONLY_NUMBERS)) - ], - controller: _numberOfController, - onChanged: (value) { - addSickLeave.noOfDays = value; - if (widget.extendedData != null) { - widget.extendedData.noOfDays = - int.parse(value); - } - }, - // validationError: isFormSubmitted && - // _selectedMedicationFrequency == - // null - // ? TranslationBase - // .of(context) - // .emptyMessage - // : null, - ), - SizedBox( - height: 10, - ), - AppTextFieldCustom( - height: Helpers.getTextFieldHeight(), - onClick: () { - _presentDatePicker('_selectedToDate'); - }, - hintText: widget.extendedData != null - ? widget.extendedData.startDate - : TranslationBase.of(context).sickLeaveDate, - enabled: false, - maxLines: 1, - minLines: 1, - isTextFieldHasSuffix: true, - suffixIcon: IconButton( - icon: Icon(Icons.calendar_today)), - inputFormatters: [ - FilteringTextInputFormatter.allow( - RegExp(ONLY_NUMBERS)) - ], - controller: _toDateController, - onChanged: (value) { - addSickLeave.startDate = value; - if (widget.extendedData != null) { - widget.extendedData.startDate = value; - } - }, - ), - - SizedBox( - height: 5, - ), - AppTextFieldCustom( - height: Helpers.getTextFieldHeight(), - hintText: - TranslationBase.of(context).clinicName, - enabled: false, - maxLines: 1, - minLines: 1, - dropDownColor: Colors.white, - isTextFieldHasSuffix: true, - inputFormatters: [ - FilteringTextInputFormatter.allow( - RegExp(ONLY_NUMBERS)) - ], - controller: _clinicController, - onChanged: (value) {}, - ), - SizedBox( - height: 10, - ), - model2.sickLeaveStatistics[ - 'recommendedSickLeaveDays'] != - null - ? AppText( - model2.sickLeaveStatistics[ - 'recommendedSickLeaveDays'], - fontWeight: FontWeight.bold, - textAlign: TextAlign.start, - fontSize: 15, - ) - : SizedBox( - height: 10, - ), - - SizedBox( - height: 10, - ), - - AppTextFieldCustom( - height: Helpers.getTextFieldHeight(), - hintText: - TranslationBase.of(context).doctorName, - enabled: false, - maxLines: 1, - minLines: 1, - dropDownColor: Colors.white, - isTextFieldHasSuffix: true, - inputFormatters: [ - FilteringTextInputFormatter.allow( - RegExp(ONLY_NUMBERS)) - ], - controller: _doctorController, - onChanged: (value) {}, - ), - SizedBox( - height: 10, - ), - AppTextFieldCustom( - height: Helpers.getTextFieldHeight(), - hintText: widget.extendedData != null - ? widget.extendedData.remarks - : TranslationBase.of(context).remarks, - maxLines: 30, - minLines: 5, - dropDownColor: Colors.white, - isTextFieldHasSuffix: true, - controller: _remarkController, - onChanged: (value) { - addSickLeave.remarks = value; - if (widget.extendedData != null) { - widget.extendedData.remarks = value; - } - }, - ), - - ], - ), - ), - ), - ), - bottomSheet: model2.state ==ViewState.Busy || model.state == ViewState.Busy?Container(height: 0,): Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all( - Radius.circular(0.0), - ), - border: Border.all(color: HexColor('#707070'), width: 0), - ), - height: SizeConfig.heightMultiplier * - (SizeConfig.isHeightVeryShort ? 12 : 10), - width: double.infinity, - child: Column( - children: [ - SizedBox( - height: 10, - ), - FractionallySizedBox( + baseViewModel: model2, + appBarTitle: widget.isExtended == true + ? TranslationBase.of(context).extendSickLeave + : TranslationBase.of(context).addSickLeave, + isShowAppBar: true, + body: Center( + child: Container( + margin: EdgeInsets.only(top: 10), + child: FractionallySizedBox( widthFactor: 0.9, - child: AppButton( - title: widget.isExtended == true - ? TranslationBase.of(context).extend - : TranslationBase.of(context) - .addSickLeaverequest, - color: Colors.green, - onPressed: () async { - if (widget.isExtended) { - await model2.extendSickLeave( - widget.extendedData); - - DrAppToastMsg.showSuccesToast( - model2.sickleaveResponse[ - 'ListSickLeavesToExtent'] - ['success']); - Navigator.of(context) - .popUntil((route) { - return route.settings.name == - PATIENTS_PROFILE; - }); - Navigator.of(context).pushNamed( - ADD_SICKLEAVE, - arguments: { - 'patient': widget.patient - }); - //print(value); - //}); - } else { - try { - if (addSickLeave.noOfDays == null) { - DrAppToastMsg.showErrorToast( - TranslationBase.of(context) - .pleaseEnterNoOfDays); - } else if (addSickLeave.remarks == - null) { - DrAppToastMsg.showErrorToast( - TranslationBase.of(context) - .pleaseEnterRemarks); - } 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); - } + child: ListView( + children: [ + SizedBox( + height: 30, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + hintText: widget.extendedData != null + ? widget.extendedData.noOfDays.toString() + : TranslationBase.of(context).sickLeave + + ' ' + + TranslationBase.of(context).days, + maxLines: 1, + minLines: 1, + dropDownColor: Colors.white, + isTextFieldHasSuffix: true, + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp(ONLY_NUMBERS)) + ], + controller: _numberOfDayController, + onChanged: (value) { + setState(() { + addSickLeave.noOfDays = value; + }); - GifLoaderDialogUtils.hideDialog( - context); + if (widget.extendedData != null) { + widget.extendedData.noOfDays = + int.parse(value); + } + }, + validationError: isFormSubmitted && + (addSickLeave.noOfDays == null) + ? TranslationBase.of(context) + .pleaseEnterNoOfDays + : null, + ), + SizedBox( + height: 10, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + onClick: () { + _presentDatePicker('_selectedToDate'); + }, + hintText: widget.extendedData != null + ? widget.extendedData.startDate + : TranslationBase.of(context) + .sickLeaveDate, + enabled: false, + maxLines: 1, + minLines: 1, + isTextFieldHasSuffix: true, + suffixIcon: IconButton( + icon: Icon(Icons.calendar_today)), + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp(ONLY_NUMBERS)) + ], + controller: _toDateController, + onChanged: (value) { + setState(() { + addSickLeave.startDate = value; + }); + if (widget.extendedData != null) { + widget.extendedData.startDate = value; } - } catch (err) { - print(err); - } - } - }, + }, + validationError: isFormSubmitted && + (addSickLeave.startDate == null) + ? TranslationBase.of(context) + .pleaseEnterDate + : null, + ), + SizedBox( + height: 5, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + hintText: + TranslationBase.of(context).clinicName, + enabled: false, + maxLines: 1, + minLines: 1, + dropDownColor: Colors.white, + isTextFieldHasSuffix: true, + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp(ONLY_NUMBERS)) + ], + controller: _clinicController, + onChanged: (value) {}, + ), + SizedBox( + height: 10, + ), + model2.sickLeaveStatistics[ + 'recommendedSickLeaveDays'] != + null + ? AppText( + model2.sickLeaveStatistics[ + 'recommendedSickLeaveDays'], + fontWeight: FontWeight.bold, + textAlign: TextAlign.start, + fontSize: 15, + ) + : SizedBox( + height: 10, + ), + SizedBox( + height: 10, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + hintText: + TranslationBase.of(context).doctorName, + enabled: false, + maxLines: 1, + minLines: 1, + dropDownColor: Colors.white, + isTextFieldHasSuffix: true, + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp(ONLY_NUMBERS)) + ], + controller: _doctorController, + onChanged: (value) {}, + ), + SizedBox( + height: 10, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + hintText: widget.extendedData != null + ? widget.extendedData.remarks + : TranslationBase.of(context).remarks, + maxLines: 30, + minLines: 5, + dropDownColor: Colors.white, + isTextFieldHasSuffix: true, + controller: _remarkController, + onChanged: (value) { + setState(() { + addSickLeave.remarks = value; + }); + if (widget.extendedData != null) { + widget.extendedData.remarks = value; + } + }, + validationError: isFormSubmitted && + (addSickLeave.remarks == null) + ? TranslationBase.of(context) + .pleaseEnterRemarks + : null, + ), + ], ), ), - SizedBox( - height: 5, - ), - ], + ), ), - ) - - ), + bottomSheet: model2.state == ViewState.Busy || + model.state == ViewState.Busy + ? Container( + height: 0, + ) + : Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(0.0), + ), + border: Border.all( + color: HexColor('#707070'), width: 0), + ), + height: SizeConfig.heightMultiplier * + (SizeConfig.isHeightVeryShort ? 12 : 10), + width: double.infinity, + child: Column( + children: [ + SizedBox( + height: 10, + ), + FractionallySizedBox( + widthFactor: 0.9, + child: AppButton( + title: widget.isExtended == true + ? TranslationBase.of(context).extend + : TranslationBase.of(context) + .addSickLeaverequest, + color: Colors.green, + onPressed: () async { + submitForm(model2); + }), + ), + SizedBox( + height: 5, + ), + ], + ), + )), ))); } - void _validateInputs(model2) async { - try { - if (addSickLeave.noOfDays == null) { - DrAppToastMsg.showErrorToast( - TranslationBase.of(context).pleaseEnterNoOfDays); - } else if (addSickLeave.remarks == null) { - DrAppToastMsg.showErrorToast( - TranslationBase.of(context).pleaseEnterRemarks); - } else if (addSickLeave.startDate == null) { - DrAppToastMsg.showErrorToast( - TranslationBase.of(context).pleaseEnterDate); - } else { - addSickLeave.patientMRN = widget.patient.patientMRN.toString(); - addSickLeave.appointmentNo = widget.patient.appointmentNo.toString(); - await model2.addSickLeave(addSickLeave); + submitForm(SickLeaveViewModel model2) async { + { + if (widget.isExtended) { + + GifLoaderDialogUtils.showMyDialog(context); + await model2.extendSickLeave(widget.extendedData); if (model2.state == ViewState.ErrorLocal) { Helpers.showErrorToast(model2.error); } else { DrAppToastMsg.showSuccesToast( TranslationBase.of(context).replySuccessfully); + Navigator.of(context).popUntil((route) { + return route.settings.name == PATIENTS_PROFILE; + }); + Navigator.of(context) + .pushNamed(ADD_SICKLEAVE, arguments: {'patient': widget.patient}); } GifLoaderDialogUtils.hideDialog(context); - Navigator.of(context).popUntil((route) { - return route.settings.name == PATIENTS_PROFILE; - }); - Navigator.of(context) - .pushNamed(ADD_SICKLEAVE, arguments: {'patient': widget.patient}); + } else { + try { + setState(() { + isFormSubmitted = true; + }); + if (addSickLeave.noOfDays == null || + addSickLeave.startDate == null || + addSickLeave.remarks == null) { + return; + } 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); + } + + GifLoaderDialogUtils.hideDialog(context); + } + } catch (err) { + print(err); + } } - } catch (err) { - print(err); } } diff --git a/pubspec.lock b/pubspec.lock index 0229e774..43aefcb2 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -141,6 +141,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "7.1.0" + cached_network_image: + dependency: "direct main" + description: + name: cached_network_image + url: "https://pub.dartlang.org" + source: hosted + version: "2.5.1" characters: dependency: transitive description: @@ -433,6 +440,20 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_blurhash: + dependency: transitive + description: + name: flutter_blurhash + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.0" + flutter_cache_manager: + dependency: transitive + description: + name: flutter_cache_manager + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" flutter_device_type: dependency: "direct main" description: @@ -595,6 +616,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.4" + image: + dependency: transitive + description: + name: image + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.19" imei_plugin: dependency: "direct main" description: @@ -664,7 +692,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.4" + version: "1.3.0-nullsafety.3" mime: dependency: transitive description: @@ -693,6 +721,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + octo_image: + dependency: transitive + description: + name: octo_image + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.0" open_iconic_flutter: dependency: transitive description: @@ -728,6 +763,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.4" + path_provider: + dependency: transitive + description: + name: path_provider + url: "https://pub.dartlang.org" + source: hosted + version: "1.6.28" path_provider_linux: dependency: transitive description: @@ -735,6 +777,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.0.1+2" + path_provider_macos: + dependency: transitive + description: + name: path_provider_macos + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.4+8" path_provider_platform_interface: dependency: transitive description: @@ -854,6 +903,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.5" + rxdart: + dependency: transitive + description: + name: rxdart + url: "https://pub.dartlang.org" + source: hosted + version: "0.25.0" scratch_space: dependency: transitive description: @@ -950,13 +1006,27 @@ packages: relative: true source: path version: "0.0.0" + sqflite: + dependency: transitive + description: + name: sqflite + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.2+4" + sqflite_common: + dependency: transitive + description: + name: sqflite_common + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3+3" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.2" + version: "1.10.0-nullsafety.1" sticky_headers: dependency: "direct main" description: @@ -985,6 +1055,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.0-nullsafety.1" + synchronized: + dependency: transitive + description: + name: synchronized + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0+2" term_glyph: dependency: transitive description: @@ -1154,5 +1231,5 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=2.10.0 <=2.11.0-213.1.beta" - flutter: ">=1.22.0 <2.0.0" + dart: ">=2.10.2 <2.11.0" + flutter: ">=1.22.2 <2.0.0" From 8a0e94c8542d1337684a2d84861532acfcfcc78b Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 21 Sep 2021 12:05:23 +0300 Subject: [PATCH 5/9] match the design as xd --- lib/config/localized_values.dart | 4 +- lib/screens/sick-leave/add-sickleave.dart | 55 +++++++++++++++-------- lib/screens/sick-leave/sick_leave.dart | 42 +++++++++++------ 3 files changed, 67 insertions(+), 34 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index d6a06be3..9b91015f 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -243,7 +243,7 @@ const Map> localizedValues = { }, "no-sickleve": {"en": "No sick leave available", "ar": "لا توجد إجازة مرضية"}, "applynow": {"en": "Apply Now", "ar": "التقدم بطلب الآن"}, - "add-sickleave": {"en": "ADD SICK LEAVE", "ar": "أضف إجازة مرضية"}, + "add-sickleave": {"en": "Add Sick Leave", "ar": "أضف إجازة مرضية"}, "add": {"en": "Add", "ar": "أضف"}, "approved": {"en": "Approved", "ar": "موافق"}, "extended": {"en": "Extended", "ar": "تمديد"}, @@ -251,7 +251,7 @@ const Map> localizedValues = { "leave-start-date": {"en": "Leave start date", "ar": "تاريخ بدء المغادرة"}, "days-sick-leave": {"en": "Leave Days: ", "ar": "أيام الإجازة "}, "extend": {"en": "Extend", "ar": "تمديد"}, - "extend-sickleave": {"en": "EXTEND SICK LEAVE", "ar": "قم بتمديد الإجازة المرضية"}, + "extend-sickleave": {"en": "Extend Sick Leave", "ar": "قم بتمديد الإجازة المرضية"}, "chiefComplaintLength": { "en": "Chief Complaint length should be greater than 25", "ar": "يجب أن يكون طول شكوى الرئيسية أكبر من 25" diff --git a/lib/screens/sick-leave/add-sickleave.dart b/lib/screens/sick-leave/add-sickleave.dart index df03db37..c90ed6d7 100644 --- a/lib/screens/sick-leave/add-sickleave.dart +++ b/lib/screens/sick-leave/add-sickleave.dart @@ -23,6 +23,7 @@ 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:doctor_app_flutter/widgets/transitions/slide_up_page.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:provider/provider.dart'; @@ -51,8 +52,7 @@ class AddSickLeavScreen extends StatelessWidget { patient, isInpatient: isInpatient, ), - body: Column( - children: [ + body: Column(children: [ patient.patientStatusType == 43 ? Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -109,7 +109,7 @@ class AddSickLeavScreen extends StatelessWidget { : SizedBox(), model.getAllSIckLeavePatient.length > 0 ? Expanded( - child: FractionallySizedBox( + child: FractionallySizedBox( widthFactor: 0.95, child: Expanded( child: ListView.builder( @@ -153,14 +153,17 @@ class AddSickLeavScreen extends StatelessWidget { ), ), ]), - SizedBox(height: 10,), + SizedBox( + height: 10, + ), Row( children: [ ClipRRect( borderRadius: BorderRadius.circular(50.0), child: CachedNetworkImage( - imageUrl: item.doctorImageURL ?? + imageUrl: item + .doctorImageURL ?? "https://hmgwebservices.com/Images/MobileImages/DUBAI/unkown.png", height: 30, width: 30, @@ -182,8 +185,12 @@ class AddSickLeavScreen extends StatelessWidget { context) .daysSickleave + ": ", - labelSize: SizeConfig.getTextMultiplierBasedOnWidth() * 3.3, - valueSize: SizeConfig.getTextMultiplierBasedOnWidth() * 4, + labelSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3.3, + valueSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 4, value: (item.sickLeaveDays .toString() != null && @@ -201,15 +208,20 @@ class AddSickLeavScreen extends StatelessWidget { .startDate + ' ' ?? "", - labelSize: SizeConfig.getTextMultiplierBasedOnWidth() * 3.3, - valueSize: SizeConfig.getTextMultiplierBasedOnWidth() * 4, + labelSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3.3, + valueSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 4, value: AppDateUtils .getDayMonthYearDateFormatted( - item.startDate - .contains("/Date(") + item.startDate.contains( + "/Date(") ? AppDateUtils .convertStringToDate( - item.startDate) + item + .startDate) : DateTime.parse( item.startDate), ), @@ -220,12 +232,16 @@ class AddSickLeavScreen extends StatelessWidget { .endDate + ' ' ?? "", - labelSize: SizeConfig.getTextMultiplierBasedOnWidth() * 3.3, - valueSize: SizeConfig.getTextMultiplierBasedOnWidth() * 4, + labelSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3.3, + valueSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 4, value: AppDateUtils .getDayMonthYearDateFormatted( - item.startDate - .contains("/Date(") + item.startDate.contains( + "/Date(") ? AppDateUtils .convertStringToDate( item.endDate ?? @@ -263,7 +279,7 @@ class AddSickLeavScreen extends StatelessWidget { }), ), ), - ) + ) : patient.patientStatusType != 43 ? ErrorMessage( error: TranslationBase.of(context).noSickLeave, @@ -281,8 +297,9 @@ class AddSickLeavScreen extends StatelessWidget { {GetAllSickLeaveResponse extendedData}) { Navigator.push( context, - FadePage( - page: SickLeaveScreen( + SlideUpPageRoute( + fullscreenDialog: true, + widget: SickLeaveScreen( appointmentNo: isExtend == true ? extendedData.appointmentNo : patient.appointmentNo, diff --git a/lib/screens/sick-leave/sick_leave.dart b/lib/screens/sick-leave/sick_leave.dart index 3b496d16..b7c3ba55 100644 --- a/lib/screens/sick-leave/sick_leave.dart +++ b/lib/screens/sick-leave/sick_leave.dart @@ -4,11 +4,12 @@ import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/viewModel/patient_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/models/sickleave/add_sickleave_request.dart'; import 'package:doctor_app_flutter/models/sickleave/get_all_sickleave_response.dart'; import 'package:doctor_app_flutter/routes.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; -import 'package:doctor_app_flutter/screens/sick-leave/add-sickleave.dart'; +import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; @@ -18,7 +19,6 @@ 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-textfield-custom.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'; import 'package:flutter/services.dart'; @@ -101,9 +101,9 @@ class _SickLeaveScreenState extends State { }, child: AppScaffold( baseViewModel: model2, - appBarTitle: widget.isExtended == true + appBar: BottomSheetTitle(title: widget.isExtended == true ? TranslationBase.of(context).extendSickLeave - : TranslationBase.of(context).addSickLeave, + : TranslationBase.of(context).addSickLeave,), isShowAppBar: true, body: Center( child: Container( @@ -190,7 +190,7 @@ class _SickLeaveScreenState extends State { AppTextFieldCustom( height: Helpers.getTextFieldHeight(), hintText: - TranslationBase.of(context).clinicName, + TranslationBase.of(context).clinic, enabled: false, maxLines: 1, minLines: 1, @@ -209,12 +209,29 @@ class _SickLeaveScreenState extends State { model2.sickLeaveStatistics[ 'recommendedSickLeaveDays'] != null - ? AppText( - model2.sickLeaveStatistics[ - 'recommendedSickLeaveDays'], - fontWeight: FontWeight.bold, - textAlign: TextAlign.start, - fontSize: 15, + ? Row( + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + SizedBox( + width: 10, + ), + Icon( + DoctorApp.warning, + size: 20, + color: IN_PROGRESS_COLOR, + ), + SizedBox( + width: 10, + ), + AppText( + model2.sickLeaveStatistics[ + 'recommendedSickLeaveDays'], + textAlign: TextAlign.start, + fontSize: 12, + color: IN_PROGRESS_COLOR, + ), + ], ) : SizedBox( height: 10, @@ -225,7 +242,7 @@ class _SickLeaveScreenState extends State { AppTextFieldCustom( height: Helpers.getTextFieldHeight(), hintText: - TranslationBase.of(context).doctorName, + TranslationBase.of(context).doctor, enabled: false, maxLines: 1, minLines: 1, @@ -316,7 +333,6 @@ class _SickLeaveScreenState extends State { submitForm(SickLeaveViewModel model2) async { { if (widget.isExtended) { - GifLoaderDialogUtils.showMyDialog(context); await model2.extendSickLeave(widget.extendedData); if (model2.state == ViewState.ErrorLocal) { From 4711b6264c289f7a00d7ecf87574c7bfa745b804 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 21 Sep 2021 12:53:39 +0300 Subject: [PATCH 6/9] rename files --- lib/routes.dart | 7 +- .../add_patient_sick_leave_screen.dart} | 8 +- .../patient_sick_leave_screen.dart} | 15 +- lib/screens/sick-leave/show-sickleave.dart | 198 ------------------ 4 files changed, 11 insertions(+), 217 deletions(-) rename lib/screens/{sick-leave/sick_leave.dart => patient-sick-leave/add_patient_sick_leave_screen.dart} (98%) rename lib/screens/{sick-leave/add-sickleave.dart => patient-sick-leave/patient_sick_leave_screen.dart} (96%) delete mode 100644 lib/screens/sick-leave/show-sickleave.dart diff --git a/lib/routes.dart b/lib/routes.dart index 712db98c..47fccec3 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -1,6 +1,7 @@ import 'package:doctor_app_flutter/root_page.dart'; import 'package:doctor_app_flutter/screens/live_care/end_call_screen.dart'; import 'package:doctor_app_flutter/screens/medical-file/health_summary_page.dart'; +import 'package:doctor_app_flutter/screens/patient-sick-leave/patient_sick_leave_screen.dart'; import 'package:doctor_app_flutter/screens/patients/ECGPage.dart'; import 'package:doctor_app_flutter/screens/patients/insurance_approval_screen_patient.dart'; import 'package:doctor_app_flutter/screens/patients/profile/lab_result/all_lab_special_result_page.dart'; @@ -15,8 +16,6 @@ import 'package:doctor_app_flutter/screens/patients/profile/referral/refer-patie import 'package:doctor_app_flutter/screens/patients/profile/soap_update/update_soap_index.dart'; import 'package:doctor_app_flutter/screens/prescription/prescriptions_page.dart'; import 'package:doctor_app_flutter/screens/procedures/procedure_screen.dart'; -import 'package:doctor_app_flutter/screens/sick-leave/add-sickleave.dart'; -import 'package:doctor_app_flutter/screens/sick-leave/show-sickleave.dart'; import 'package:doctor_app_flutter/screens/auth/verification_methods_screen.dart'; import './screens/auth/login_screen.dart'; @@ -65,7 +64,6 @@ const String IN_PATIENT_PRESCRIPTIONS_DETAILS = 'patients/prescription-details'; const String ORDER_PRESCRIPTION_NEW = 'prescription/prescription_new'; const String ORDER_PROCEDURE = 'procedure/procedure'; const String ADD_SICKLEAVE = 'add-sickleave'; -const String SHOW_SICKLEAVE = 'show-sickleave'; const String RADIOLOGY_PATIENT = 'radiology-patient'; const String ALL_SPECIAL_LAB_RESULT = 'all-special_lab'; @@ -103,8 +101,7 @@ var routes = { isUpdate: true, ), IN_PATIENT_PRESCRIPTIONS_DETAILS: (_) => InpatientPrescriptionDetailsScreen(), - ADD_SICKLEAVE: (_) => AddSickLeavScreen(), - SHOW_SICKLEAVE: (_) => ShowSickLeaveScreen(), + ADD_SICKLEAVE: (_) => PatientSickLeaveScreen(), ORDER_PRESCRIPTION_NEW: (_) => PrescriptionsPage(), ORDER_PROCEDURE: (_) => ProcedureScreen(), MY_REFERRAL_DETAIL: (_) => MyReferralDetailScreen(), diff --git a/lib/screens/sick-leave/sick_leave.dart b/lib/screens/patient-sick-leave/add_patient_sick_leave_screen.dart similarity index 98% rename from lib/screens/sick-leave/sick_leave.dart rename to lib/screens/patient-sick-leave/add_patient_sick_leave_screen.dart index b7c3ba55..c32eed2c 100644 --- a/lib/screens/sick-leave/sick_leave.dart +++ b/lib/screens/patient-sick-leave/add_patient_sick_leave_screen.dart @@ -27,14 +27,14 @@ import 'package:intl/intl.dart'; Helpers helpers = Helpers(); -class SickLeaveScreen extends StatefulWidget { +class AddPatientSickLeaveScreen extends StatefulWidget { final bool isExtended; final GetAllSickLeaveResponse extendedData; final appointmentNo; final patientMRN; final patient; - SickLeaveScreen( + AddPatientSickLeaveScreen( {this.appointmentNo, this.patientMRN, this.isExtended = false, @@ -42,10 +42,10 @@ class SickLeaveScreen extends StatefulWidget { this.patient}); @override - _SickLeaveScreenState createState() => _SickLeaveScreenState(); + _AddPatientSickLeaveScreenState createState() => _AddPatientSickLeaveScreenState(); } -class _SickLeaveScreenState extends State { +class _AddPatientSickLeaveScreenState extends State { DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); TextEditingController _toDateController = new TextEditingController(); TextEditingController _numberOfDayController = new TextEditingController(); diff --git a/lib/screens/sick-leave/add-sickleave.dart b/lib/screens/patient-sick-leave/patient_sick_leave_screen.dart similarity index 96% rename from lib/screens/sick-leave/add-sickleave.dart rename to lib/screens/patient-sick-leave/patient_sick_leave_screen.dart index c90ed6d7..55114803 100644 --- a/lib/screens/sick-leave/add-sickleave.dart +++ b/lib/screens/patient-sick-leave/patient_sick_leave_screen.dart @@ -3,14 +3,12 @@ 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/screens/patient-sick-leave/add_patient_sick_leave_screen.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'; @@ -20,15 +18,12 @@ 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:doctor_app_flutter/widgets/transitions/slide_up_page.dart'; import 'package:flutter/material.dart'; -import 'package:hexcolor/hexcolor.dart'; import 'package:provider/provider.dart'; -class AddSickLeavScreen extends StatelessWidget { +class PatientSickLeaveScreen extends StatelessWidget { PatiantInformtion patient; @override @@ -299,13 +294,13 @@ class AddSickLeavScreen extends StatelessWidget { context, SlideUpPageRoute( fullscreenDialog: true, - widget: SickLeaveScreen( - appointmentNo: isExtend == true + widget: AddPatientSickLeaveScreen( + appointmentNo: isExtend ? extendedData.appointmentNo : patient.appointmentNo, //extendedData.appointmentNo, patientMRN: - isExtend == true ? extendedData.patientMRN : patient.patientMRN, + isExtend ? extendedData.patientMRN : patient.patientMRN, isExtended: isExtend, extendedData: extendedData, patient: patient), diff --git a/lib/screens/sick-leave/show-sickleave.dart b/lib/screens/sick-leave/show-sickleave.dart deleted file mode 100644 index 726524d8..00000000 --- a/lib/screens/sick-leave/show-sickleave.dart +++ /dev/null @@ -1,198 +0,0 @@ -import 'package:doctor_app_flutter/core/viewModel/sick_leave_view_model.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/util/date-utils.dart'; -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-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/rounded_container_widget.dart'; -import 'package:flutter/material.dart'; - -class ShowSickLeaveScreen extends StatelessWidget { - PatiantInformtion patient; - - @override - Widget build(BuildContext context) { - final routeArgs = ModalRoute.of(context).settings.arguments as Map; - patient = routeArgs['patient']; - return BaseView( - onModelReady: (model) => - model.getSickLeave(patient.patientMRN ?? patient.patientId), - builder: (_, model, w) => AppScaffold( - baseViewModel: model, - isShowAppBar: true, - backgroundColor: Colors.grey[100], - appBar: PatientProfileAppBar( - patient, - ), - body: SingleChildScrollView( - child: Column( - children: [ - // PatientProfileHeaderNewDesign( - // patient, routeArgs['patientType'], routeArgs['arrivalType']), - model.getAllSIckLeave.length > 0 - ? Column( - children: model.getAllSIckLeave - .map((GetAllSickLeaveResponse item) { - return RoundedContainer( - margin: EdgeInsets.all(10), - child: Column( - children: [ - Container( - decoration: BoxDecoration( - border: Border( - left: BorderSide( - color: item.status == 1 - ? Colors.yellow[800] - : item.status == 2 - ? Colors.green - : Colors.black, - width: 5.0, - ))), - 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.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, - ), - ), - Row( - children: [ - AppText( - TranslationBase.of( - context) - .daysSickleave), - AppText( - item.noOfDays - .toString(), - fontWeight: - FontWeight.bold, - ), - ], - ), - Row( - children: [ - AppText( - TranslationBase.of( - context) - .startDate + - ' ', - ), - Flexible( - child: AppText( - AppDateUtils - .convertStringToDateFormat( - item.startDate, - 'dd-MMM-yyyy'), - fontWeight: - FontWeight.bold, - )) - ], - ), - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, - children: [ - AppText( - item.remarks ?? "", - ), - (item.status == 1) - ? IconButton( - icon: Image.asset( - 'assets/images/edit.png'), - - // color: Colors.green, //Colors.black, - onPressed: () => - { - if (item.status == - 1) - { - DrAppToastMsg.showErrorToast( - TranslationBase.of(context) - .sickleaveonhold) - } - // else - // { - // openSickLeave( - // context, - // true, - // extendedData: - // item) - // } - }, - ) - : SizedBox() - ]), - ], - ), - SizedBox( - width: 20, - ), - ], - ), - ), - ], - )), - ], - )); - }).toList(), - ) - : Center( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox( - height: 100, - ), - Image.asset('assets/images/no-data.png'), - Padding( - padding: const EdgeInsets.all(8.0), - child: AppText( - TranslationBase.of(context).noSickLeave), - ) - ], - ), - ) - ], - ), - ), - ), - ); - } -} From 9a5eff8c8b9a7b5d265e7e499fbb2fd61a368657 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 21 Sep 2021 16:52:55 +0300 Subject: [PATCH 7/9] sick leave fixes --- .../sick_leave/sickleave_service.dart | 9 +- lib/core/viewModel/sick_leave_view_model.dart | 51 +- .../sick_leave_statisitics_model.dart | 24 + .../add_patient_sick_leave_screen.dart | 522 ++++++++---------- .../patient_sick_leave_screen.dart | 27 +- .../profile/note/progress_note_screen.dart | 2 +- lib/util/date-utils.dart | 4 +- 7 files changed, 317 insertions(+), 322 deletions(-) create mode 100644 lib/models/sickleave/sick_leave_statisitics_model.dart 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 2b3062ee..070fd862 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 @@ -7,11 +7,12 @@ import 'package:doctor_app_flutter/core/viewModel/leave_rechdule_response.dart'; import 'package:doctor_app_flutter/models/sickleave/add_sickleave_request.dart'; import 'package:doctor_app_flutter/models/sickleave/extend_sick_leave_request.dart'; import 'package:doctor_app_flutter/models/sickleave/get_all_sickleave_response.dart'; +import 'package:doctor_app_flutter/models/sickleave/sick_leave_statisitics_model.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; class SickLeaveService extends BaseService { - Map get sickLeavestatisitics => _statistics; - Map _statistics = {}; + SickLeaveStatisticsModel get sickLeavestatisitics => _statistics; + SickLeaveStatisticsModel _statistics = SickLeaveStatisticsModel(); List get getOffTimeList => offTime; List offTime = []; List get getReasons => reasonse; @@ -40,8 +41,8 @@ class SickLeaveService extends BaseService { GET_SICKLEAVE_STATISTIC, onSuccess: (dynamic response, int statusCode) { print(response); - _statistics = {}; - _statistics = response['SickLeaveStatistics']; + + _statistics = SickLeaveStatisticsModel.fromJson(response['SickLeaveStatistics']); }, onFailure: (String error, int statusCode) { hasError = true; diff --git a/lib/core/viewModel/sick_leave_view_model.dart b/lib/core/viewModel/sick_leave_view_model.dart index bc7c9568..7a7f4575 100644 --- a/lib/core/viewModel/sick_leave_view_model.dart +++ b/lib/core/viewModel/sick_leave_view_model.dart @@ -1,25 +1,40 @@ import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/core/service/patient/patient_service.dart'; import 'package:doctor_app_flutter/core/service/patient_medical_file/sick_leave/sickleave_service.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/models/sickleave/add_sickleave_request.dart'; import 'package:doctor_app_flutter/models/sickleave/get_all_sickleave_response.dart'; +import 'package:doctor_app_flutter/models/sickleave/sick_leave_statisitics_model.dart'; import '../../locator.dart'; import 'base_view_model.dart'; class SickLeaveViewModel extends BaseViewModel { SickLeaveService _sickLeaveService = locator(); - get sickLeaveStatistics => _sickLeaveService.sickLeavestatisitics; - get getAllSIckLeave => _sickLeaveService.getAllSickLeave; + PatientService _patientService = locator(); + + SickLeaveStatisticsModel get sickLeaveStatistics => + _sickLeaveService.sickLeavestatisitics; + get getAllSIckLeave => _sickLeaveService.getAllSickLeave; List get allOffTime => _sickLeaveService.getOffTimeList; + List get allReasons => _sickLeaveService.getReasons; + List get coveringDoctors => _sickLeaveService.coveringDoctorsList; + List get sickLeaveDoctor => _sickLeaveService.getAllSickLeaveDoctor; + get getReschduleLeave => _sickLeaveService.getAllRescheduleLeave; + get postSechedule => _sickLeaveService.postReschedule; - get getAllSIckLeavePatient => - [..._sickLeaveService.getAllSickLeavePatient, ..._sickLeaveService.getAllSickLeaveDoctor]; + + get getAllSIckLeavePatient => [ + ..._sickLeaveService.getAllSickLeavePatient, + ..._sickLeaveService.getAllSickLeaveDoctor + ]; + Future addSickLeave(AddSickLeaveRequest addSickLeaveRequest) async { setState(ViewState.BusyLocal); await _sickLeaveService.addSickLeave(addSickLeaveRequest); @@ -60,12 +75,36 @@ class SickLeaveViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getSickLeavePatient(patientMRN) async { - setState(ViewState.Busy); + Future getSickLeavePatient(patientMRN, {bool isLocalBusy = false}) async { + if (isLocalBusy) + setState(ViewState.BusyLocal); + else + setState(ViewState.Busy); await _sickLeaveService.getSickLeavePatient(patientMRN); if (_sickLeaveService.hasError) { error = _sickLeaveService.error; setState(ViewState.ErrorLocal); + + } else + setState(ViewState.Idle); + } + + Future getSickLeaveForPatient(PatiantInformtion patient, {bool isLocalBusy = false}) async { + if (isLocalBusy) + setState(ViewState.BusyLocal); + else + setState(ViewState.Busy); + var patientMRN = patient.patientMRN ?? patient.patientId; + var services = [_sickLeaveService.getSickLeavePatient(patientMRN),_sickLeaveService.getSickLeaveDoctor(patientMRN) ]; + + final results = await Future.wait(services); + if (_sickLeaveService.hasError) { + error = _sickLeaveService.error; + // if (isLocalBusy) + setState(ViewState.ErrorLocal); + // else + // setState(ViewState.Error); + } else setState(ViewState.Idle); } diff --git a/lib/models/sickleave/sick_leave_statisitics_model.dart b/lib/models/sickleave/sick_leave_statisitics_model.dart new file mode 100644 index 00000000..f679807c --- /dev/null +++ b/lib/models/sickleave/sick_leave_statisitics_model.dart @@ -0,0 +1,24 @@ +class SickLeaveStatisticsModel { + String recommendedSickLeaveDays; + int totalLeavesByAllClinics; + int totalLeavesByDoctor; + + SickLeaveStatisticsModel( + {this.recommendedSickLeaveDays, + this.totalLeavesByAllClinics, + this.totalLeavesByDoctor}); + + SickLeaveStatisticsModel.fromJson(Map json) { + recommendedSickLeaveDays = json['recommendedSickLeaveDays']; + totalLeavesByAllClinics = json['totalLeavesByAllClinics']; + totalLeavesByDoctor = json['totalLeavesByDoctor']; + } + + Map toJson() { + final Map data = new Map(); + data['recommendedSickLeaveDays'] = this.recommendedSickLeaveDays; + data['totalLeavesByAllClinics'] = this.totalLeavesByAllClinics; + data['totalLeavesByDoctor'] = this.totalLeavesByDoctor; + return data; + } +} diff --git a/lib/screens/patient-sick-leave/add_patient_sick_leave_screen.dart b/lib/screens/patient-sick-leave/add_patient_sick_leave_screen.dart index c32eed2c..a5ba8819 100644 --- a/lib/screens/patient-sick-leave/add_patient_sick_leave_screen.dart +++ b/lib/screens/patient-sick-leave/add_patient_sick_leave_screen.dart @@ -5,11 +5,13 @@ import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/viewModel/patient_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/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/models/sickleave/add_sickleave_request.dart'; import 'package:doctor_app_flutter/models/sickleave/get_all_sickleave_response.dart'; import 'package:doctor_app_flutter/routes.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart'; +import 'package:doctor_app_flutter/util/date-utils.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; @@ -28,21 +30,19 @@ import 'package:intl/intl.dart'; Helpers helpers = Helpers(); class AddPatientSickLeaveScreen extends StatefulWidget { - final bool isExtended; - final GetAllSickLeaveResponse extendedData; final appointmentNo; final patientMRN; - final patient; + final PatiantInformtion patient; + final SickLeaveViewModel previousModel; AddPatientSickLeaveScreen( {this.appointmentNo, this.patientMRN, - this.isExtended = false, - this.extendedData, - this.patient}); + this.patient, this.previousModel}); @override - _AddPatientSickLeaveScreenState createState() => _AddPatientSickLeaveScreenState(); + _AddPatientSickLeaveScreenState createState() => + _AddPatientSickLeaveScreenState(); } class _AddPatientSickLeaveScreenState extends State { @@ -53,321 +53,276 @@ class _AddPatientSickLeaveScreenState extends State { TextEditingController _doctorController = new TextEditingController(); TextEditingController _remarkController = new TextEditingController(); - Map profile = {}; AddSickLeaveRequest addSickLeave = AddSickLeaveRequest(); bool isFormSubmitted = false; - void _presentDatePicker(id) { + void _presentDatePicker() { showDatePicker( context: context, initialDate: DateTime.now(), - firstDate: DateTime(2019), - lastDate: DateTime(2050), + firstDate: DateTime(DateTime.now().year-1), + lastDate: DateTime(DateTime.now().year+1), ).then((pickedDate) { if (pickedDate == null) { return; } setState(() { - // var selectedDate = DateFormat.yMd().format(pickedDate); final df = new DateFormat('yyyy-MM-dd'); addSickLeave.startDate = df.format(pickedDate); - - _toDateController.text = addSickLeave.startDate; - //addSickLeave.startDate = selectedDate; + _toDateController.text = AppDateUtils.getDayMonthYearDateFormatted(pickedDate,isMonthShort: true ); }); }); } @override void initState() { - getProfile(); super.initState(); } @override Widget build(BuildContext context) { - return BaseView( + return BaseView( onModelReady: (model) async { - await model.getClinicsList(); - _clinicController.text = getClinicName(model); - _doctorController.text = profile['DoctorName']; + await model.getDoctorProfile(); + _clinicController.text = model.doctorProfile.clinicDescription; + _doctorController.text = model.doctorProfile.doctorName; + await model.preSickLeaveStatistics( + widget.appointmentNo, widget.patientMRN); }, - builder: (_, model, w) => BaseView( - onModelReady: (model2) => model2.preSickLeaveStatistics( - widget.appointmentNo, widget.patientMRN), - builder: (_, model2, w) => GestureDetector( - onTap: () { - FocusScope.of(context).requestFocus(new FocusNode()); - }, - child: AppScaffold( - baseViewModel: model2, - appBar: BottomSheetTitle(title: widget.isExtended == true - ? TranslationBase.of(context).extendSickLeave - : TranslationBase.of(context).addSickLeave,), - isShowAppBar: true, - body: Center( - child: Container( - margin: EdgeInsets.only(top: 10), - child: FractionallySizedBox( - widthFactor: 0.9, - child: ListView( - children: [ - SizedBox( - height: 30, - ), - AppTextFieldCustom( - height: Helpers.getTextFieldHeight(), - hintText: widget.extendedData != null - ? widget.extendedData.noOfDays.toString() - : TranslationBase.of(context).sickLeave + - ' ' + - TranslationBase.of(context).days, - maxLines: 1, - minLines: 1, - dropDownColor: Colors.white, - isTextFieldHasSuffix: true, - inputFormatters: [ - FilteringTextInputFormatter.allow( - RegExp(ONLY_NUMBERS)) - ], - controller: _numberOfDayController, - onChanged: (value) { - setState(() { - addSickLeave.noOfDays = value; - }); + builder: (_, model, w) => GestureDetector( + onTap: () { + FocusScope.of(context).requestFocus(new FocusNode()); + }, + child: AppScaffold( + baseViewModel: model, + appBar: BottomSheetTitle( + title: TranslationBase.of(context).addSickLeave, + ), + isShowAppBar: true, + body: Center( + child: Container( + margin: EdgeInsets.only(top: 10), + child: FractionallySizedBox( + widthFactor: 0.9, + child: ListView( + children: [ + SizedBox( + height: 30, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + hintText: TranslationBase.of(context).sickLeave + + ' ' + + TranslationBase.of(context).days, + maxLines: 1, + minLines: 1, + dropDownColor: Colors.white, + isTextFieldHasSuffix: true, + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp(ONLY_NUMBERS)) + ], + inputType:TextInputType.number, + controller: _numberOfDayController, + onChanged: (value) { + if(value.isNotEmpty) + setState(() { + addSickLeave.noOfDays = value; + }); - if (widget.extendedData != null) { - widget.extendedData.noOfDays = - int.parse(value); - } - }, - validationError: isFormSubmitted && - (addSickLeave.noOfDays == null) - ? TranslationBase.of(context) - .pleaseEnterNoOfDays - : null, - ), - SizedBox( - height: 10, - ), - AppTextFieldCustom( - height: Helpers.getTextFieldHeight(), - onClick: () { - _presentDatePicker('_selectedToDate'); - }, - hintText: widget.extendedData != null - ? widget.extendedData.startDate - : TranslationBase.of(context) - .sickLeaveDate, - enabled: false, - maxLines: 1, - minLines: 1, - isTextFieldHasSuffix: true, - suffixIcon: IconButton( - icon: Icon(Icons.calendar_today)), - inputFormatters: [ - FilteringTextInputFormatter.allow( - RegExp(ONLY_NUMBERS)) - ], - controller: _toDateController, - onChanged: (value) { - setState(() { - addSickLeave.startDate = value; - }); - if (widget.extendedData != null) { - widget.extendedData.startDate = value; - } - }, - validationError: isFormSubmitted && - (addSickLeave.startDate == null) - ? TranslationBase.of(context) - .pleaseEnterDate - : null, - ), - SizedBox( - height: 5, - ), - AppTextFieldCustom( - height: Helpers.getTextFieldHeight(), - hintText: - TranslationBase.of(context).clinic, - enabled: false, - maxLines: 1, - minLines: 1, - dropDownColor: Colors.white, - isTextFieldHasSuffix: true, - inputFormatters: [ - FilteringTextInputFormatter.allow( - RegExp(ONLY_NUMBERS)) - ], - controller: _clinicController, - onChanged: (value) {}, - ), - SizedBox( - height: 10, - ), - model2.sickLeaveStatistics[ - 'recommendedSickLeaveDays'] != - null - ? Row( - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - SizedBox( - width: 10, - ), - Icon( - DoctorApp.warning, - size: 20, - color: IN_PROGRESS_COLOR, - ), - SizedBox( - width: 10, - ), - AppText( - model2.sickLeaveStatistics[ - 'recommendedSickLeaveDays'], - textAlign: TextAlign.start, - fontSize: 12, - color: IN_PROGRESS_COLOR, - ), - ], - ) - : SizedBox( - height: 10, - ), - SizedBox( - height: 10, - ), - AppTextFieldCustom( - height: Helpers.getTextFieldHeight(), - hintText: - TranslationBase.of(context).doctor, - enabled: false, - maxLines: 1, - minLines: 1, - dropDownColor: Colors.white, - isTextFieldHasSuffix: true, - inputFormatters: [ - FilteringTextInputFormatter.allow( - RegExp(ONLY_NUMBERS)) - ], - controller: _doctorController, - onChanged: (value) {}, - ), - SizedBox( - height: 10, - ), - AppTextFieldCustom( - height: Helpers.getTextFieldHeight(), - hintText: widget.extendedData != null - ? widget.extendedData.remarks - : TranslationBase.of(context).remarks, - maxLines: 30, - minLines: 5, - dropDownColor: Colors.white, - isTextFieldHasSuffix: true, - controller: _remarkController, - onChanged: (value) { - setState(() { - addSickLeave.remarks = value; - }); - if (widget.extendedData != null) { - widget.extendedData.remarks = value; - } - }, - validationError: isFormSubmitted && - (addSickLeave.remarks == null) - ? TranslationBase.of(context) - .pleaseEnterRemarks - : null, - ), - ], + }, + validationError: isFormSubmitted && + (addSickLeave.noOfDays == null) + ? TranslationBase.of(context) + .pleaseEnterNoOfDays + : null, + ), + SizedBox( + height: 10, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + onClick: () { + _presentDatePicker(); + }, + hintText: TranslationBase.of(context) + .sickLeaveDate, + enabled: false, + maxLines: 1, + minLines: 1, + isTextFieldHasSuffix: true, + suffixIcon: IconButton( + icon: Icon(Icons.calendar_today)), + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp(ONLY_NUMBERS)) + ], + controller: _toDateController, + onChanged: (value) { + setState(() { + addSickLeave.startDate = value; + }); + + }, + validationError: isFormSubmitted && + (addSickLeave.startDate == null) + ? TranslationBase.of(context) + .pleaseEnterDate + : null, + ), + SizedBox( + height: 5, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + hintText: TranslationBase.of(context).clinic, + enabled: false, + maxLines: 1, + minLines: 1, + dropDownColor: Colors.white, + isTextFieldHasSuffix: true, + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp(ONLY_NUMBERS)) + ], + controller: _clinicController, + onChanged: (value) {}, + ), + SizedBox( + height: 10, + ), + model.sickLeaveStatistics.recommendedSickLeaveDays!= + null + ? Row( + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + SizedBox( + width: 10, + ), + Icon( + DoctorApp.warning, + size: 20, + color: IN_PROGRESS_COLOR, ), - ), + SizedBox( + width: 10, + ), + AppText( + model.sickLeaveStatistics.recommendedSickLeaveDays, + textAlign: TextAlign.start, + fontSize: 12, + color: IN_PROGRESS_COLOR, + ), + ], + ) + : SizedBox( + height: 10, + ), + SizedBox( + height: 10, ), - ), - bottomSheet: model2.state == ViewState.Busy || - model.state == ViewState.Busy - ? Container( - height: 0, - ) - : Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all( - Radius.circular(0.0), - ), - border: Border.all( - color: HexColor('#707070'), width: 0), - ), - height: SizeConfig.heightMultiplier * - (SizeConfig.isHeightVeryShort ? 12 : 10), - width: double.infinity, - child: Column( - children: [ - SizedBox( - height: 10, - ), - FractionallySizedBox( - widthFactor: 0.9, - child: AppButton( - title: widget.isExtended == true - ? TranslationBase.of(context).extend - : TranslationBase.of(context) - .addSickLeaverequest, - color: Colors.green, - onPressed: () async { - submitForm(model2); - }), - ), - SizedBox( - height: 5, - ), - ], - ), - )), - ))); + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + hintText: TranslationBase.of(context).doctor, + enabled: false, + maxLines: 1, + minLines: 1, + dropDownColor: Colors.white, + isTextFieldHasSuffix: true, + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp(ONLY_NUMBERS)) + ], + controller: _doctorController, + onChanged: (value) {}, + ), + SizedBox( + height: 10, + ), + AppTextFieldCustom( + height: Helpers.getTextFieldHeight(), + hintText: TranslationBase.of(context).remarks, + maxLines: 30, + minLines: 5, + dropDownColor: Colors.white, + isTextFieldHasSuffix: true, + controller: _remarkController, + onChanged: (value) { + setState(() { + addSickLeave.remarks = value; + }); + }, + ), + ], + ), + ), + ), + ), + bottomSheet: model.state == ViewState.Busy || + model.state == ViewState.Busy + ? Container( + height: 0, + ) + : Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(0.0), + ), + border: Border.all( + color: HexColor('#707070'), width: 0), + ), + height: SizeConfig.heightMultiplier * + (SizeConfig.isHeightVeryShort ? 12 : 10), + width: double.infinity, + child: Column( + children: [ + SizedBox( + height: 10, + ), + FractionallySizedBox( + widthFactor: 0.9, + child: AppButton( + title: TranslationBase.of(context) + .addSickLeaverequest, + color: Colors.green, + onPressed: () async { + submitForm(model); + }), + ), + SizedBox( + height: 5, + ), + ], + ), + )), + )); } - submitForm(SickLeaveViewModel model2) async { + submitForm(SickLeaveViewModel model) async { { - if (widget.isExtended) { - GifLoaderDialogUtils.showMyDialog(context); - await model2.extendSickLeave(widget.extendedData); - if (model2.state == ViewState.ErrorLocal) { - Helpers.showErrorToast(model2.error); - } else { - DrAppToastMsg.showSuccesToast( - TranslationBase.of(context).replySuccessfully); - Navigator.of(context).popUntil((route) { - return route.settings.name == PATIENTS_PROFILE; - }); - Navigator.of(context) - .pushNamed(ADD_SICKLEAVE, arguments: {'patient': widget.patient}); - } - - GifLoaderDialogUtils.hideDialog(context); - } else { try { setState(() { isFormSubmitted = true; }); if (addSickLeave.noOfDays == null || - addSickLeave.startDate == null || - addSickLeave.remarks == null) { + addSickLeave.startDate == null ) { return; } 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); + await model.addSickLeave(addSickLeave); + if (model.state == ViewState.ErrorLocal) { + Helpers.showErrorToast(model.error); } else { + await widget.previousModel + .getSickLeaveForPatient(widget.patient, isLocalBusy: true); DrAppToastMsg.showSuccesToast( TranslationBase.of(context).replySuccessfully); + Navigator.of(context).pop(); } GifLoaderDialogUtils.hideDialog(context); @@ -375,21 +330,8 @@ class _AddPatientSickLeaveScreenState extends State { } catch (err) { print(err); } - } - } - } - getProfile() async { - Map p = await sharedPref.getObj(DOCTOR_PROFILE); - setState(() { - this.profile = p; - }); + } } - getClinicName(model) { - var clinicInfo = model.clinicsList - .where((i) => i['ClinicID'] == this.profile['ClinicID']) - .toList(); - return clinicInfo.length > 0 ? clinicInfo[0]['ClinicDescription'] : ""; - } } diff --git a/lib/screens/patient-sick-leave/patient_sick_leave_screen.dart b/lib/screens/patient-sick-leave/patient_sick_leave_screen.dart index 55114803..c38aab4a 100644 --- a/lib/screens/patient-sick-leave/patient_sick_leave_screen.dart +++ b/lib/screens/patient-sick-leave/patient_sick_leave_screen.dart @@ -6,7 +6,6 @@ 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/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/patient-sick-leave/add_patient_sick_leave_screen.dart'; import 'package:doctor_app_flutter/util/date-utils.dart'; @@ -35,9 +34,7 @@ class PatientSickLeaveScreen extends StatelessWidget { bool isInpatient = routeArgs['isInpatient']; return BaseView( onModelReady: (model) async { - await model - .getSickLeavePatient(patient.patientMRN ?? patient.patientId); - await model.getSickLeaveDoctor(patient.patientMRN ?? patient.patientId); + await model.getSickLeaveForPatient(patient); }, builder: (_, model, w) => AppScaffold( baseViewModel: model, @@ -94,10 +91,7 @@ class PatientSickLeaveScreen extends StatelessWidget { "Leave Screen", eventAction: "apply For Sick Leave", ); - openSickLeave( - context, - false, - ); + openSickLeave(context, model); }), ], ) @@ -288,22 +282,17 @@ class PatientSickLeaveScreen extends StatelessWidget { ); } - openSickLeave(BuildContext context, isExtend, - {GetAllSickLeaveResponse extendedData}) { + openSickLeave(BuildContext context, model) { Navigator.push( context, SlideUpPageRoute( fullscreenDialog: true, widget: AddPatientSickLeaveScreen( - appointmentNo: isExtend - ? extendedData.appointmentNo - : patient.appointmentNo, - //extendedData.appointmentNo, - patientMRN: - isExtend ? extendedData.patientMRN : patient.patientMRN, - isExtended: isExtend, - extendedData: extendedData, - patient: patient), + appointmentNo: patient.appointmentNo, + patientMRN: patient.patientMRN, + patient: patient, + previousModel: model, + ), ), ); } diff --git a/lib/screens/patients/profile/note/progress_note_screen.dart b/lib/screens/patients/profile/note/progress_note_screen.dart index c43b1ab8..054817c2 100644 --- a/lib/screens/patients/profile/note/progress_note_screen.dart +++ b/lib/screens/patients/profile/note/progress_note_screen.dart @@ -496,7 +496,7 @@ class _ProgressNoteState extends State { isArabic: projectViewModel .isArabic, - isMonthshort: true) + isMonthShort: true) : AppDateUtils .getDayMonthYearDateFormatted( DateTime.now(), diff --git a/lib/util/date-utils.dart b/lib/util/date-utils.dart index c4819ad9..89564833 100644 --- a/lib/util/date-utils.dart +++ b/lib/util/date-utils.dart @@ -297,11 +297,11 @@ class AppDateUtils { /// get data formatted like 26 Apr 2020 /// [dateTime] convert DateTime to data formatted static String getDayMonthYearDateFormatted(DateTime dateTime, - {bool isArabic = false, bool isMonthshort = false}) { + {bool isArabic = false, bool isMonthShort = false}) { if (dateTime != null) return dateTime.day.toString() + " " + - "${isArabic ? getMonthArabic(dateTime.month) : isMonthshort ? getMonth(dateTime.month).toString().substring(0, 3) : getMonth(dateTime.month)}" + + "${isArabic ? getMonthArabic(dateTime.month) : isMonthShort ? getMonth(dateTime.month).toString().substring(0, 3) : getMonth(dateTime.month)}" + " " + dateTime.year.toString(); else From 87b70ff9058f412a04e167aa3c4b3937576e9cc2 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 21 Sep 2021 17:24:05 +0300 Subject: [PATCH 8/9] fix last issue --- .../add_patient_sick_leave_screen.dart | 16 +- .../patient_sick_leave_screen.dart | 314 +++++++++--------- 2 files changed, 166 insertions(+), 164 deletions(-) diff --git a/lib/screens/patient-sick-leave/add_patient_sick_leave_screen.dart b/lib/screens/patient-sick-leave/add_patient_sick_leave_screen.dart index a5ba8819..1d2e3c10 100644 --- a/lib/screens/patient-sick-leave/add_patient_sick_leave_screen.dart +++ b/lib/screens/patient-sick-leave/add_patient_sick_leave_screen.dart @@ -55,7 +55,7 @@ class _AddPatientSickLeaveScreenState extends State { AddSickLeaveRequest addSickLeave = AddSickLeaveRequest(); bool isFormSubmitted = false; - + FocusNode focusNode; void _presentDatePicker() { showDatePicker( context: context, @@ -76,6 +76,7 @@ class _AddPatientSickLeaveScreenState extends State { @override void initState() { + focusNode = new FocusNode(); super.initState(); } @@ -143,6 +144,7 @@ class _AddPatientSickLeaveScreenState extends State { AppTextFieldCustom( height: Helpers.getTextFieldHeight(), onClick: () { + Helpers.hideKeyboard(context); _presentDatePicker(); }, hintText: TranslationBase.of(context) @@ -208,11 +210,13 @@ class _AddPatientSickLeaveScreenState extends State { SizedBox( width: 10, ), - AppText( - model.sickLeaveStatistics.recommendedSickLeaveDays, - textAlign: TextAlign.start, - fontSize: 12, - color: IN_PROGRESS_COLOR, + Expanded( + child: AppText( + model.sickLeaveStatistics.recommendedSickLeaveDays, + textAlign: TextAlign.start, + fontSize: 12, + color: IN_PROGRESS_COLOR, + ), ), ], ) diff --git a/lib/screens/patient-sick-leave/patient_sick_leave_screen.dart b/lib/screens/patient-sick-leave/patient_sick_leave_screen.dart index c38aab4a..964c3a13 100644 --- a/lib/screens/patient-sick-leave/patient_sick_leave_screen.dart +++ b/lib/screens/patient-sick-leave/patient_sick_leave_screen.dart @@ -100,173 +100,171 @@ class PatientSickLeaveScreen extends StatelessWidget { ? 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) { - 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(20), - child: InkWell( - child: Column( - children: [ - Row( - crossAxisAlignment: - CrossAxisAlignment.start, - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - Expanded( - // width: MediaQuery.of(context).size.width*0.51, - child: AppText( - Helpers.capitalize( - item.doctorName ?? ""), - fontSize: 18, - color: Color(0xff2e303a), - fontWeight: FontWeight.w700, - fontFamily: 'Poppins', - textOverflow: - TextOverflow.ellipsis, - ), - ), - ]), - SizedBox( - height: 10, - ), - Row( + child: ListView.builder( + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemCount: model.getAllSIckLeavePatient.length, + itemBuilder: (BuildContext ctxt, int index) { + 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(20), + child: InkWell( + child: Column( + children: [ + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, 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, - ), + Expanded( + // width: MediaQuery.of(context).size.width*0.51, + child: AppText( + Helpers.capitalize( + item.doctorName ?? ""), + fontSize: 18, + color: Color(0xff2e303a), + fontWeight: FontWeight.w700, + fontFamily: 'Poppins', + textOverflow: + TextOverflow.ellipsis, ), ), - SizedBox( - width: 10, + ]), + SizedBox( + height: 10, + ), + 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, + ), ), - Column( - children: [ - CustomRow( - label: TranslationBase.of( - context) - .daysSickleave + - ": ", - labelSize: SizeConfig - .getTextMultiplierBasedOnWidth() * - 3.3, - valueSize: SizeConfig - .getTextMultiplierBasedOnWidth() * - 4, - value: (item.sickLeaveDays - .toString() != - null && - item.sickLeaveDays - .toString() != - "null") - ? item.sickLeaveDays - .toString() - : item.noOfDays - .toString(), - ), - CustomRow( - label: TranslationBase.of( - context) - .startDate + - ' ' ?? - "", - labelSize: SizeConfig - .getTextMultiplierBasedOnWidth() * - 3.3, - valueSize: SizeConfig - .getTextMultiplierBasedOnWidth() * - 4, - value: AppDateUtils - .getDayMonthYearDateFormatted( - item.startDate.contains( - "/Date(") - ? AppDateUtils - .convertStringToDate( - item - .startDate) - : DateTime.parse( - item.startDate), - ), + ), + SizedBox( + width: 10, + ), + Column( + children: [ + CustomRow( + label: TranslationBase.of( + context) + .daysSickleave + + ": ", + labelSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3.3, + valueSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 4, + value: (item.sickLeaveDays + .toString() != + null && + item.sickLeaveDays + .toString() != + "null") + ? item.sickLeaveDays + .toString() + : item.noOfDays + .toString(), + ), + CustomRow( + label: TranslationBase.of( + context) + .startDate + + ' ' ?? + "", + labelSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3.3, + valueSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 4, + value: AppDateUtils + .getDayMonthYearDateFormatted( + item.startDate.contains( + "/Date(") + ? AppDateUtils + .convertStringToDate( + item + .startDate) + : DateTime.parse( + item.startDate), ), - CustomRow( - label: TranslationBase.of( - context) - .endDate + - ' ' ?? - "", - labelSize: SizeConfig - .getTextMultiplierBasedOnWidth() * - 3.3, - valueSize: SizeConfig - .getTextMultiplierBasedOnWidth() * - 4, - 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 ?? - ""), - ), - ), + ), + CustomRow( + label: TranslationBase.of( + context) + .endDate + + ' ' ?? + "", + labelSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3.3, + valueSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 4, + 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, - ), - ], - ), - ], - ), + ), + ], + crossAxisAlignment: + CrossAxisAlignment.start, + ), + ], + ), + ], ), ), ), - ], - ); - }), - ), + ), + ], + ); + }), ), ) : patient.patientStatusType != 43 From b23fe5ee1b6f32a319672ba4aff7a1406bfd4219 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 21 Sep 2021 17:32:40 +0300 Subject: [PATCH 9/9] add selected date --- .../patient-sick-leave/add_patient_sick_leave_screen.dart | 6 +++--- .../patient-sick-leave/patient_sick_leave_screen.dart | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/screens/patient-sick-leave/add_patient_sick_leave_screen.dart b/lib/screens/patient-sick-leave/add_patient_sick_leave_screen.dart index 1d2e3c10..3141e475 100644 --- a/lib/screens/patient-sick-leave/add_patient_sick_leave_screen.dart +++ b/lib/screens/patient-sick-leave/add_patient_sick_leave_screen.dart @@ -52,14 +52,14 @@ class _AddPatientSickLeaveScreenState extends State { TextEditingController _clinicController = new TextEditingController(); TextEditingController _doctorController = new TextEditingController(); TextEditingController _remarkController = new TextEditingController(); + DateTime currentDate; AddSickLeaveRequest addSickLeave = AddSickLeaveRequest(); bool isFormSubmitted = false; - FocusNode focusNode; void _presentDatePicker() { showDatePicker( context: context, - initialDate: DateTime.now(), + initialDate: currentDate??DateTime.now(), firstDate: DateTime(DateTime.now().year-1), lastDate: DateTime(DateTime.now().year+1), ).then((pickedDate) { @@ -69,6 +69,7 @@ class _AddPatientSickLeaveScreenState extends State { setState(() { final df = new DateFormat('yyyy-MM-dd'); addSickLeave.startDate = df.format(pickedDate); + currentDate = pickedDate; _toDateController.text = AppDateUtils.getDayMonthYearDateFormatted(pickedDate,isMonthShort: true ); }); }); @@ -76,7 +77,6 @@ class _AddPatientSickLeaveScreenState extends State { @override void initState() { - focusNode = new FocusNode(); super.initState(); } diff --git a/lib/screens/patient-sick-leave/patient_sick_leave_screen.dart b/lib/screens/patient-sick-leave/patient_sick_leave_screen.dart index 964c3a13..fa6228f1 100644 --- a/lib/screens/patient-sick-leave/patient_sick_leave_screen.dart +++ b/lib/screens/patient-sick-leave/patient_sick_leave_screen.dart @@ -121,6 +121,7 @@ class PatientSickLeaveScreen extends StatelessWidget { child: InkWell( child: Column( children: [ + if(item.doctorName != null) Row( crossAxisAlignment: CrossAxisAlignment.start,