Skip to content

Commit

Permalink
Added time validation if the date is same in detail_screen.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
Raviramnani1 committed Jul 30, 2024
1 parent 7c68564 commit 8a5bb7a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions evently/lib/screens/detail_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class _DetailsScreenState extends State<DetailsScreen> {
if (_validateDates(provider)) {
createEventViewModel.nextPage();
} else {
_showSnackBarWithPostFrameCallback('End date cannot be before start date!');
_showSnackBarWithPostFrameCallback('End date and time cannot be before start date and time!');
}
},
onPressSaveDraft: () {
Expand All @@ -192,7 +192,7 @@ class _DetailsScreenState extends State<DetailsScreen> {
uploadStep: UploadStep.detail,
);
} else {
_showSnackBarWithPostFrameCallback('End date cannot be before start date!');
_showSnackBarWithPostFrameCallback('End date and time cannot be before start date and time!');
}
},
isContinueEnable: provider.startDate.isNotEmpty &&
Expand Down Expand Up @@ -258,6 +258,15 @@ class _DetailsScreenState extends State<DetailsScreen> {
if (end.isBefore(start)) {
return false; // End date is before start date
}
// Check times if the dates are the same
if (provider.startDate.compareTo(provider.endDate) == 0) {
final DateTime startTime = DateFormat('HH:mm').parse(provider.startTime);
final DateTime endTime = DateFormat('HH:mm').parse(provider.endTime);

if (endTime.isBefore(startTime)) {
return false; // End time is before start time on the same day
}
}
} catch (e) {
return false; // Invalid date format
}
Expand Down

0 comments on commit 8a5bb7a

Please sign in to comment.