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 Appearance module to observe application appearance #1340

Merged
merged 1 commit into from
Aug 10, 2022

Conversation

christophpurrer
Copy link

@christophpurrer christophpurrer commented Aug 9, 2022

Please select one of the following

  • I am removing an existing difference between facebook/react-native and microsoft/react-native-macos 👍
  • I am cherry-picking a change from Facebook's react-native into microsoft/react-native-macos 👍
  • I am making a fix / change for the macOS implementation of react-native
  • I am making a change required for Microsoft usage of react-native

Summary

This fixes the Appearance.getColorScheme() API to return the application-level appearance instead of the last appearance of any root view, which breaks down in multi-window applications.

In Messenger Desktop we always respect the OS appearance for main and setting windows, but force a darkTheme in the calling UI.
W/o this change returning from the calling UI would result in a wrong appearance setting on light theme OS setting.

Changelog

[macOS] [Fixed] - Fix Appearance module to observe application appearance

Test Plan

I have added this snippet to RNTester-macOS/ViewController.m

- (void)viewWillAppear {
    [super viewWillAppear];
    NSAppearance* appearance = [NSAppearance appearanceNamed:NSAppearanceNameVibrantLight];
    self.view.window.appearance = appearance;
}

The macOS appearance was set to darkTheme.
(The test plan is not ideal as I don't have a valid multi-window setup, but it should suffice for a basic test)

Before

b1.mov

After

a.mov

@Saadnajmi
Copy link
Collaborator

Thanks for the fix! Normally would ask to refactor the ifdef so that it's actually 2 methods calling a common block, but in the interest of time, I'll just merge this.

This fixes the `Appearance.getColorScheme()` API to return the application-level appearance instead of the last appearance of any root view, which breaks down in multi-window applications.

In Messenger Desktop we always respect the OS appearance for main and setting windows, but force a darkTheme in the calling UI.
W/o this change returning from the calling UI would result in a wrong appearance setting on light theme OS setting
@Saadnajmi Saadnajmi merged commit c3e847a into microsoft:main Aug 10, 2022
shwanton pushed a commit to shwanton/react-native-macos that referenced this pull request Feb 13, 2023
This fixes the `Appearance.getColorScheme()` API to return the application-level appearance instead of the last appearance of any root view, which breaks down in multi-window applications.

In Messenger Desktop we always respect the OS appearance for main and setting windows, but force a darkTheme in the calling UI.
W/o this change returning from the calling UI would result in a wrong appearance setting on light theme OS setting

Co-authored-by: Scott Kyle <skyle@fb.com>
shwanton pushed a commit to shwanton/react-native-macos that referenced this pull request Mar 10, 2023
This fixes the `Appearance.getColorScheme()` API to return the application-level appearance instead of the last appearance of any root view, which breaks down in multi-window applications.

In Messenger Desktop we always respect the OS appearance for main and setting windows, but force a darkTheme in the calling UI.
W/o this change returning from the calling UI would result in a wrong appearance setting on light theme OS setting

Co-authored-by: Scott Kyle <skyle@fb.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants