Back out "Add Appearance.setColorScheme support"

Summary:
See https://github.com/facebook/react-native/pull/35989#discussion_r1101016329

Changelog:
[General][Fixed] - Back out "Add Appearance.setColorScheme support"

Reviewed By: jacdebug

Differential Revision: D43148056

fbshipit-source-id: 823ab8276207f243b788ce7757839a3e95bdbe07
This commit is contained in:
Nick Gerleman
2023-02-09 00:54:42 -08:00
committed by Facebook GitHub Bot
parent 7c82a3fa11
commit 6d1667cf86
8 changed files with 0 additions and 63 deletions
-10
View File
@@ -28,16 +28,6 @@ export namespace Appearance {
*/
export function getColorScheme(): ColorSchemeName;
/**
* Set the color scheme preference. This is useful for overriding the default
* color scheme preference for the app. Note that this will not change the
* appearance of the system UI, only the appearance of the app.
* Only available on iOS 13+ and Android 10+.
*/
export function setColorScheme(
scheme: ColorSchemeName | null | undefined,
): void;
/**
* Add an event handler that is fired when appearance preferences change.
*/
-11
View File
@@ -85,17 +85,6 @@ module.exports = {
return nativeColorScheme;
},
setColorScheme(colorScheme: ?ColorSchemeName): void {
const nativeColorScheme = colorScheme == null ? 'unspecified' : colorScheme;
invariant(
colorScheme === 'dark' || colorScheme === 'light' || colorScheme == null,
"Unrecognized color scheme. Did you mean 'dark', 'light' or null?",
);
NativeAppearance?.setColorScheme?.(nativeColorScheme);
},
/**
* Add an event handler that is fired when appearance preferences change.
*/
-1
View File
@@ -26,7 +26,6 @@ export interface Spec extends TurboModule {
// types.
/* 'light' | 'dark' */
+getColorScheme: () => ?string;
+setColorScheme?: (colorScheme: string) => void;
// RCTEventEmitter
+addListener: (eventName: string) => void;
-1
View File
@@ -8,7 +8,6 @@
#import <UIKit/UIKit.h>
#import <React/RCTBridgeModule.h>
#import <React/RCTConvert.h>
#import <React/RCTEventEmitter.h>
RCT_EXTERN void RCTEnableAppearancePreference(BOOL enabled);
-26
View File
@@ -10,7 +10,6 @@
#import <FBReactNativeSpec/FBReactNativeSpec.h>
#import <React/RCTConstants.h>
#import <React/RCTEventEmitter.h>
#import <React/RCTUtils.h>
#import "CoreModulesPlugins.h"
@@ -69,20 +68,6 @@ NSString *RCTColorSchemePreference(UITraitCollection *traitCollection)
return RCTAppearanceColorSchemeLight;
}
@implementation RCTConvert (UIUserInterfaceStyle)
RCT_ENUM_CONVERTER(
UIUserInterfaceStyle,
(@{
@"light" : @(UIUserInterfaceStyleLight),
@"dark" : @(UIUserInterfaceStyleDark),
@"unspecified" : @(UIUserInterfaceStyleUnspecified)
}),
UIUserInterfaceStyleUnspecified,
integerValue);
@end
@interface RCTAppearance () <NativeAppearanceSpec>
@end
@@ -107,17 +92,6 @@ RCT_EXPORT_MODULE(Appearance)
return std::make_shared<NativeAppearanceSpecJSI>(params);
}
RCT_EXPORT_METHOD(setColorScheme : (NSString *)style)
{
UIUserInterfaceStyle userInterfaceStyle = [RCTConvert UIUserInterfaceStyle:style];
NSArray<__kindof UIWindow *> *windows = RCTSharedApplication().windows;
if (@available(iOS 13.0, *)) {
for (UIWindow *window in windows) {
window.overrideUserInterfaceStyle = userInterfaceStyle;
}
}
}
RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSString *, getColorScheme)
{
if (_currentColorScheme == nil) {
@@ -11,7 +11,6 @@ import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatDelegate;
import com.facebook.fbreact.specs.NativeAppearanceSpec;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.ReactApplicationContext;
@@ -67,17 +66,6 @@ public class AppearanceModule extends NativeAppearanceSpec {
return "light";
}
@Override
public void setColorScheme(String style) {
if (style == "dark") {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
} else if (style == "light") {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
} else if (style == "unspecified") {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
}
}
@Override
public String getColorScheme() {
// Attempt to use the Activity context first in order to get the most up to date
@@ -14,7 +14,6 @@ rn_android_library(
deps = [
react_native_dep("third-party/java/jsr-305:jsr-305"),
react_native_dep("third-party/android/androidx:annotation"),
react_native_dep("third-party/android/androidx:appcompat"),
react_native_target("java/com/facebook/react/bridge:bridge"),
react_native_target("java/com/facebook/react/common:common"),
react_native_target("java/com/facebook/react/module/annotations:annotations"),
@@ -15,7 +15,6 @@ rn_android_library(
react_native_dep("libraries/fresco/fresco-react-native:imagepipeline"),
react_native_dep("libraries/soloader/java/com/facebook/soloader:soloader"),
react_native_dep("third-party/android/androidx:annotation"),
react_native_dep("third-party/android/androidx:appcompat"),
react_native_dep("third-party/android/androidx:core"),
react_native_dep("third-party/android/androidx:fragment"),
react_native_dep("third-party/android/androidx:legacy-support-core-utils"),