diff --git a/apps/mobile/app/app.tsx b/apps/mobile/app/app.tsx index 1c9323b84..7e92c8042 100644 --- a/apps/mobile/app/app.tsx +++ b/apps/mobile/app/app.tsx @@ -127,8 +127,12 @@ export const withTheme = (Element: (props: any) => JSX.Element) => { .then((theme) => { if (theme) { theme.colorScheme === "dark" - ? useThemeStore.getState().setDarkTheme(theme) - : useThemeStore.getState().setLightTheme(theme); + ? useThemeStore.setState({ + darkTheme: theme + }) + : useThemeStore.setState({ + lightTheme: theme + }); } }) .catch(() => { @@ -138,9 +142,9 @@ export const withTheme = (Element: (props: any) => JSX.Element) => { const listener = Appearance.addChangeListener(({ colorScheme }) => { if (colorScheme && SettingsService.getProperty("useSystemTheme")) { - useThemeStore - .getState() - .setColorScheme(colorScheme as "light" | "dark"); + useThemeStore.setState({ + colorScheme: colorScheme as "light" | "dark" + }); } }); return () => { diff --git a/apps/mobile/app/stores/use-theme-store.ts b/apps/mobile/app/stores/use-theme-store.ts index 6cec58c9e..d0e4ebf65 100644 --- a/apps/mobile/app/stores/use-theme-store.ts +++ b/apps/mobile/app/stores/use-theme-store.ts @@ -76,18 +76,14 @@ export const useThemeStore = create((set, get) => ({ ? (Appearance.getColorScheme() as "dark" | "light") : SettingsService.get().colorScheme, setDarkTheme: (darkTheme) => { - switchThemeWithAnimation(() => { - set({ darkTheme }); - changeSystemBarColors(); - SettingsService.setProperty("darkTheme", darkTheme); - }); + set({ darkTheme }); + changeSystemBarColors(); + SettingsService.setProperty("darkTheme", darkTheme); }, setLightTheme: (lightTheme) => { - switchThemeWithAnimation(() => { - set({ lightTheme }); - changeSystemBarColors(); - SettingsService.setProperty("lighTheme", lightTheme); - }); + set({ lightTheme }); + changeSystemBarColors(); + SettingsService.setProperty("lighTheme", lightTheme); }, setColorScheme: (colorScheme) => { switchThemeWithAnimation(() => { diff --git a/apps/mobile/patches/react-native-theme-switch-animation+0.6.0.patch b/apps/mobile/patches/react-native-theme-switch-animation+0.6.0.patch new file mode 100644 index 000000000..8d35b5ec9 --- /dev/null +++ b/apps/mobile/patches/react-native-theme-switch-animation+0.6.0.patch @@ -0,0 +1,65 @@ +diff --git a/node_modules/react-native-theme-switch-animation/android/src/main/java/com/themeswitchanimation/ThemeSwitchAnimationModule.java b/node_modules/react-native-theme-switch-animation/android/src/main/java/com/themeswitchanimation/ThemeSwitchAnimationModule.java +index f4630ac..a3a837f 100644 +--- a/node_modules/react-native-theme-switch-animation/android/src/main/java/com/themeswitchanimation/ThemeSwitchAnimationModule.java ++++ b/node_modules/react-native-theme-switch-animation/android/src/main/java/com/themeswitchanimation/ThemeSwitchAnimationModule.java +@@ -13,7 +13,7 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule; + import com.facebook.react.bridge.ReactMethod; + import com.facebook.react.modules.core.DeviceEventManagerModule; + +-public class ThemeSwitchAnimationModule extends ThemeSwitchAnimationModuleSpec { ++public class ThemeSwitchAnimationModule extends com.themeswitchanimation.ThemeSwitchAnimationModuleSpec { + public static final String NAME = "ThemeSwitchAnimationModule"; + + private ReactContext reactContext; +@@ -38,6 +38,12 @@ public class ThemeSwitchAnimationModule extends ThemeSwitchAnimationModuleSpec { + this.isAnimating = true; + this.rootView = (ViewGroup) getCurrentActivity().getWindow().getDecorView(); + this.capturedImageBitmap = captureScreenshot(this.rootView, this.reactContext); ++ if (this.capturedImageBitmap == null) { ++ reactContext ++ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) ++ .emit("FINISHED_FREEZING_SCREEN", null); ++ return; ++ } + this.capturedImageView = createImageView(this.capturedImageBitmap, this.reactContext); + + reactContext.runOnUiQueueThread(() -> { +@@ -57,6 +63,9 @@ public class ThemeSwitchAnimationModule extends ThemeSwitchAnimationModuleSpec { + @Override + public void run() { + if (isAnimating) { ++ if (capturedImageView == null) { ++ cleanUp(); ++ } + switch (animationType) { + case "circular": + Animations.performCircleAnimation(capturedImageView, rootView, (int) duration, cxRatio, cyRatio, reactContext, new Runnable() { +@@ -94,16 +103,22 @@ public class ThemeSwitchAnimationModule extends ThemeSwitchAnimationModuleSpec { + capturedImageBitmap.recycle(); + capturedImageBitmap = null; + } +- rootView.removeView(capturedImageView); ++ if (capturedImageView != null) { ++ rootView.removeView(capturedImageView); ++ } + isAnimating = false; + } + + public static Bitmap captureScreenshot(View rootView, ReactContext reactContext) { +- Bitmap capturedImageBitmap = Bitmap.createBitmap(rootView.getWidth(), rootView.getHeight(), Bitmap.Config.ARGB_8888); +- Canvas canvas = new Canvas(capturedImageBitmap); +- rootView.draw(canvas); +- +- return capturedImageBitmap; ++ try { ++ Bitmap capturedImageBitmap = Bitmap.createBitmap(rootView.getWidth(), rootView.getHeight(), Bitmap.Config.ARGB_8888); ++ Canvas canvas = new Canvas(capturedImageBitmap); ++ rootView.draw(canvas); ++ ++ return capturedImageBitmap; ++ } catch (Exception e) { ++ return null; ++ } + } + + public static ImageView createImageView(Bitmap capturedImageBitmap, ReactContext reactContext) {