Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
RGTechPro committed Aug 26, 2022
1 parent 6beac41 commit eb9cbee
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 29 deletions.
31 changes: 24 additions & 7 deletions lib/screens/date_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class DatePage extends StatefulWidget {
}

class _DatePageState extends State<DatePage> {
DateTime? realDate;
DateTime? dynamicDate;
DateTime? realDate = DateTime.now();
DateTime? dynamicDate = DateTime.now();
DateTime date = DateTime.now();
String? slotType;
bool isMorningSlot = true;
Expand All @@ -27,10 +27,10 @@ class _DatePageState extends State<DatePage> {
print("init called00");
bool flag = false;
DateFormat dateFormat = DateFormat("yyyy-MM-dd HH:mm:ss");
DateTime dateTime =
dateFormat.parse('${date.year}-${date.month}-${date.day} 17:00:00');
DateTime dateTime1 =
dateFormat.parse('${date.year}-${date.month}-${date.day} 12:00:00');
DateTime dateTime = dateFormat.parse(
'${dynamicDate!.year}-${dynamicDate!.month}-${dynamicDate!.day} 17:00:00');
DateTime dateTime1 = dateFormat.parse(
'${dynamicDate!.year}-${dynamicDate!.month}-${dynamicDate!.day} 12:00:00');
if (date.isAfter(dateTime)) {
realDate = date.add(Duration(days: 1));
dynamicDate = realDate;
Expand Down Expand Up @@ -69,7 +69,10 @@ class _DatePageState extends State<DatePage> {
Provider.of<BookingProvider>(context, listen: false).morning
: Provider.of<BookingProvider>(context, listen: false).slots =
Provider.of<BookingProvider>(context, listen: false).evening;
Provider.of<BookingProvider>(context, listen: false).booking.date =

Provider.of<BookingProvider>(context, listen: false).booking.slotDate =
dynamicDate.toString();
Provider.of<BookingProvider>(context, listen: false).booking.date =
dynamicDate;
print(dynamicDate);
print(Provider.of<BookingProvider>(context, listen: false)
Expand Down Expand Up @@ -191,6 +194,20 @@ class _DatePageState extends State<DatePage> {
daysCount: 15,
onDateChange: (value) {
dynamicDate = value;
if (value.isAfter(date)) {
isMorningSlot = true;

}

DateFormat dateFormat = DateFormat("yyyy-MM-dd HH:mm:ss");

DateTime dateTime1 = dateFormat.parse(
'${dynamicDate!.year}-${dynamicDate!.month}-${dynamicDate!.day} 12:00:00');


if (date.isAfter(dateTime1)) {
isMorningSlot = false;
}
setState(() {});
},
),
Expand Down
59 changes: 37 additions & 22 deletions lib/screens/slot_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class _SlotPageState extends State<SlotPage> {
print(Provider.of<BookingProvider>(context, listen: false)
.booking
.slotTime);

Navigator.pop(context);
Navigator.pop(context);
} else {
Expand Down Expand Up @@ -192,32 +192,47 @@ class _SlotPageState extends State<SlotPage> {
.length,
itemBuilder: (context, index) {
bool boolHandler = true;

print(Provider.of<BookingProvider>(context,
listen: false)
.booking
.slotDate!);
print("here");
DateFormat dateFormat =
DateFormat("yyyy-MM-dd HH:mm:ss");
DateTime date = DateTime.now();
//DateTime date = dateFormat.parse('2022-08-26 15:05:00');
DateTime dateTime = dateFormat.parse(
'${date.year}-${date.month}-${date.day} ${Provider.of<BookingProvider>(context).slots[index].timeslot.substring(0, 4)}:00');
print(Provider.of<BookingProvider>(context)
.slots[index]
.timeslot
.substring(5, 7));
if (Provider.of<BookingProvider>(context)
.slots[index]
.timeslot
.substring(5, 7) ==
'PM') {
dateTime = dateTime.add(Duration(hours: 12));
}
print(date.difference(dateTime));
if (date.isAfter(dateTime)
DateTime dateTime2 = dateFormat.parse(
Provider.of<BookingProvider>(context)
.booking
.slotDate!);
if (date.isAfter(dateTime2)) {
print(Provider.of<BookingProvider>(context,
listen: false)
.booking
.slotDate!);
print("there");
//DateTime date = dateFormat.parse('2022-08-26 15:05:00');
DateTime dateTime = dateFormat.parse(
'${date.year}-${date.month}-${date.day} ${Provider.of<BookingProvider>(context).slots[index].timeslot.substring(0, 4)}:00');
print(Provider.of<BookingProvider>(context)
.slots[index]
.timeslot
.substring(5, 7));
if (Provider.of<BookingProvider>(context)
.slots[index]
.timeslot
.substring(5, 7) ==
'PM') {
dateTime =
dateTime.add(Duration(hours: 12));
}
print(date.difference(dateTime));
if (date.isAfter(dateTime)

//|| date.difference(dateTime) <= Duration(minutes: 30)
) {
boolHandler = false;
//|| date.difference(dateTime) <= Duration(minutes: 30)
) {
boolHandler = false;
}
}
//if()

return TimeTile(
timeslot:
Expand Down

0 comments on commit eb9cbee

Please sign in to comment.