Skip to content

Conversation

@lucaslcode
Copy link

Description

Updates TimePicker so both dragging and tapping in hour mode will change to minute mode, as is native android behavior.

Related Issues

#17276

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes tests for all changed/updated/fixed behaviors (See Test Coverage).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

@lucaslcode lucaslcode force-pushed the timepicker_minute_switch branch from 4429e38 to 024c773 Compare March 24, 2019 17:01
@goderbauer goderbauer added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Mar 25, 2019
@lucaslcode
Copy link
Author

lucaslcode commented Apr 3, 2019

@HansMuller I checked this with the TimePicker tests and modified them so they all pass with (and also test) the new behavior, any chance of it landing seperately from the larger updates?

@ghost ghost self-requested a review April 5, 2019 17:43
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Thanks for working on this. Looks good. I have a couple of issues for you to consider, which I describe in comments below.

final _TimePickerMode mode;
final bool use24HourDials;
final ValueChanged<TimeOfDay> onChanged;
final VoidCallback onHourDragEnd;
Copy link

Choose a reason for hiding this comment

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

These two new callbacks really are describing the same abstract event: the user is done editing one of the units for the time. How they did that (dragging or tapping) isn't really important to the client of this widget.

I would suggest having only one of these and instead of tying it to just the hour, have it called for either the hour or the minutes. This would allow more flexibility. So something like;

final VoidCallback onTimeUnitFinished;

And then let the client check for the mode and do whatever it wants for either the hour being set or the minutes (which in this case would only be checking for the hour and switching modes).

@required this.mode,
@required this.use24HourDials,
@required this.onChanged,
@required this.onHourDragEnd,
Copy link

Choose a reason for hiding this comment

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

Minor nit, but this probably doesn't need to be required, but as this is an internal widget, probably not critical.

});
}

void _handleHourDragEnd() {
Copy link

Choose a reason for hiding this comment

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

These both need to be doing the same thing as _handleModeChanged(). It would make sense to refactor the guts of _handleModeChanged() into a _setMode(_TimePickerMode mode) and then have _handleModeChanged() and these (or a new _handleTimeUnitFinished() from the above comment) call _setMode().

darrenaustin added a commit that referenced this pull request Apr 25, 2019
Adds a feature of the native Android Time Picker to our Material Time Picker. When the user selects an hour, it automatically switches to minute mode.

This is a merging of two pull requests:

Code changes from @sdolski #24677
Tests from @lucaslcode #29876

Thanks to both of you for your contributions!
@darrenaustin
Copy link
Contributor

Sorry about the 'Ghost' comments, I switched accounts for Flutter work. I went ahead and combined the your tests with the code changes from @sdolski #24677 and landed it in #31566. Thanks for your work on this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants