fixes Show Week Day in CupertinoDatePicker with CupertinoDatePickerMo…#120052
fixes Show Week Day in CupertinoDatePicker with CupertinoDatePickerMo…#120052auto-submit[bot] merged 12 commits intoflutter:masterfrom
Conversation
|
|
@jmagman test case fixed. |
|
@sikandernoori I'll review once all the tests are passing. Some of the tests don't look like infastructure issues outside of this PR, but this one looks related: |
|
@MitchellGoodwin failling test fixed. |
|
@sikandernoori the infrastructure issues were fixed. Could you please rebase on the latest master branch to pick up the fixes? |
@MitchellGoodwin Done |
FYI As of yesterday we turned on the ability for any flutter-hacker contributor to rebase with the "Update branch" button (probably most useful for infra issues like this one) |
MitchellGoodwin
left a comment
There was a problem hiding this comment.
Thank you for submitting this change. I left some mostly nit comments.
| final String dayOfMonth = localizations.datePickerDayOfMonth(i); | ||
| if (longestText.length < dayOfMonth.length) { | ||
| longestText = dayOfMonth; | ||
| final int lenght = showDayOfWeek ? DateTime.daysPerWeek : 2; |
There was a problem hiding this comment.
nit: length instead of lenght
| const DefaultCupertinoLocalizations(); | ||
|
|
||
| static const List<String> _shortWeekdays = <String>[ | ||
| ///Short version of days of week. |
There was a problem hiding this comment.
nit: need a space in front of Short
| initialDateTime: date, | ||
| mode: CupertinoDatePickerMode.date, | ||
| use24hFormat: true, | ||
| // This shows daya of week alongside day of month |
There was a problem hiding this comment.
nit: "day of the week"
| final String dayOfMonth = localizations.datePickerDayOfMonth(i, showDayOfWeek ? wd : null); | ||
| if (longestText.length < dayOfMonth.length) { | ||
| longestText = dayOfMonth; | ||
| } |
There was a problem hiding this comment.
Instead of doing a nested loop to check every possible option to find the longest string, I think it would be faster to find the longest day of the week, and the longest day of the month in two separate strings and add them together? It would be log(m) + log(n) rather than log(m*n).
| /// Day of month that is shown in [CupertinoDatePicker] spinner corresponding | ||
| /// to the given day index. | ||
| /// | ||
| /// if weekDay is provided then it will also show Day of week alongside day |
There was a problem hiding this comment.
nit: format to "If weekDay is provided then it will also show weekday name alongside the numerical day."
|
@sikandernoori I've left one more nit comment for the documentation, but other than that, this looks good to me. |
MitchellGoodwin
left a comment
There was a problem hiding this comment.
LGTM. Thank you for dealing with my nitpicking.
Happy to participate in quality work. |
|
auto label is removed for flutter/flutter, pr: 120052, due to - Please get at least one approved review if you are already a member or two member reviews if you are not a member before re-applying this label. Reviewers: If you left a comment approving, please use the "approve" review action instead. |
|
auto label is removed for flutter/flutter, pr: 120052, due to Validations Fail. |
|
Oops, need another review. Let me ask around. |
from bot description I believe 1 review is enough, you have to pass "approve" label first. |
No, it's because the PR has the "First-time contributor" label. Those need two reviews as a part of a security concern. |
okay. |
|
Members of flutter-hackers access control group require one other flutter-hacker to approve. If the author is not a member of the flutter-hackers group, then two approvers are needed. |
Piinks
left a comment
There was a problem hiding this comment.
Welcome @sikandernoori, thanks for contributing!
#120052 introduces the `showDayOfWeek` flag to `CupertinoDatePicker` for mode `CupertinoDatePickerMode.date`, but the default `en` locale from `DefaultCupertinoLocalizations` is always used for the day of the week: https://github.com/flutter/flutter/blob/5103d757436124a08e6a8024ebacbf0cf4b2bacf/packages/flutter_localizations/lib/src/cupertino_localizations.dart#L116-L119 This PR introduces a new `intl.DateFormat` `weekdayFormat` to replace the default with the abbreviated weekday for any supported locales. | Before | After | | --- | --- | | <img width="379" alt="Screenshot 2024-07-09 at 5 08 43�PM" src="proxy.php?url=https://github.com/flutter/flutter/assets/77553258/d6899c6b-bd0a-4484-a6a8-3ef1512aeae1"> | <img width="379" alt="Screenshot 2024-07-09 at 5 08 11�PM" src="proxy.php?url=https://github.com/flutter/flutter/assets/77553258/f320c634-80d1-4f3b-adfd-ed85a9dfc3f6"> | Fixes #141875


Show Week Day in CupertinoDatePicker with CupertinoDatePickerMode.date
fixes #120051
Sample
If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].
Pre-launch Checklist
///).