Skip to content

Commit fa4aff2

Browse files
authored
Merge pull request #101 from mendix/fix/dark-mode
Add safe check for dark mode in RN0.63
2 parents a46816e + 552babe commit fa4aff2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

styles/native/ts/app/custom-variables.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,15 @@ export const brand: VariablesBrand = {
4141
dangerLight: `rgba(${anyColorToRgbString("#ed1c24")}, 0.14)`,
4242
};
4343
//
44+
// Safely check if Appearance API is available in this version of React Native
45+
const Appearance = require("react-native").Appearance;
4446
// Dark Mode - Inherits OS theme if possible
45-
export const darkMode = NativeModules && NativeModules.RNDarkMode && NativeModules.RNDarkMode.initialMode
46-
? NativeModules.RNDarkMode.initialMode === "dark"
47-
: false;
47+
export const darkMode =
48+
NativeModules && NativeModules.RNDarkMode && NativeModules.RNDarkMode.initialMode
49+
? NativeModules.RNDarkMode.initialMode === "dark"
50+
: Appearance
51+
? Appearance.getColorScheme() === "dark"
52+
: false;
4853
//
4954
// Background Colors
5055
const backgroundColor = darkMode ? "#000" : "#FFF";

0 commit comments

Comments
 (0)