Merge pull request 'appointment date filter handled' (#74) from appointment_filter into master

Reviewed-on: #74
pull/78/head
Haroon6138 4 weeks ago
commit 3bbc014251

@ -485,3 +485,11 @@ class DateUtil {
return "";
}
}
extension OnlyDate on DateTime{
DateTime provideDateOnly(){
return DateTime(this.year, month, day);
}
}

@ -50,6 +50,8 @@ class MyAppointmentsViewModel extends ChangeNotifier {
void onTabChange(int index) {
previouslySelectedTab = selectedTabIndex;
selectedTabIndex = index;
start = null;
end = null;
notifyListeners();
}
@ -451,12 +453,12 @@ class MyAppointmentsViewModel extends ChangeNotifier {
filteredAppointmentList.add(element);
}
});
filteredAppointmentList.addAll(sourceList);
} else {
filteredAppointmentList.clear();
sourceList.forEach((element) {
try {
var dateTime = DateUtil.convertStringToDate(element.appointmentDate);
var dateTime = DateUtil.convertStringToDate(element.appointmentDate).provideDateOnly();
if (start != null && end == null) {
if (dateTime.isAtSameMomentAs(start)) {
if (isUnderFilter(element)) {
@ -464,7 +466,7 @@ class MyAppointmentsViewModel extends ChangeNotifier {
}
}
} else if (start != null && end != null) {
if ((dateTime.isAfter(start)) && (dateTime.isBefore(end))) {
if ((dateTime.isAfter(start)) && ((dateTime.isBefore(end))||((dateTime.isAtSameMomentAs(end))))) {
if (isUnderFilter(element)) {
filteredAppointmentList.add(element);
}

@ -1,5 +1,6 @@
import 'package:dartz/dartz.dart';
import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/utils/date_util.dart';
import 'package:hmg_patient_app_new/features/lab/models/Range.dart';
class DateRangeSelectorRangeViewModel extends ChangeNotifier {
@ -50,7 +51,7 @@ class DateRangeSelectorRangeViewModel extends ChangeNotifier {
get getCurrentYear => DateTime.now().year;
calculateDatesFromRange() {
_toDate = DateTime.now();
_toDate = DateTime.now().provideDateOnly();
switch (_currentlySelectedRange) {
case Range.WEEKLY:
_fromDate = _toDate!.subtract(Duration(days: 7));

Loading…
Cancel
Save