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,274 +112,237 @@ 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)
// .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), AppTextFieldCustom(
padding: EdgeInsets.all(5), height: Helpers.getTextFieldHeight(),
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ hintText: widget.extendedData != null
Padding( ? widget.extendedData.noOfDays.toString()
padding: EdgeInsets.only(top: 5, left: 10, right: 10), : TranslationBase.of(context).sickLeave +
child: AppText(TranslationBase.of(context).sickLeave +
' ' + ' ' +
TranslationBase.of(context).days)), TranslationBase.of(context).days,
AppTextFormField( maxLines: 1,
borderColor: Colors.white, minLines: 1,
dropDownColor: Colors.white,
isTextFieldHasSuffix: true,
inputFormatters: [
FilteringTextInputFormatter.allow(
RegExp(ONLY_NUMBERS))
],
controller: _numberOfController,
onChanged: (value) { onChanged: (value) {
addSickLeave.noOfDays = value; addSickLeave.noOfDays = value;
if (widget.extendedData != null) { if (widget.extendedData != null) {
widget.extendedData.noOfDays = int.parse(value); widget.extendedData.noOfDays =
int.parse(value);
} }
}, },
hintText: // validationError: isFormSubmitted &&
widget.extendedData != null ? widget.extendedData.noOfDays.toString() : '', // _selectedMedicationFrequency ==
// validator: (value) { // null
// return TextValidator().validateName(value); // ? TranslationBase
// }, // .of(context)
textInputType: TextInputType.number, // .emptyMessage
inputFormatter: ONLY_NUMBERS) // : null,
]),
), ),
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)),
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'); _presentDatePicker('_selectedToDate');
}, },
inputFormatter: ONLY_DATE, 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) { onChanged: (value) {
addSickLeave.startDate = value; addSickLeave.startDate = value;
if (widget.extendedData != null) { if (widget.extendedData != null) {
widget.extendedData.startDate = value; 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(), 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[
model2.sickLeaveStatistics['recommendedSickLeaveDays'] != null 'recommendedSickLeaveDays'] !=
? Padding( null
child: AppText( ? AppText(
model2.sickLeaveStatistics['recommendedSickLeaveDays'], model2.sickLeaveStatistics[
'recommendedSickLeaveDays'],
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
textAlign: TextAlign.start, textAlign: TextAlign.start,
), fontSize: 15,
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,
), ),
padding: EdgeInsets.all(5),
child: Column( AppTextFieldCustom(
crossAxisAlignment: CrossAxisAlignment.start, height: Helpers.getTextFieldHeight(),
children: [ hintText:
Padding(
padding: EdgeInsets.only(top: 5, left: 10, right: 10),
child: AppText(
TranslationBase.of(context).doctorName, TranslationBase.of(context).doctorName,
)), enabled: false,
new IgnorePointer( maxLines: 1,
ignoring: true, minLines: 1,
child: AppTextFormField( dropDownColor: Colors.white,
readOnly: true, isTextFieldHasSuffix: true,
hintText: profile['DoctorName'], inputFormatters: [
borderColor: Colors.white, FilteringTextInputFormatter.allow(
onSaved: (value) {}, RegExp(ONLY_NUMBERS))
// validator: (value) {
// return TextValidator().validateName(value);
// },
inputFormatter: ONLY_NUMBERS))
], ],
), controller: _doctorController,
onChanged: (value) {},
), ),
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: [
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) { onChanged: (value) {
addSickLeave.remarks = value; addSickLeave.remarks = value;
if (widget.extendedData != null) { if (widget.extendedData != null) {
widget.extendedData.remarks = value; widget.extendedData.remarks = value;
} }
}, },
) ),
], ],
), ),
), ),
Container( ),
margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), ),
child: Wrap( bottomSheet: model2.state ==ViewState.Busy || model.state == ViewState.Busy?Container(height: 0,): Container(
alignment: WrapAlignment.center, decoration: BoxDecoration(
children: <Widget>[ color: Colors.white,
AppButton( 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 title: widget.isExtended == true
? TranslationBase.of(context).extend ? TranslationBase.of(context).extend
: TranslationBase.of(context).addSickLeaverequest, : TranslationBase.of(context)
.addSickLeaverequest,
color: Colors.green, color: Colors.green,
onPressed: () async { onPressed: () async {
if (widget.isExtended) { if (widget.isExtended) {
await model2.extendSickLeave(widget.extendedData); await model2.extendSickLeave(
widget.extendedData);
DrAppToastMsg.showSuccesToast( DrAppToastMsg.showSuccesToast(
model2.sickleaveResponse['ListSickLeavesToExtent']['success']); model2.sickleaveResponse[
Navigator.of(context).popUntil((route) { 'ListSickLeavesToExtent']
return route.settings.name == PATIENTS_PROFILE; ['success']);
});
Navigator.of(context) Navigator.of(context)
.pushNamed(ADD_SICKLEAVE, arguments: {'patient': widget.patient}); .popUntil((route) {
return route.settings.name ==
PATIENTS_PROFILE;
});
Navigator.of(context).pushNamed(
ADD_SICKLEAVE,
arguments: {
'patient': widget.patient
});
//print(value); //print(value);
//}); //});
} else { } else {
try { try {
if (addSickLeave.noOfDays == null) { if (addSickLeave.noOfDays == null) {
DrAppToastMsg.showErrorToast( DrAppToastMsg.showErrorToast(
TranslationBase.of(context).pleaseEnterNoOfDays); TranslationBase.of(context)
} else if (addSickLeave.remarks == null) { .pleaseEnterNoOfDays);
} else if (addSickLeave.remarks ==
null) {
DrAppToastMsg.showErrorToast( DrAppToastMsg.showErrorToast(
TranslationBase.of(context).pleaseEnterRemarks); TranslationBase.of(context)
} else if (addSickLeave.startDate == null) { .pleaseEnterRemarks);
DrAppToastMsg.showErrorToast(TranslationBase.of(context).pleaseEnterDate); } else if (addSickLeave.startDate ==
null) {
DrAppToastMsg.showErrorToast(
TranslationBase.of(context)
.pleaseEnterDate);
} else { } else {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(
addSickLeave.patientMRN = widget.patient.patientMRN.toString(); context);
addSickLeave.appointmentNo = widget.patient.appointmentNo.toString(); addSickLeave.patientMRN = widget
await model2.addSickLeave(addSickLeave); .patient.patientMRN
if(model2.state == ViewState.ErrorLocal){ .toString();
Helpers.showErrorToast(model2.error); addSickLeave.appointmentNo =
widget.patient.appointmentNo
.toString();
await model2
.addSickLeave(addSickLeave);
if (model2.state ==
ViewState.ErrorLocal) {
Helpers.showErrorToast(
model2.error);
} else { } else {
DrAppToastMsg.showSuccesToast(TranslationBase.of(context).replySuccessfully); DrAppToastMsg.showSuccesToast(
TranslationBase.of(context)
.replySuccessfully);
} }
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(
context);
} }
} catch (err) { } catch (err) {
print(err); print(err);
@ -367,21 +350,14 @@ class _SickLeaveScreenState extends State<SickLeaveScreen> {
} }
}, },
), ),
],
), ),
SizedBox(
height: 5,
), ),
// Column(
// children: [
// AppText(TranslationBase.of(context)
// .previousSickLeaveIssue +
// ' ')
// ],
// )
], ],
), ),
), )
),
),
), ),
))); )));
} }
@ -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