Skip to content

Conversation

@thejitenpatel
Copy link
Contributor

@thejitenpatel thejitenpatel commented Oct 19, 2024

This PR addresses an issue where the CupertinoAlertDialog was not fully visible in dark mode. The dialog now adapts better to dark mode themes, ensuring proper contrast and readability across different UI elements.

Fixes: #80921

Pre-launch Checklist

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

@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, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!).

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. The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: cupertino flutter/packages/flutter/cupertino repository labels Oct 19, 2024
@Piinks Piinks requested a review from victorsanni October 23, 2024 18:16
@Piinks Piinks added the a: fidelity Matching the OEM platforms better label Oct 23, 2024
@victorsanni
Copy link
Contributor

This PR will need images with side-by-side comparisons with native, new tests, and fixes to existing tests.

@thejitenpatel
Copy link
Contributor Author

This PR will need images with side-by-side comparisons with native, new tests, and fixes to existing tests.

Sure @victorsanni! I will add images with a side-by-side comparison with native, and also fix the existing tests. However, I'm having a bit of trouble understanding the golden test documentation. Could you please help me with the following:

Do we need to create or update the golden test case? If yes, what are the steps involved in doing so?

@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

For more guidance, visit Writing a golden file test for package:flutter.

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

Changes reported for pull request #157218 at sha a1da43a

@flutter-dashboard flutter-dashboard bot added the will affect goldens Changes to golden files label Oct 24, 2024
@victorsanni
Copy link
Contributor

Sure @victorsanni! I will add images with a side-by-side comparison with native, and also fix the existing tests. However, I'm having a bit of trouble understanding the golden test documentation. Could you please help me with the following:

Do we need to create or update the golden test case? If yes, what are the steps involved in doing so?

Considering its a color change, the goldens are expected to change.

@MitchellGoodwin
Copy link
Contributor

Do we need to create or update the golden test case? If yes, what are the steps involved in doing so?

Nothing you need to do. One of us with access to the golden test tool will triage it and approve the changes from this PR when it's ready to merge. As such, screenshots will be helpful.

@dkwingsmt
Copy link
Contributor

Can you explain how you got those numbers? And can you illustrate (probably with a side-by-side comparison, as mentioned by comments above) how you verify that those numbers produce native-like effects?

Thank you for you contribution!

@thejitenpatel
Copy link
Contributor Author

Hi @victorsanni, @MitchellGoodwin, @dkwingsmt, here's the side-by-side comparison with native.

Native Flutter

Also, @dkwingsmt, I derived those numbers from GitHub Issue #80921, where they were initially suggested for achieving native-like effects.

To verify the results, I created an alert dialog box in SwiftUI and manually compared the colors to ensure accuracy.

@victorsanni
Copy link
Contributor

Hi @victorsanni, @MitchellGoodwin, @dkwingsmt, here's the side-by-side comparison with native.

Are the Flutter images before or after this PR? It would be easy to see the changes if the images show native, flutter before, and flutter after.

@MitchellGoodwin
Copy link
Contributor

Screenshot 2024-10-29 at 11 29 22 AM It looks like the separator between the actions and the main content needs to be lightened as well.

@victorsanni
Copy link
Contributor

It looks like the separator between the actions and the main content needs to be lightened as well.

And the middle divider is also a little too light. Just from visually looking at it I wonder if the dividers are translucent. @thejitenpatel when trying to fix this, it might be helpful to draw the native dialog in different color backgrounds.

@thejitenpatel
Copy link
Contributor Author

Hi @victorsanni, @MitchellGoodwin as requested, here's the detailed comparison of before and after PR changes with native.

Before PR

Native Flutter (master)

After PR

Native Flutter (PR #157218)

Copy link
Contributor

@dkwingsmt dkwingsmt left a comment

Choose a reason for hiding this comment

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

LGTM! The colors indeed look much closer to native. Thank you for your contribution and explanation!

Although I wouldn't mark #80921 as fixed, because the issue also pointed out the problem of the separation line. Can you change the PR description so that it says something like "Fix part of #80921" and Github doesn't close the issue right away?

@victorsanni
Copy link
Contributor

@thejitenpatel to add to @dkwingsmt's comment, there's no pressure to add the separator fix. But it would be nice to have that here as well, in order to close the linked issue entirely :)

@dkwingsmt
Copy link
Contributor

