From 214dfecb3ce5a7cd2413be64bf73d90502fadcd6 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Thu, 18 Feb 2021 14:07:21 +0300 Subject: [PATCH] DA-422 --- lib/config/localized_values.dart | 4 + lib/screens/sick-leave/add-sickleave.dart | 10 +- lib/screens/sick-leave/sick_leave.dart | 150 ++++++++++++---------- lib/util/translations_delegate_base.dart | 3 + 4 files changed, 101 insertions(+), 66 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 6daeb5a2..f9f7d6b6 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -734,4 +734,8 @@ const Map> localizedValues = { 'orderNo': {'en': "Order No : ", 'ar': "رقم الطلب"}, 'infoStatus': {'en': "Info Status", 'ar': "حالة المعلومات"}, 'doctorResponse': {'en': "Doctor Response", 'ar': "استجابة الطبيب"}, + 'sickleaveonhold': { + 'en': "A Sick leave is on Hold status for this patient", + 'ar': "الإجازة المرضية في حالة الانتظار لهذا المريض" + }, }; diff --git a/lib/screens/sick-leave/add-sickleave.dart b/lib/screens/sick-leave/add-sickleave.dart index 81d62513..ad74b760 100644 --- a/lib/screens/sick-leave/add-sickleave.dart +++ b/lib/screens/sick-leave/add-sickleave.dart @@ -6,6 +6,7 @@ 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/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/patient-page-header-widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; @@ -122,7 +123,14 @@ class AddSickLeavScreen extends StatelessWidget { ), // color: Colors.green, //Colors.black, onPressed: () => { - if (item.status != 1) + if (item.status == 1) + { + DrAppToastMsg.showErrorToast( + TranslationBase.of( + context) + .sickleaveonhold) + } + else { openSickLeave(context, true, extendedData: item) diff --git a/lib/screens/sick-leave/sick_leave.dart b/lib/screens/sick-leave/sick_leave.dart index 103c133b..f8433fb0 100644 --- a/lib/screens/sick-leave/sick_leave.dart +++ b/lib/screens/sick-leave/sick_leave.dart @@ -84,10 +84,10 @@ class _SickLeaveScreenState extends State { onModelReady: (model2) => model2.preSickLeaveStatistics( widget.appointmentNo, widget.patientMRN), builder: (_, model2, w) => GestureDetector( - onTap: (){ - FocusScope.of(context).requestFocus(new FocusNode()); - }, - child: AppScaffold( + onTap: () { + FocusScope.of(context).requestFocus(new FocusNode()); + }, + child: AppScaffold( baseViewModel: model2, isShowAppBar: false, body: Center( @@ -113,10 +113,12 @@ class _SickLeaveScreenState extends State { borderRadius: BorderRadius.all(Radius.circular(6.0)), border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), + width: 1.0, + color: HexColor("#CCCCCC"))), padding: EdgeInsets.all(5), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ AppTextFormField( borderColor: Colors.white, @@ -144,14 +146,15 @@ class _SickLeaveScreenState extends State { Container( margin: EdgeInsets.only(left: 10, right: 10), decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), + borderRadius: BorderRadius.all( + Radius.circular(6.0)), border: Border.all( width: 1.0, color: HexColor("#CCCCCC"))), padding: EdgeInsets.all(5), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ // AppText( // TranslationBase.of(context).sickLeaveDate, @@ -168,7 +171,8 @@ class _SickLeaveScreenState extends State { textInputType: TextInputType.number, controller: _toDateController, onTap: () { - _presentDatePicker('_selectedToDate'); + _presentDatePicker( + '_selectedToDate'); }, inputFormatter: ONLY_DATE, onChanged: (value) { @@ -184,8 +188,8 @@ class _SickLeaveScreenState extends State { margin: EdgeInsets.only( top: 10, left: 10, right: 10), decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), + borderRadius: BorderRadius.all( + Radius.circular(6.0)), border: Border.all( width: 1.0, color: HexColor("#CCCCCC"))), @@ -193,7 +197,8 @@ class _SickLeaveScreenState extends State { child: Padding( padding: EdgeInsets.only( top: SizeConfig.widthMultiplier * 0.9, - bottom: SizeConfig.widthMultiplier * 0.9, + bottom: + SizeConfig.widthMultiplier * 0.9, right: SizeConfig.widthMultiplier * 3, left: SizeConfig.widthMultiplier * 3), child: Column( @@ -209,55 +214,59 @@ class _SickLeaveScreenState extends State { 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( + 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: < + Widget>[ + 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, - fontSize: SizeConfig - .textMultiplier * - 2.1, - color: - Colors.grey, + textAlign: + TextAlign + .end, ), - ], - ); - }).toList(); - }, - onChanged: (newValue) => - {}, - items: model - .getClinicNameList() - .map((item) { - return DropdownMenuItem( - value: - item.toString(), - child: Text( - item, - textAlign: - TextAlign.end, - ), - ); - }).toList(), - ))), + ); + }).toList(), + ))), ), ], ) @@ -285,7 +294,8 @@ class _SickLeaveScreenState extends State { borderRadius: BorderRadius.all(Radius.circular(6.0)), border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), + width: 1.0, + color: HexColor("#CCCCCC"))), padding: EdgeInsets.all(5), child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -317,7 +327,8 @@ class _SickLeaveScreenState extends State { borderRadius: BorderRadius.all(Radius.circular(6.0)), border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), + width: 1.0, + color: HexColor("#CCCCCC"))), padding: EdgeInsets.all(5), child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -364,7 +375,8 @@ class _SickLeaveScreenState extends State { model2.sickleaveResponse[ 'ListSickLeavesToExtent'] ['success']); - Navigator.of(context).popUntil((route) { + Navigator.of(context) + .popUntil((route) { return route.settings.name == PATIENTS_PROFILE; }); @@ -396,7 +408,7 @@ class _SickLeaveScreenState extends State { ), ), ), - ))); + ))); } void _validateInputs(model2) async { @@ -413,7 +425,15 @@ class _SickLeaveScreenState extends State { } else { addSickLeave.patientMRN = widget.patient.patientMRN.toString(); addSickLeave.appointmentNo = widget.patient.appointmentNo.toString(); - model2.addSickLeave(addSickLeave).then((value) => print(value)); + await model2.addSickLeave(addSickLeave).then((value) => print(value)); + + 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}); } } catch (err) { print(err); diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index 761edfbf..311e5f78 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -1120,6 +1120,9 @@ class TranslationBase { String get infoStatus => localizedValues['infoStatus'][locale.languageCode]; String get doctorResponse => localizedValues['doctorResponse'][locale.languageCode]; + + String get sickleaveonhold => + localizedValues['sickleaveonhold'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate {