-
-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix setting minutes in time pickers #616
Conversation
To view this pull requests documentation preview, visit the following URL: docs.page/sharezoneapp/sharezone-app~616 Documentation is deployed and generated using docs.page. |
Visit the preview URL for this PR (updated for commit 76c9d48): https://sharezone-test--pr616-fix-time-picker-oor8dylh.web.app (expires Sun, 23 Apr 2023 18:18:37 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 4cb3ae61e1e018abfd9841fd3239f5b49ccc034b |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, see comment
app/lib/timetable/src/edit_time.dart
Outdated
visibleStep: VisibleStep.thirtieths, | ||
interval: minutesInterval, | ||
visibleStep: | ||
minutesInterval == 30 ? VisibleStep.thirtieths : VisibleStep.fifths, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're basically hard coding the logic here that it's either 30 or 5 minute intervals then shouldn't we also also add an assert that minutesInteval
is one or the other?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm using an extension now on int
to get the VisibleStep
and throw an exception if it's an unknown minute value:
extension on int {
VisibleStep toVisibleStep() {
switch (this) {
case 1:
case 5:
return VisibleStep.fifths;
case 6:
return VisibleStep.sixths;
case 10:
return VisibleStep.tenths;
case 20:
return VisibleStep.twentieths;
case 30:
return VisibleStep.thirtieths;
case 60:
return VisibleStep.sixtieth;
default:
// At the moment, only these intervals are supported. If you need
// another one, please add it and handle it in the switch statement.
throw Exception(
"Unsupported minutes interval: $this. Please handle the other cases yourself.",
);
}
}
}
Description
#568 introduced a new bug: When adding a new event (e.g. an exam) it's only allowed to enter 0 or 30 as value for the minute at the time picker.
Screen.Recording.2023-04-06.at.14.11.58.mov
The problem was the minute interval for the Material time picker was hard-coded.
Solution demo
Screen.Recording.2023-04-07.at.00.44.02.mov
Related Tickets
Closes #584