dkwingsmt commented Nov 4, 2024

Thank you Victor for the addition, although I must note that the separator issue is actually really complicated, and I would recommend doing so in a different PR.

(I don't know why the current screenshots show almost no horizontal separators, maybe it's a bug)

I can't find the issues on this problem for now, but there has been back and forth on how the thickness of the separator is defined, and my latest discovery is that iOS devices draw them with 1 physical pixel thick. Yes, this means that the separator on a low-res iPhone is thicker than a high-res one. But how should Flutter handle it? There used to be complaint on the separators looking differently on Android.

In short, fixing the separator might require further investigation and comparison. (Feel free to research on it though!)

@victorsanni
Copy link
Contributor

I saw there was another open issue for the separators: #61164

Maybe this issue can be closed with this PR and target the separator fix to that issue instead?

@dkwingsmt
Copy link
Contributor

I saw there was another open issue for the separators: #61164

Maybe this issue can be closed with this PR and target the separator fix to that issue instead?

Sounds good!

Copy link
Contributor

@victorsanni victorsanni left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the PR.

@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

For more guidance, visit Writing a golden file test for package:flutter.

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

Changes reported for pull request #157218 at sha a942ab0

darkHighContrastColor: Color.fromARGB(173, 84, 84, 88),
elevatedColor: Color.fromARGB(73, 60, 60, 67),
darkElevatedColor: Color.fromARGB(153, 84, 84, 88),
darkElevatedColor: Color.fromARGB(153, 210, 210, 210),
Copy link
Contributor

@dkwingsmt dkwingsmt Nov 6, 2024

Choose a reason for hiding this comment

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

Can you teach me why this change is needed? Actually I can't even find the usage of this variable in Cupertino...

@dkwingsmt
Copy link
Contributor

Hi @MitchellGoodwin,

Thanks for the suggestion! I tried using CupertinoColors.separator.resolveFrom(context) & final Color dividerColor = CupertinoDynamicColor.resolve(CupertinoColors.separator, context); as recommended, but it doesn't seem to be working as expected. The divider color still isn’t adapting to the theme correctly. Do you have any additional suggestions or insights on what might be going wrong? Any help would be appreciated!

Have you checked whether the value of dividerColor has changed as intended?

@MitchellGoodwin
Copy link
Contributor

The divider color still isn’t adapting to the theme correctly.

Is it showing as the same color as before? And is it not picking up the brightness, the elevation, or both?

CupertinoDynamicColor.resolve may need to be called further down. Possibly in the _Divider class itself.

@MitchellGoodwin
Copy link
Contributor

I haven't tested to be sure, but I believe that this PR didn't introduce that behavior, so it's not required to fix it in this PR. But my instinct is that the divider color will be an easy fix somewhere, it just may need some trial and error to find where it is. Give it a try and see what happens. If it doesn't work after a bit of trying, I'll approve the PR as-is and make a separate issue for that divider.

@thejitenpatel
Copy link
Contributor Author

thejitenpatel commented Nov 10, 2024

Hi @MitchellGoodwin,
Thanks for the suggestion! I tried using CupertinoColors.separator.resolveFrom(context) & final Color dividerColor = CupertinoDynamicColor.resolve(CupertinoColors.separator, context); as recommended, but it doesn't seem to be working as expected. The divider color still isn’t adapting to the theme correctly. Do you have any additional suggestions or insights on what might be going wrong? Any help would be appreciated!

Have you checked whether the value of dividerColor has changed as intended?

Hi @dkwingsmt,

I've checked that the dividerColor is changing as expected, but it seems the actual Divider itself isn't reflecting this change.

@thejitenpatel
Copy link
Contributor Author

Is it showing as the same color as before? And is it not picking up the brightness, the elevation, or both?

CupertinoDynamicColor.resolve may need to be called further down. Possibly in the _Divider class itself.

@MitchellGoodwin, It’s showing as the same color as before—no noticeable change. It doesn’t seem to be picking up the brightness correctly, and the elevation appears to be slightly lower than expected.

Attaching screenshot of this PR for your reference:

@thejitenpatel
Copy link
Contributor Author

Hi @MitchellGoodwin,

You’re correct that this PR didn’t introduce the behavior. The issue occurs specifically when a horizontal divider is drawn—it doesn’t resolve the color as expected (screenshot 1.0). It is taking elevatedColor property if I'm not wrong, whereas the vertical divider resolves it correctly via the _CupertinoAlertActionSection class (screenshot 1.1).

To address this, I added CupertinoDynamicColor.resolve in the _CupertinoAlertDialogState class, which helps resolve the color issue for the horizontal divider. However, it still doesn’t fully address the brightness, and the elevation appears slightly less than expected.

To further address the color issue, as suggested, I also applied CupertinoDynamicColor.resolve directly in the Divider class (screenshot 1.2). The Color got resolved but it's not taking brightness if I am not wrong and elevation seems little less as expected (screenshot 2.0).

Interestingly, if there are more than two buttons, all horizontal dividers render with the correct color, except for the first one (screenshot 3.0)

Screenshot 1.0:
Screnshot_1 0

Screentshot 1.1:
Screenshot_1 1

Screenshot 1.2:
Screenshot 2024-11-10 at 7 01 13 PM

Screenshot 2.0: Dialog with single button in this PR

Screenshot 3.0: Current behavior after adding more than two buttons in this PR

@dkwingsmt
Copy link
Contributor

Oh! You're right. I think I made a mistake at
https://github.com/flutter/flutter/pull/150410/files#diff-4ea2907696de4fecf42f2ca56278a7b1d90c28921b1259d18ae28b1a2553d8e8R378

The dividerColor is never resolved here before being passed to _Divider, which doesn't resolve either. Thank you for your investigation!

Copy link
Contributor

@MitchellGoodwin MitchellGoodwin left a comment

Choose a reason for hiding this comment

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

@thejitenpatel thank you so much for looking into the divider, and submitting this PR in the first place. That officially sounds like a bigger pain to fix than I expected, so I'm going to approve this PR and create a separate issue for the divider. Thank you so much for the fix!

@MitchellGoodwin MitchellGoodwin added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 12, 2024
@auto-submit auto-submit bot merged commit 9a2e249 into flutter:master Nov 12, 2024
76 checks passed
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 12, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Nov 13, 2024
Roll Flutter from c8510f2 to ed553d1 (48 revisions)

flutter/flutter@c8510f2...ed553d1

