WD: Date from and date to added to the dialog and limit handled

update_3.16.0_CR5439_Pharmacy_Intervention
taha.alam 10 months ago
parent 9fa4fc445c
commit 2ec7672b29

@ -581,8 +581,10 @@ class PharmacyInterventionViewModel extends BaseViewModel {
DrAppToastMsg.showErrorToast(errorMessage);
return;
}
DrAppToastMsg.showSuccesToast(successMessage);
getPharmacyIntervention();
if(result) {
DrAppToastMsg.showSuccesToast(successMessage);
getPharmacyIntervention();
}
setState(ViewState.Idle);
}

@ -53,8 +53,8 @@ class _PharmacyInterventionDialogState
admissionNumber.text = (widget.admissionNumber == '0')?'':widget.admissionNumber;
nursingStation.text = (widget.nursingStation == '0')?'':widget.nursingStation;
patientId.text = (widget.patientID == '0' )?'':widget.patientID;
dateTo = getDate(widget.dateTo);
dateFrom = getDate(widget.dateFrom);
dateTo = getDateString(widget.dateTo);
dateFrom = getDateString(widget.dateFrom);
}
@override
@ -102,10 +102,25 @@ class _PharmacyInterventionDialogState
_dateSelection(TranslationBase
.of(context)
.dateFrom, (date) {
DateTime? fromDate = getDate(date);
DateTime? toDate =getDate(dateTo);
if(toDate == null){
setState(() {
dateFrom = date;
});
return;
}
if(fromDate!.compareTo(toDate!) == 1){
setState(() {
dateFrom = date;
dateTo = '';
});
return;
}
setState(() {
dateFrom = date;
});
}, dateFrom),
}, dateFrom, false),
SizedBox(
height: 4,
),
@ -115,7 +130,7 @@ class _PharmacyInterventionDialogState
setState(() {
dateTo = date;
});
}, dateTo),
}, dateTo, true, selectedFromDate: dateFrom),
SizedBox(
height: 8,
),
@ -144,9 +159,9 @@ class _PharmacyInterventionDialogState
}
Widget _dateSelection(String title, Function(String) onDateSelected,
String selectedDate) {
String selectedDate, bool isToDateSelection,{String? selectedFromDate}) {
return GestureDetector(
onTap: () => _selectDate(onDateSelected),
onTap: () => _selectDate(onDateSelected,selectedDate, isToDateSelection , selectedFromDate: selectedFromDate),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
@ -164,11 +179,13 @@ class _PharmacyInterventionDialogState
);
}
Future _selectDate(Function(String) updateDate) async {
Future _selectDate(Function(String) updateDate , String date, bool toDateSelection, {String? selectedFromDate}) async {
DateTime? dateTime = getDate(date);
DateTime? fromDate = getDate(selectedFromDate??'');
final DateTime? picked = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(DateTime
initialDate:date.isNotEmpty? getDate(date) :fromDate != null? fromDate: DateTime.now(),
firstDate:(( date.isNotEmpty && dateTime != null ) ) ? dateTime: (toDateSelection && fromDate != null)?fromDate :DateTime(DateTime
.now()
.year - 150),
lastDate: DateTime(DateTime
@ -226,11 +243,18 @@ class _PharmacyInterventionDialogState
return DateFormat('yyyy-MM-dd').format(time);
}
String getDate(String dateTime) {
String getDateString(String dateTime) {
if (dateTime.isEmpty) return '';
DateTime? now = getDate(dateTime);
if(now == null ) return '';
return DateFormat('yyyy-MM-dd').format(now);
}
DateTime? getDate(String dateTime){
if (dateTime.isEmpty) return null;
List<String> splitedDate = dateTime.split('-');
DateTime now = DateTime(int.parse(splitedDate[0]),
int.parse(splitedDate[1]), int.parse(splitedDate[2]));
return DateFormat('yyyy-MM-dd').format(now);
return now;
}
}
Loading…
Cancel
Save