Skip to content

Feat: showDatePicker - Exposed callback when user changes Date Picker Mode - #119116

Merged
HansMuller merged 7 commits into
flutter:masterfrom
hasnentai:feat-datepicker-onchange
Mar 3, 2023
Merged

HansMuller merged 7 commits into
flutter:masterfrom
hasnentai:feat-datepicker-onchange

Conversation

@hasnentai

@hasnentai hasnentai commented Jan 25, 2023 •

Copy link
Copy Markdown
Contributor

Exposed a callback when the user switches between entry mode from calendar to input, this way we can store the preferred input method in the application state and open the next date picker with the preferred entry mode already set (using the existing initialEntryMode parameter).

Fixes #113423

Example of callback onDatePickerModeChange

showDatePicker(
  context: context,
  initialDate: DateTime.now(),
  firstDate: DateTime.now(),
  lastDate: DateTime.now(),
  initialEntryMode: datePickerMode,
  onDatePickerModeChange: (mode) {
  setState(() {
    datePickerMode = mode;
  });
  },
)

Screen Recording

Screen.Recording.2023-01-25.at.11.53.51.AM.mov

CC: @Piinks , @HansMuller

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

@flutter-dashboard flutter-dashboard Bot added p: material_ui material_ui package in flutter/packages framework flutter/packages/flutter repository. See also f: labels. labels Jan 25, 2023
@hasnentai hasnentai changed the title [WIP] : showDatePicker - Exposed callback when user changes entry mode (Calendar <=> Input ) Feat: showDatePicker - Exposed callback when user changes entry mode (Calendar <=> Input ) Jan 25, 2023
@hasnentai hasnentai changed the title Feat: showDatePicker - Exposed callback when user changes entry mode (Calendar <=> Input ) Feat: showDatePicker - Exposed callback when user changes entry mode (Calendar <=> Input ) Jan 25, 2023
@hasnentai hasnentai changed the title Feat: showDatePicker - Exposed callback when user changes entry mode (Calendar <=> Input ) Feat: showDatePicker - Exposed callback when user changes Date Picker Mode (Calendar <=> Input ) Jan 25, 2023
@hasnentai hasnentai changed the title Feat: showDatePicker - Exposed callback when user changes Date Picker Mode (Calendar <=> Input ) Feat: showDatePicker - Exposed callback when user changes Date Picker Mode Jan 25, 2023
@HansMuller
HansMuller self-requested a review January 27, 2023 19:17
@HansMuller
HansMuller force-pushed the feat-datepicker-onchange branch from 9a43820 to a6b11da Compare March 2, 2023 00:23

@HansMuller HansMuller left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks great, just noted some small stuff.

Comment thread packages/flutter/lib/src/material/date_picker.dart Outdated
Comment thread packages/flutter/lib/src/material/date_picker.dart Outdated
@hasnentai
hasnentai requested a review from HansMuller March 2, 2023 11:00

@HansMuller HansMuller left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Still really close. The presubmit analyze test is complaining about some trailing spaces.

Comment thread packages/flutter/lib/src/material/date_picker.dart Outdated
Comment thread packages/flutter/lib/src/material/date_picker.dart Outdated
Comment thread packages/flutter/test/material/date_picker_test.dart Outdated
Comment thread packages/flutter/test/material/date_picker_test.dart Outdated
@hasnentai
hasnentai requested a review from HansMuller March 3, 2023 06:19

@HansMuller HansMuller left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@HansMuller
HansMuller merged commit 859b6ec into flutter:master Mar 3, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 4, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 10, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

showDatePicker - expose callback or change notifier when user changes entry mode (calendar / input)

2 participants