2024-11-13 [email protected] Avoid using platform `ProcessInfo.maxRss` in test. (flutter/flutter#158526)
2024-11-13 [email protected] Roll Packages from 72356fd to 26e123a (19 revisions) (flutter/flutter#158626)
2024-11-13 [email protected] Move `dart pub deps` call to `<Pub>.deps` and use it accordingly (flutter/flutter#158524)
2024-11-13 [email protected] Roll Flutter Engine from 05c14d8b4cd7 to db3e5af2ca22 (1 revision) (flutter/flutter#158553)
2024-11-13 [email protected] Roll Flutter Engine from ef760d6e1f13 to 05c14d8b4cd7 (3 revisions) (flutter/flutter#158551)
2024-11-13 [email protected] Roll Flutter Engine from 08348c9eebcc to ef760d6e1f13 (1 revision) (flutter/flutter#158545)
2024-11-13 [email protected] Marks Mac_arm64_ios hot_mode_dev_cycle_ios__benchmark to be flaky (flutter/flutter#158242)
2024-11-13 [email protected] Roll Flutter Engine from 877abb9ad6ff to 08348c9eebcc (8 revisions) (flutter/flutter#158541)
2024-11-13 [email protected] Allow `devDependencies` to be omitted and not cause a tool crash. (flutter/flutter#158518)
2024-11-13 [email protected] Explain how to use `flutter channel`. (flutter/flutter#158533)
2024-11-13 [email protected] Clean up dependabot config, add github-action group (flutter/flutter#158408)
2024-11-12 [email protected] Update test to include more complete instructions for how to run tests locally, add example to andoid 11 tests as well (flutter/flutter#158528)
2024-11-12 [email protected] force Linux plugin_test to run on Ubuntu 20.04 (flutter/flutter#158529)
2024-11-12 [email protected] Support materialTapTargetSize in PopupMenuButton (flutter/flutter#158357)
2024-11-12 [email protected] [SwiftPM] Update .flutter-plugin-dependencies format (flutter/flutter#158138)
2024-11-12 [email protected] add filesystem error handling to `systemTempDirectory` (flutter/flutter#158481)
2024-11-12 [email protected] Made Cupertino dialog more like a native dialog in dark mode (flutter/flutter#157218)
2024-11-12 [email protected] Roll Flutter Engine from b0a4ca92c49e to 877abb9ad6ff (2 revisions) (flutter/flutter#158506)
2024-11-12 [email protected] Fix `NavigationBar` label style customization on the widget level (flutter/flutter#158510)
2024-11-12 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Add test for `dynamic_content_color.0.dart` (#158309)" (flutter/flutter#158511)
2024-11-12 [email protected] Add test for `dynamic_content_color.0.dart` (flutter/flutter#158309)
2024-11-12 [email protected] Roll Flutter Engine from a672f971c659 to b0a4ca92c49e (2 revisions) (flutter/flutter#158488)
2024-11-12 [email protected] Roll Flutter Engine from 35041f118744 to a672f971c659 (1 revision) (flutter/flutter#158487)
2024-11-12 [email protected] Roll Flutter Engine from 7b3eacd20eb6 to 35041f118744 (9 revisions) (flutter/flutter#158485)
2024-11-11 [email protected] [SwiftPM] Simplify logic that determines if CocoaPods is used (flutter/flutter#158409)
2024-11-11 [email protected] Fix Chip draws `InkWell.hoverColor` is drawn on top of the provided background color with `hovered` state (flutter/flutter#158454)
2024-11-11 [email protected] Roll Flutter Engine from 3cb6f4de89b6 to 7b3eacd20eb6 (1 revision) (flutter/flutter#158464)
2024-11-11 [email protected] Roll Packages from bb5a258 to 72356fd (8 revisions) (flutter/flutter#158378)
2024-11-11 [email protected] Roll Flutter Engine from e9a44820f302 to 3cb6f4de89b6 (3 revisions) (flutter/flutter#158456)
2024-11-11 [email protected] Replace custom `RPCErrorCodes` with `RPCErrorKind` from `package:vm_service` (flutter/flutter#158379)
2024-11-11 [email protected] Roll Flutter Engine from d90e9f4718b8 to e9a44820f302 (1 revision) (flutter/flutter#158453)
2024-11-11 [email protected] Roll Flutter Engine from 01c76e42c20f to d90e9f4718b8 (1 revision) (flutter/flutter#158443)
2024-11-11 [email protected] Roll Flutter Engine from 9b4c3b3d5518 to 01c76e42c20f (3 revisions) (flutter/flutter#158438)
2024-11-11 [email protected] Remove block and line comments when detecting '.flutter-plugins' in settings.gradle(.kts) (flutter/flutter#155488)
2024-11-11 [email protected] Add `SafeArea` DartPad sample (flutter/flutter#158019)
2024-11-10 [email protected] Marks Linux analyzer_benchmark to be flaky (flutter/flutter#158244)
2024-11-10 [email protected] remove `bringup` status for recently re-subsharded targets (flutter/flutter#158217)
2024-11-09 [email protected] Roll Flutter Engine from 690cdfd09beb to 9b4c3b3d5518 (1 revision) (flutter/flutter#158418)
2024-11-09 [email protected] Marks Mac_benchmark complex_layout_scroll_perf_macos__timeline_summary to be flaky (flutter/flutter#158252)
2024-11-09 [email protected] Roll Flutter Engine from ca6f5110d9d3 to 690cdfd09beb (1 revision) (flutter/flutter#158414)
2024-11-09 [email protected] Roll Flutter Engine from 2f097cfd3d2d to ca6f5110d9d3 (3 revisions) (flutter/flutter#158411)
2024-11-09 [email protected] Roll Flutter Engine from 54df0b8a4784 to 2f097cfd3d2d (1 revision) (flutter/flutter#158407)
2024-11-08 [email protected] Roll Flutter Engine from b7134d373ef8 to 54df0b8a4784 (2 revisions) (flutter/flutter#158405)
2024-11-08 [email protected] Roll Flutter Engine from 6b77347edfc5 to b7134d373ef8 (3 revisions) (flutter/flutter#158402)
2024-11-08 [email protected] Roll Flutter Engine from 1b567e80386e to 6b77347edfc5 (4 revisions) (flutter/flutter#158398)
2024-11-08 [email protected] Roll Flutter Engine from a08bd5a07c2a to 1b567e80386e (1 revision) (flutter/flutter#158393)
...
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: fidelity Matching the OEM platforms better f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels. will affect goldens Changes to golden files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make CupertinoAlertDialog clearly visible in dark mode

5 participants