A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
mobile: add theme switch animation
Ammar Ahmedd3221abd7ee7
diff --git a/apps/mobile/app/stores/use-theme-store.ts b/apps/mobile/app/stores/use-theme-store.tsindex b15adaf1f..59b4a7102 100644--- a/apps/mobile/app/stores/use-theme-store.ts+++ b/apps/mobile/app/stores/use-theme-store.ts@@ -21,6 +21,7 @@ import { ThemeDefinition } from "@notesnook/theme";import { Appearance } from "react-native";import create, { State } from "zustand";import SettingsService from "../services/settings";+import switchTheme from "react-native-theme-switch-animation";export interface ThemeStore extends State {lightTheme: ThemeDefinition;@@ -31,6 +32,20 @@ export interface ThemeStore extends State {setColorScheme: (colorScheme?: "dark" | "light") => void;}+function switchThemeWithAnimation(fn: () => void) {+ switchTheme({+ switchThemeFunction: fn,+ animationConfig: {+ type: "circular",+ duration: 500,+ startingPoint: {+ cxRatio: 0,+ cyRatio: 0+ }+ }+ });+}+export const useThemeStore = create<ThemeStore>((set, get) => ({lightTheme: SettingsService.get().lighTheme,darkTheme: SettingsService.get().darkTheme,@@ -38,27 +53,33 @@ export const useThemeStore = create<ThemeStore>((set, get) => ({? (Appearance.getColorScheme() as "dark" | "light"): SettingsService.get().colorScheme,setDarkTheme: (darkTheme) => {- set({ darkTheme });- SettingsService.setProperty("darkTheme", darkTheme);+ switchThemeWithAnimation(() => {+ set({ darkTheme });+ SettingsService.setProperty("darkTheme", darkTheme);+ });},setLightTheme: (lightTheme) => {- set({ lightTheme });- SettingsService.setProperty("lighTheme", lightTheme);+ switchThemeWithAnimation(() => {+ set({ lightTheme });+ SettingsService.setProperty("lighTheme", lightTheme);+ });},setColorScheme: (colorScheme) => {- const nextColorScheme =- colorScheme === undefined- ? get().colorScheme === "dark"- ? "light"- : "dark"- : colorScheme;- set({- colorScheme: nextColorScheme- });- if (!SettingsService.getProperty("useSystemTheme")) {- SettingsService.set({+ switchThemeWithAnimation(() => {+ const nextColorScheme =+ colorScheme === undefined+ ? get().colorScheme === "dark"+ ? "light"+ : "dark"+ : colorScheme;+ set({colorScheme: nextColorScheme});- }+ if (!SettingsService.getProperty("useSystemTheme")) {+ SettingsService.set({+ colorScheme: nextColorScheme+ });+ }+ });}}));diff --git a/apps/mobile/native/package.json b/apps/mobile/native/package.jsonindex 8168fd238..eded284e8 100644--- a/apps/mobile/native/package.json+++ b/apps/mobile/native/package.json@@ -63,7 +63,8 @@"react-native-vector-icons": "9.2.0","react-native-webview": "^11.14.1","react-native-zip-archive": "6.0.9",- "react-native-quick-sqlite": "^8.0.6"+ "react-native-quick-sqlite": "^8.0.6",+ "react-native-theme-switch-animation": "^0.6.0"},"devDependencies": {"@babel/core": "^7.20.0",diff --git a/apps/mobile/package-lock.json b/apps/mobile/package-lock.jsonindex eee1bfad0..eaef164fc 100644--- a/apps/mobile/package-lock.json+++ b/apps/mobile/package-lock.json@@ -27711,6 +27711,7 @@"react-native-share": "^7.2.0","react-native-svg": "^12.3.0","react-native-swiper-flatlist": "3.2.2",+ "react-native-theme-switch-animation": "^0.6.0","react-native-tooltips": "^1.0.3","react-native-vector-icons": "9.2.0","react-native-webview": "^11.14.1",@@ -44408,6 +44409,15 @@"react-native": ">=0.59.0"}},+ "node_modules/react-native-theme-switch-animation": {+ "version": "0.6.0",+ "resolved": "https://registry.npmjs.org/react-native-theme-switch-animation/-/react-native-theme-switch-animation-0.6.0.tgz",+ "integrity": "sha512-XC6xb1J6Pgq4XQFsq6KdxJugRHjwsj04qTDh9rZdi1mkNOy9QKtz7wCQHoK6q8CBZtF3R/sergCw9wZhIRXK3Q==",+ "peerDependencies": {+ "react": "*",+ "react-native": "*"+ }+ },"node_modules/react-native-tooltips": {"version": "1.0.3","license": "Apache License"@@ -80099,6 +80109,7 @@"react-native-share": "^7.2.0","react-native-svg": "^12.3.0","react-native-swiper-flatlist": "3.2.2",+ "react-native-theme-switch-animation": "^0.6.0","react-native-tooltips": "^1.0.3","react-native-vector-icons": "9.2.0","react-native-webview": "^11.14.1",@@ -88249,6 +88260,12 @@"version": "3.2.2","requires": {}},+ "react-native-theme-switch-animation": {+ "version": "0.6.0",+ "resolved": "https://registry.npmjs.org/react-native-theme-switch-animation/-/react-native-theme-switch-animation-0.6.0.tgz",+ "integrity": "sha512-XC6xb1J6Pgq4XQFsq6KdxJugRHjwsj04qTDh9rZdi1mkNOy9QKtz7wCQHoK6q8CBZtF3R/sergCw9wZhIRXK3Q==",+ "requires": {}+ },"react-native-tooltips": {"version": "1.0.3"},