From 6ecf6b105da27b872a37ce7043564aa71bf20217 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Sun, 16 Oct 2022 01:53:18 -0700 Subject: [PATCH] Add webview background defaults to device color mode --- mobile/App.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mobile/App.tsx b/mobile/App.tsx index 7af2b9ba..c3b09cd9 100644 --- a/mobile/App.tsx +++ b/mobile/App.tsx @@ -12,13 +12,13 @@ const backgroundColors = { }; const App = () => { - const colorScheme = Appearance.getColorScheme(); + const colorScheme = Appearance.getColorScheme() ?? 'light'; const torClient = new TorClient(); const webViewRef = useRef(); const uri = (Platform.OS === 'android' ? 'file:///android_asset/' : '') + 'Web.bundle/index.html'; const injectMessageResolve = (id: string, data?: object) => { - const json = JSON.stringify((data != null) || {}); + const json = JSON.stringify(data != null || {}); webViewRef.current?.injectJavaScript( `(function() {window.NativeRobosats.onMessageResolve(${id}, ${json});})();`, ); @@ -145,6 +145,7 @@ const App = () => { }} onMessage={onMessage} // @ts-expect-error + style={{ backgroundColor: backgroundColors[colorScheme] }} ref={(ref) => (webViewRef.current = ref)} overScrollMode='never' javaScriptEnabled={true}