Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: CupertinoSheetTransition should change SystemUIOverlayStyle based on theme #164680

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rkishan516
Copy link
Contributor

@rkishan516 rkishan516 commented Mar 6, 2025

Fix: CupertinoSheetTransition should change SystemUIOverlayStyle based on theme
fixes: #164633

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].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@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 Mar 6, 2025
@rkishan516 rkishan516 changed the title Fix: SystemUIOverlayStyle based on theme Fix: CupertinoSheetTransition should change SystemUIOverlayStyle based on theme Mar 6, 2025
final bool isDarkMode = CupertinoTheme.brightnessOf(context) == Brightness.dark;
final Color overlayColor = isDarkMode ? const Color(0xFFc8c8c8) : const Color(0xFF000000);

SystemChrome.setSystemUIOverlayStyle(
isDarkMode ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark,
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't quite the correct function, as the sheet needs to set the SystemUIOverlayStyle to light regardless of theme. Since when the sheet is opened, the system UI overlay is always on a black background.

The problem is that this delegated transition is wrapped around the previous route, and does not go away when the sheet is popped. The delegated transition is waiting to be played again. It might be better to move the call to setSystemUIOverlayStyle to one of the sheet's build methods. Or wrap this call here with if (!secondaryAnimation.isDismissed) might work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohh, yes correct. So, it should be SystemUIOverlayStyle.light when sheet is visible. Otherwise inverse of theme.

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.

LGTM, but needs a test.

@rkishan516 rkishan516 force-pushed the cupertino-sheet-route-system-ui-overlay branch from 199799e to 5ad753e Compare March 19, 2025 02:55
@rkishan516 rkishan516 force-pushed the cupertino-sheet-route-system-ui-overlay branch from 5ad753e to f46c51b Compare March 19, 2025 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[iOS] CupertinoSheetRoute doesn't reset SystemUiOverlayStyle when closed
2 participants