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,
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

@ -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<SickLeaveScreen> {
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<SickLeaveScreen> {
@override
Widget build(BuildContext context) {
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>(
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<SickLeaveScreen> {
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: <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),
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: <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 {
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<SickLeaveScreen> {
}
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'] : "";
}
}

@ -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({

Loading…
Cancel
Save