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 6c5167f commit 1721d68
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 of event cannot be before start of event!');
}
},
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 of event cannot be before start of event!');
}
},
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 1721d68

Please sign in to comment.