fix sick leave design

merge-requests/847/head
Elham Rababh 4 years ago
parent 29336a9ef3
commit ff07686bf7

@ -129,7 +129,7 @@ class AddSickLeavScreen extends StatelessWidget {
bgColor: Colors.black, bgColor: Colors.black,
widget: Container( widget: Container(
color: Colors.white, color: Colors.white,
padding: EdgeInsets.all(10), padding: EdgeInsets.all(20),
child: InkWell( child: InkWell(
child: Column( child: Column(
children: [ children: [
@ -144,7 +144,7 @@ class AddSickLeavScreen extends StatelessWidget {
child: AppText( child: AppText(
Helpers.capitalize( Helpers.capitalize(
item.doctorName ?? ""), item.doctorName ?? ""),
fontSize: 16, fontSize: 18,
color: Color(0xff2e303a), color: Color(0xff2e303a),
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
fontFamily: 'Poppins', fontFamily: 'Poppins',
@ -153,6 +153,7 @@ class AddSickLeavScreen extends StatelessWidget {
), ),
), ),
]), ]),
SizedBox(height: 10,),
Row( Row(
children: [ children: [
ClipRRect( ClipRRect(
@ -181,6 +182,8 @@ class AddSickLeavScreen extends StatelessWidget {
context) context)
.daysSickleave + .daysSickleave +
": ", ": ",
labelSize: SizeConfig.getTextMultiplierBasedOnWidth() * 3.3,
valueSize: SizeConfig.getTextMultiplierBasedOnWidth() * 4,
value: (item.sickLeaveDays value: (item.sickLeaveDays
.toString() != .toString() !=
null && null &&
@ -198,6 +201,8 @@ class AddSickLeavScreen extends StatelessWidget {
.startDate + .startDate +
' ' ?? ' ' ??
"", "",
labelSize: SizeConfig.getTextMultiplierBasedOnWidth() * 3.3,
valueSize: SizeConfig.getTextMultiplierBasedOnWidth() * 4,
value: AppDateUtils value: AppDateUtils
.getDayMonthYearDateFormatted( .getDayMonthYearDateFormatted(
item.startDate item.startDate
@ -215,6 +220,8 @@ class AddSickLeavScreen extends StatelessWidget {
.endDate + .endDate +
' ' ?? ' ' ??
"", "",
labelSize: SizeConfig.getTextMultiplierBasedOnWidth() * 3.3,
valueSize: SizeConfig.getTextMultiplierBasedOnWidth() * 4,
value: AppDateUtils value: AppDateUtils
.getDayMonthYearDateFormatted( .getDayMonthYearDateFormatted(
item.startDate item.startDate

@ -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/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_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/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:doctor_app_flutter/widgets/shared/text_fields/app_text_form_field.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:hexcolor/hexcolor.dart'; import 'package:hexcolor/hexcolor.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
@ -31,7 +33,14 @@ class SickLeaveScreen extends StatefulWidget {
final appointmentNo; final appointmentNo;
final patientMRN; final patientMRN;
final patient; 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 @override
_SickLeaveScreenState createState() => _SickLeaveScreenState(); _SickLeaveScreenState createState() => _SickLeaveScreenState();
} }
@ -39,9 +48,15 @@ class SickLeaveScreen extends StatefulWidget {
class _SickLeaveScreenState extends State<SickLeaveScreen> { class _SickLeaveScreenState extends State<SickLeaveScreen> {
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
TextEditingController _toDateController = new TextEditingController(); TextEditingController _toDateController = new TextEditingController();
TextEditingController _numberOfController = new TextEditingController();
TextEditingController _clinicController = new TextEditingController();
TextEditingController _doctorController = new TextEditingController();
TextEditingController _remarkController = new TextEditingController();
String _selectedClinic; String _selectedClinic;
Map profile = {}; Map profile = {};
AddSickLeaveRequest addSickLeave = AddSickLeaveRequest(); AddSickLeaveRequest addSickLeave = AddSickLeaveRequest();
void _presentDatePicker(id) { void _presentDatePicker(id) {
showDatePicker( showDatePicker(
context: context, context: context,
@ -72,9 +87,14 @@ class _SickLeaveScreenState extends State<SickLeaveScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BaseView<PatientViewModel>( return BaseView<PatientViewModel>(
onModelReady: (model) => model.getClinicsList(), onModelReady: (model) async {
await model.getClinicsList();
_clinicController.text = getClinicName(model);
_doctorController.text = profile['DoctorName'];
},
builder: (_, model, w) => BaseView<SickLeaveViewModel>( builder: (_, model, w) => BaseView<SickLeaveViewModel>(
onModelReady: (model2) => model2.preSickLeaveStatistics(widget.appointmentNo, widget.patientMRN), onModelReady: (model2) => model2.preSickLeaveStatistics(
widget.appointmentNo, widget.patientMRN),
builder: (_, model2, w) => GestureDetector( builder: (_, model2, w) => GestureDetector(
onTap: () { onTap: () {
FocusScope.of(context).requestFocus(new FocusNode()); FocusScope.of(context).requestFocus(new FocusNode());
@ -92,296 +112,252 @@ class _SickLeaveScreenState extends State<SickLeaveScreen> {
widthFactor: 0.9, widthFactor: 0.9,
child: ListView( child: ListView(
children: [ children: [
// Padding( SizedBox(
// child: AppText( height: 30,
// widget.isExtended == true ),
// ? TranslationBase.of(context) AppTextFieldCustom(
// .extendSickLeave height: Helpers.getTextFieldHeight(),
// : TranslationBase.of(context) hintText: widget.extendedData != null
// .addSickLeave, ? widget.extendedData.noOfDays.toString()
// fontWeight: FontWeight.bold, : TranslationBase.of(context).sickLeave +
// ), ' ' +
// padding: EdgeInsets.all(10)), TranslationBase.of(context).days,
Container( maxLines: 1,
margin: EdgeInsets.only(left: 10, right: 10), minLines: 1,
decoration: BoxDecoration( dropDownColor: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(6.0)),
border: Border.all( isTextFieldHasSuffix: true,
width: 1.0, inputFormatters: [
color: HexColor("#CCCCCC"), FilteringTextInputFormatter.allow(
), RegExp(ONLY_NUMBERS))
color: Colors.white), ],
padding: EdgeInsets.all(5), controller: _numberOfController,
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ onChanged: (value) {
Padding( addSickLeave.noOfDays = value;
padding: EdgeInsets.only(top: 5, left: 10, right: 10), if (widget.extendedData != null) {
child: AppText(TranslationBase.of(context).sickLeave + widget.extendedData.noOfDays =
' ' + int.parse(value);
TranslationBase.of(context).days)), }
AppTextFormField( },
borderColor: Colors.white, // validationError: isFormSubmitted &&
onChanged: (value) { // _selectedMedicationFrequency ==
addSickLeave.noOfDays = value; // null
if (widget.extendedData != null) { // ? TranslationBase
widget.extendedData.noOfDays = int.parse(value); // .of(context)
} // .emptyMessage
}, // : null,
hintText:
widget.extendedData != null ? widget.extendedData.noOfDays.toString() : '',
// validator: (value) {
// return TextValidator().validateName(value);
// },
textInputType: TextInputType.number,
inputFormatter: ONLY_NUMBERS)
]),
), ),
SizedBox( SizedBox(
height: 10, height: 10,
), ),
Container( AppTextFieldCustom(
margin: EdgeInsets.only(left: 10, right: 10), height: Helpers.getTextFieldHeight(),
decoration: BoxDecoration( onClick: () {
borderRadius: BorderRadius.all(Radius.circular(6.0)), _presentDatePicker('_selectedToDate');
border: Border.all(width: 1.0, color: HexColor("#CCCCCC")), },
color: Colors.white, hintText: widget.extendedData != null
), ? widget.extendedData.startDate
padding: EdgeInsets.all(5), : TranslationBase.of(context).sickLeaveDate,
child: Column( enabled: false,
crossAxisAlignment: CrossAxisAlignment.start, maxLines: 1,
children: [ minLines: 1,
Padding( isTextFieldHasSuffix: true,
padding: EdgeInsets.only(top: 5, left: 10, right: 10), suffixIcon: IconButton(
child: AppText( icon: Icon(Icons.calendar_today)),
TranslationBase.of(context).sickLeaveDate, inputFormatters: [
)), FilteringTextInputFormatter.allow(
AppTextFormField( RegExp(ONLY_NUMBERS))
hintText: widget.extendedData != null ? widget.extendedData.startDate : '', ],
borderColor: Colors.white, controller: _toDateController,
prefix: IconButton(icon: Icon(Icons.calendar_today)), onChanged: (value) {
textInputType: TextInputType.number, addSickLeave.startDate = value;
controller: _toDateController, if (widget.extendedData != null) {
onTap: () { widget.extendedData.startDate = value;
_presentDatePicker('_selectedToDate'); }
}, },
inputFormatter: ONLY_DATE, ),
onChanged: (value) {
addSickLeave.startDate = value; SizedBox(
if (widget.extendedData != null) { height: 5,
widget.extendedData.startDate = value; ),
} AppTextFieldCustom(
}), height: Helpers.getTextFieldHeight(),
], hintText:
)), TranslationBase.of(context).clinicName,
Container( enabled: false,
margin: EdgeInsets.only(top: 10, left: 10, right: 10), maxLines: 1,
decoration: BoxDecoration( minLines: 1,
borderRadius: BorderRadius.all(Radius.circular(6.0)), dropDownColor: Colors.white,
border: Border.all(width: 1.0, color: HexColor("#CCCCCC")), isTextFieldHasSuffix: true,
color: Colors.white, inputFormatters: [
), FilteringTextInputFormatter.allow(
width: double.infinity, RegExp(ONLY_NUMBERS))
child: Padding( ],
padding: EdgeInsets.only( controller: _clinicController,
top: SizeConfig.widthMultiplier * 0.9, onChanged: (value) {},
bottom: SizeConfig.widthMultiplier * 0.9, ),
right: SizeConfig.widthMultiplier * 3, SizedBox(
left: SizeConfig.widthMultiplier * 3), height: 10,
child: Column( ),
crossAxisAlignment: CrossAxisAlignment.start, model2.sickLeaveStatistics[
children: [ 'recommendedSickLeaveDays'] !=
Padding( null
padding: EdgeInsets.only(top: 5), ? AppText(
child: AppText( model2.sickLeaveStatistics[
TranslationBase.of(context).clinicName, 'recommendedSickLeaveDays'],
)), fontWeight: FontWeight.bold,
Row( textAlign: TextAlign.start,
mainAxisSize: MainAxisSize.max, fontSize: 15,
children: <Widget>[
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: <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,
textAlign: TextAlign.end,
),
);
}).toList(),
))),
),
],
)
],
),
)),
model2.sickLeaveStatistics['recommendedSickLeaveDays'] != null
? Padding(
child: AppText(
model2.sickLeaveStatistics['recommendedSickLeaveDays'],
fontWeight: FontWeight.bold,
textAlign: TextAlign.start,
),
padding: EdgeInsets.all(10),
) )
: SizedBox( : SizedBox(
height: 10, height: 10,
), ),
Container(
margin: EdgeInsets.only(left: 10, right: 10), SizedBox(
decoration: BoxDecoration( height: 10,
borderRadius: BorderRadius.all(Radius.circular(6.0)), ),
border: Border.all(width: 1.0, color: HexColor("#CCCCCC")),
color: Colors.white, AppTextFieldCustom(
), height: Helpers.getTextFieldHeight(),
padding: EdgeInsets.all(5), hintText:
child: Column( TranslationBase.of(context).doctorName,
crossAxisAlignment: CrossAxisAlignment.start, enabled: false,
children: [ maxLines: 1,
Padding( minLines: 1,
padding: EdgeInsets.only(top: 5, left: 10, right: 10), dropDownColor: Colors.white,
child: AppText( isTextFieldHasSuffix: true,
TranslationBase.of(context).doctorName, inputFormatters: [
)), FilteringTextInputFormatter.allow(
new IgnorePointer( RegExp(ONLY_NUMBERS))
ignoring: true, ],
child: AppTextFormField( controller: _doctorController,
readOnly: true, onChanged: (value) {},
hintText: profile['DoctorName'],
borderColor: Colors.white,
onSaved: (value) {},
// validator: (value) {
// return TextValidator().validateName(value);
// },
inputFormatter: ONLY_NUMBERS))
],
),
), ),
SizedBox( SizedBox(
height: 10, height: 10,
), ),
Container( AppTextFieldCustom(
margin: EdgeInsets.only(left: 10, right: 10), height: Helpers.getTextFieldHeight(),
decoration: BoxDecoration( hintText: widget.extendedData != null
borderRadius: BorderRadius.all(Radius.circular(6.0)), ? widget.extendedData.remarks
border: Border.all(width: 1.0, color: HexColor("#CCCCCC")), : TranslationBase.of(context).remarks,
color: Colors.white, maxLines: 30,
), minLines: 5,
padding: EdgeInsets.all(5), dropDownColor: Colors.white,
child: Column( isTextFieldHasSuffix: true,
crossAxisAlignment: CrossAxisAlignment.start, controller: _remarkController,
children: [ onChanged: (value) {
Padding( addSickLeave.remarks = value;
padding: EdgeInsets.only(top: 5, left: 10, right: 10), if (widget.extendedData != null) {
child: AppText( widget.extendedData.remarks = value;
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;
}
},
)
],
),
), ),
Container(
margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5),
child: Wrap(
alignment: WrapAlignment.center,
children: <Widget>[
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<SickLeaveScreen> {
void _validateInputs(model2) async { void _validateInputs(model2) async {
try { try {
if (addSickLeave.noOfDays == null) { if (addSickLeave.noOfDays == null) {
DrAppToastMsg.showErrorToast(TranslationBase.of(context).pleaseEnterNoOfDays); DrAppToastMsg.showErrorToast(
TranslationBase.of(context).pleaseEnterNoOfDays);
} else if (addSickLeave.remarks == null) { } else if (addSickLeave.remarks == null) {
DrAppToastMsg.showErrorToast(TranslationBase.of(context).pleaseEnterRemarks); DrAppToastMsg.showErrorToast(
TranslationBase.of(context).pleaseEnterRemarks);
} else if (addSickLeave.startDate == null) { } else if (addSickLeave.startDate == null) {
DrAppToastMsg.showErrorToast(TranslationBase.of(context).pleaseEnterDate); DrAppToastMsg.showErrorToast(
TranslationBase.of(context).pleaseEnterDate);
} else { } else {
addSickLeave.patientMRN = widget.patient.patientMRN.toString(); addSickLeave.patientMRN = widget.patient.patientMRN.toString();
addSickLeave.appointmentNo = widget.patient.appointmentNo.toString(); addSickLeave.appointmentNo = widget.patient.appointmentNo.toString();
await model2.addSickLeave(addSickLeave); await model2.addSickLeave(addSickLeave);
if(model2.state == ViewState.ErrorLocal){ if (model2.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(model2.error); Helpers.showErrorToast(model2.error);
} else { } else {
DrAppToastMsg.showSuccesToast(TranslationBase.of(context).replySuccessfully); DrAppToastMsg.showSuccesToast(
TranslationBase.of(context).replySuccessfully);
} }
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
Navigator.of(context).popUntil((route) { Navigator.of(context).popUntil((route) {
return route.settings.name == PATIENTS_PROFILE; 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) { } catch (err) {
print(err); print(err);
@ -423,7 +404,9 @@ class _SickLeaveScreenState extends State<SickLeaveScreen> {
} }
getClinicName(model) { 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'] : ""; return clinicInfo.length > 0 ? clinicInfo[0]['ClinicDescription'] : "";
} }
} }

@ -30,8 +30,6 @@ class AppTextFieldCustom extends StatefulWidget {
final bool isPrscription; final bool isPrscription;
final bool isSecure; final bool isSecure;
final bool focus; final bool focus;
///TODO Rename it to isCustomSearchablFiels
final bool isSearchTextField; final bool isSearchTextField;
AppTextFieldCustom({ AppTextFieldCustom({

Loading…
Cancel
Save