Skip to content
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

Merged
merged 3 commits into from
Apr 16, 2023
Merged

Fix setting minutes in time pickers #616

merged 3 commits into from
Apr 16, 2023

Conversation

nilsreichardt
Copy link
Member

@nilsreichardt nilsreichardt commented Apr 6, 2023

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

@docs-page
Copy link

docs-page bot commented Apr 6, 2023

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.

@github-actions github-actions bot added the feature: timetable / calendar Includes anything regarding lessons (timetable) and events (calendar). label Apr 6, 2023
@github-actions
Copy link

github-actions bot commented Apr 6, 2023

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

Copy link
Collaborator

@Jonas-Sander Jonas-Sander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, see comment

visibleStep: VisibleStep.thirtieths,
interval: minutesInterval,
visibleStep:
minutesInterval == 30 ? VisibleStep.thirtieths : VisibleStep.fifths,
Copy link
Collaborator

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?

Copy link
Member Author

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.",
        );
    }
  }
}

@nilsreichardt nilsreichardt enabled auto-merge April 16, 2023 18:13
@nilsreichardt nilsreichardt added this pull request to the merge queue Apr 16, 2023
Merged via the queue into main with commit f6d27ec Apr 16, 2023
@nilsreichardt nilsreichardt deleted the fix-time-picker branch April 16, 2023 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: timetable / calendar Includes anything regarding lessons (timetable) and events (calendar).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

It's only possible to set the minute of an event to 0 or 30
2 participants