Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@kpsroka
Copy link
Contributor

@kpsroka kpsroka commented Jul 10, 2024

Moves the implementation if isAlwaysUse24HourFormat from iOS's FlutterViewController internals to common utility, and makes use of it on MacOS in order to return correct value of alwaysUse24HourFormat.

This PR partially resolves #32006.

Note that on iOS 16+ and MacOS 13+, there is a new API for obtaining this information: https://developer.apple.com/documentation/foundation/locale/components/3952289-hourcycle. However, to keep things simpler, I wanted to not include changes to the logic.

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 and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@kpsroka kpsroka marked this pull request as ready for review July 10, 2024 11:16
@kpsroka kpsroka force-pushed the alwaysUse24Hour-macos-32006 branch from c347a3a to b29181f Compare July 10, 2024 11:22
@kpsroka kpsroka force-pushed the alwaysUse24Hour-macos-32006 branch from b29181f to 99313d2 Compare July 10, 2024 11:24
@kpsroka kpsroka force-pushed the alwaysUse24Hour-macos-32006 branch from f1ccbb5 to f16f37e Compare July 10, 2024 12:29
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@knopp knopp self-requested a review July 12, 2024 10:10
Copy link
Member

@knopp knopp left a comment

Choose a reason for hiding this comment

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

LGTM. This seems like a straightforward refactor. Not sure if this needs a test since it only moves things from iOS to darwin embedder. Also I'm not sure how to test this given that the behavior depends on system settings. @cbracken, any ideas?

@cbracken
Copy link
Member

cbracken commented Jul 12, 2024

Also I'm not sure how to test this given that the behavior depends on system settings.

In the usual case, we'd say extract out a thin utility class that wraps the system setting and then write a test of the usage site against a mock. In this case, this is just a refactoring that factors out the thin wrapper that wraps the system setting. Since this also makes use of this in the mac embedding, we should add a test there.

You could write a test against the existing usage that just tests that the value set in the FlutterHourFormat is the value that's used. Probably not too much effort, but I think a case could also be made for requesting a test exemption.

Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

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

LGTM stamp from a Japanese personal seal

Looks great! Thanks for the patch!

@stuartmorgan-g
Copy link
Contributor

stuartmorgan-g commented Jul 16, 2024

In this case, this is just a refactoring that factors out the thin wrapper that wraps the system setting.

This isn't just a refactoring though; the purpose of this PR is to change the behavior of the macOS embedding. That's a behavioral change that should not regress, and thus should be tested.

(In this case I would suggest a test that onSettingsChanged: call the channel with expected values, probably using an injected formatter as cbracken suggested.)

@zanderso
Copy link
Member

From PR triage: It looks like this PR is waiting for a test to be added, correct?

@kpsroka
Copy link
Contributor Author

kpsroka commented Jul 18, 2024

From PR triage: It looks like this PR is waiting for a test to be added, correct?

Yes, I will get to that over the weekend.

Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

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

Overall looks good, just a few nits and suggestions.

@kpsroka
Copy link
Contributor Author

kpsroka commented Aug 1, 2024

I think that the PR is ready for merge. @cbracken please merge/add "autosubmit" [if you agree].

@kpsroka
Copy link
Contributor Author

kpsroka commented Aug 1, 2024

Note that flutter/flutter#32006 is best left [re-]opened, and updated to refer only to textScaleFactor

@cbracken cbracken added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 1, 2024
@auto-submit auto-submit bot merged commit 17e3c7d into flutter:main Aug 1, 2024
@cbracken
Copy link
Member

cbracken commented Aug 1, 2024

Thanks for the fix, @kpsroka! Merged!

engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 1, 2024
@kpsroka kpsroka deleted the alwaysUse24Hour-macos-32006 branch August 2, 2024 15:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

affects: desktop autosubmit Merge PR when tree becomes green via auto submit App platform-ios platform-macos

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Share the alwaysUse24Hour and textScaleFactor heuristics between iOS and macOS

5 participants