From 4a5b3ffecc1c069f65b9553f5c4474ca050153af Mon Sep 17 00:00:00 2001 From: Bogdan Stefanescu <26150024+bog1200@users.noreply.github.com> Date: Tue, 8 Sep 2026 15:33:32 +0200 Subject: [PATCH 1/5] Feature flag: change color theme --- src/firebaseConfig.ts | 23 ++++++++++- src/styles/theme.alt.ts | 74 +++++++++++++++++++++++++++++++++ src/styles/theme.default.ts | 77 +++++++++++++++++++++++++++++++++++ src/styles/theme.ts | 81 +++++-------------------------------- 4 files changed, 182 insertions(+), 73 deletions(-) create mode 100644 src/styles/theme.alt.ts create mode 100644 src/styles/theme.default.ts diff --git a/src/firebaseConfig.ts b/src/firebaseConfig.ts index 73046a3..364372c 100644 --- a/src/firebaseConfig.ts +++ b/src/firebaseConfig.ts @@ -1,4 +1,6 @@ import { FirebaseApp, getApp, getApps, initializeApp } from "firebase/app" +import { fetchAndActivate, getRemoteConfig, getValue, type RemoteConfig } from "firebase/remote-config"; + import { initializeAuth, //@ts-ignore @@ -50,7 +52,26 @@ const getInternalAuth = (): Auth => { }; const auth = getInternalAuth(); -export { firebaseApp, auth }; +const remoteConfig: RemoteConfig | null = Platform.OS === "web" ? getRemoteConfig(firebaseApp) : null; +const remoteConfigValues: Record = {}; + +const loadRemoteConfigValues = async (): Promise> => { + if (!remoteConfig) { + return remoteConfigValues; + } + + await fetchAndActivate(remoteConfig); + + Object.keys(remoteConfig.defaultConfig).forEach((key) => { + remoteConfigValues[key] = getValue(remoteConfig, key).asString(); + }); + + return remoteConfigValues; +}; + +void loadRemoteConfigValues(); + +export { firebaseApp, auth, remoteConfig, remoteConfigValues }; export const isFirebaseConfigured = Boolean( firebaseConfig.apiKey && firebaseConfig.projectId && firebaseConfig.appId diff --git a/src/styles/theme.alt.ts b/src/styles/theme.alt.ts new file mode 100644 index 0000000..715728e --- /dev/null +++ b/src/styles/theme.alt.ts @@ -0,0 +1,74 @@ +export const COLORS = { + background: '#eef6ff', + surface: '#ffffff', + primary: '#4f46e5', + secondary: '#06b6d4', + textPrimary: '#0f172a', + textSecondary: '#334155', + border: '#bfdbfe', + divider: '#bfdbfe', + mapBackground: '#dbeafe', + mapText: '#1e3a8a', + icon: '#312e81', + shadow: '#1e293b', + + text: '#0b1220', + primaryDark: '#3730a3', + primaryLight: '#818cf8', + primarySubtle: '#e0e7ff', + backgroundDark: '#020617', + surfaceDark: '#0b1220', + surfaceElevatedDark: '#111b2e', + textDark: '#e2e8f0', + textSecondaryDark: '#94a3b8', + borderDark: '#1e293b', + + error: '#dc2626', + success: '#16a34a', + warning: '#d97706', +} as const; + +export const SPACING = { + xxs: 3, + xs: 4, + _6: 6, + sm: 8, + _10: 10, + _12: 12, + _14: 14, + md: 16, + _20: 20, + lg: 24, + xl: 32, + _38: 38, + xxl: 48, + notesMinHeight: 82, +} as const; + +export const TYPOGRAPHY = { + sizes: { + small: 12, + label: 14, + meta: 15, + body: 16, + subtitle: 18, + heading: 20, + sectionTitle: 22, + title: 24, + display: 32, + }, + weights: { + regular: '400', + medium: '500', + semibold: '600', + bold: '700', + }, +} as const; + +export const RADIUS = { + sm: 6, + md: 10, + field: 14, + lg: 16, + pill: 999, +} as const; diff --git a/src/styles/theme.default.ts b/src/styles/theme.default.ts new file mode 100644 index 0000000..152c566 --- /dev/null +++ b/src/styles/theme.default.ts @@ -0,0 +1,77 @@ +export const COLORS = { + // Legacy `colors` palette preserved as the main token set. + background: '#f6f1e8', + surface: '#fff9ef', + primary: '#8b5e3c', + secondary: '#c0925a', + textPrimary: '#2b2118', + textSecondary: '#6b5a4b', + border: '#d8c6b2', + divider: '#d8c6b2', + mapBackground: '#efe3d2', + mapText: '#6b5a4b', + icon: '#6b3f26', + shadow: '#2b2118', + + // Additional tokens used in native views. + text: '#12100A', + primaryDark: '#8b6520', + primaryLight: '#E5B84D', + primarySubtle: '#FBF3DF', + backgroundDark: '#0A0907', + surfaceDark: '#141210', + surfaceElevatedDark: '#1E1C18', + textDark: '#F5EED8', + textSecondaryDark: '#8C8070', + borderDark: '#2C2820', + + // Semantic + error: '#EF4444', + success: '#10B981', + warning: '#F59E0B', +} as const; + +export const SPACING = { + xxs: 3, + xs: 4, + _6: 6, + sm: 8, + _10: 10, + _12: 12, + _14: 14, + md: 16, + _20: 20, + lg: 24, + xl: 32, + _38: 38, + xxl: 48, + notesMinHeight: 82, +} as const; + +export const TYPOGRAPHY = { + sizes: { + small: 12, + label: 14, + meta: 15, + body: 16, + subtitle: 18, + heading: 20, + sectionTitle: 22, + title: 24, + display: 32, + }, + weights: { + regular: '400', + medium: '500', + semibold: '600', + bold: '700', + }, +} as const; + +export const RADIUS = { + sm: 6, + md: 10, + field: 14, + lg: 16, + pill: 999, +} as const; diff --git a/src/styles/theme.ts b/src/styles/theme.ts index 152c566..b51902c 100644 --- a/src/styles/theme.ts +++ b/src/styles/theme.ts @@ -1,77 +1,14 @@ -export const COLORS = { - // Legacy `colors` palette preserved as the main token set. - background: '#f6f1e8', - surface: '#fff9ef', - primary: '#8b5e3c', - secondary: '#c0925a', - textPrimary: '#2b2118', - textSecondary: '#6b5a4b', - border: '#d8c6b2', - divider: '#d8c6b2', - mapBackground: '#efe3d2', - mapText: '#6b5a4b', - icon: '#6b3f26', - shadow: '#2b2118', +import { remoteConfigValues } from "@/firebaseConfig"; +import * as defaultTheme from "./theme.default"; +import * as altTheme from "./theme.alt"; - // Additional tokens used in native views. - text: '#12100A', - primaryDark: '#8b6520', - primaryLight: '#E5B84D', - primarySubtle: '#FBF3DF', - backgroundDark: '#0A0907', - surfaceDark: '#141210', - surfaceElevatedDark: '#1E1C18', - textDark: '#F5EED8', - textSecondaryDark: '#8C8070', - borderDark: '#2C2820', +const useAltTheme = remoteConfigValues.newThemeTest === "true"; +const activeTheme = useAltTheme ? altTheme : defaultTheme; - // Semantic - error: '#EF4444', - success: '#10B981', - warning: '#F59E0B', -} as const; +export const COLORS = activeTheme.COLORS; -export const SPACING = { - xxs: 3, - xs: 4, - _6: 6, - sm: 8, - _10: 10, - _12: 12, - _14: 14, - md: 16, - _20: 20, - lg: 24, - xl: 32, - _38: 38, - xxl: 48, - notesMinHeight: 82, -} as const; +export const SPACING = activeTheme.SPACING; -export const TYPOGRAPHY = { - sizes: { - small: 12, - label: 14, - meta: 15, - body: 16, - subtitle: 18, - heading: 20, - sectionTitle: 22, - title: 24, - display: 32, - }, - weights: { - regular: '400', - medium: '500', - semibold: '600', - bold: '700', - }, -} as const; +export const TYPOGRAPHY = activeTheme.TYPOGRAPHY; -export const RADIUS = { - sm: 6, - md: 10, - field: 14, - lg: 16, - pill: 999, -} as const; +export const RADIUS = activeTheme.RADIUS; From 80fd6d4251f003f4a0cb8a349aa35594474f4792 Mon Sep 17 00:00:00 2001 From: Bogdan Stefanescu <26150024+bog1200@users.noreply.github.com> Date: Wed, 9 Sep 2026 15:21:57 +0200 Subject: [PATCH 2/5] Theme change test --- src/firebaseConfig.ts | 71 ++++++++++++++++++++++++++++++------------- src/styles/theme.ts | 9 ++---- 2 files changed, 53 insertions(+), 27 deletions(-) diff --git a/src/firebaseConfig.ts b/src/firebaseConfig.ts index 364372c..802c478 100644 --- a/src/firebaseConfig.ts +++ b/src/firebaseConfig.ts @@ -1,18 +1,22 @@ -import { FirebaseApp, getApp, getApps, initializeApp } from "firebase/app" -import { fetchAndActivate, getRemoteConfig, getValue, type RemoteConfig } from "firebase/remote-config"; +import { FirebaseApp, getApp, getApps, initializeApp } from "firebase/app"; +import { + fetchAndActivate, + getRemoteConfig, + getValue, +} from "firebase/remote-config"; import { initializeAuth, //@ts-ignore - getReactNativePersistence, // Method exists on native, compiler complains about web, but we don't use it there. - type Auth, getAuth -} from 'firebase/auth'; + getReactNativePersistence, + type Auth, + getAuth, +} from "firebase/auth"; import { firebaseConfig } from "@/firebaseEnv"; import { createAsyncStorage } from "@react-native-async-storage/async-storage"; import { Platform } from "react-native"; -import {GoogleSignin} from "@react-native-google-signin/google-signin"; +import { GoogleSignin } from "@react-native-google-signin/google-signin"; -// node_modules/@firebase/app/dist/app.d.ts (Private api) interface FirebaseAppInternal extends FirebaseApp { container?: { getProvider(name: string): { @@ -21,21 +25,23 @@ interface FirebaseAppInternal extends FirebaseApp { }; }; } -const firebaseApp: FirebaseApp = getApps().length > 0 ? getApp() : initializeApp(firebaseConfig); -// Set the Web Client ID for token verification -// Navive login prompt +const firebaseApp: FirebaseApp = getApps().length > 0 ? getApp() : initializeApp(firebaseConfig); + GoogleSignin.configure({ webClientId: firebaseConfig.googleClientId, - scopes: ["https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile"], + scopes: [ + "https://www.googleapis.com/auth/userinfo.email", + "https://www.googleapis.com/auth/userinfo.profile", + ], offlineAccess: false, }); + const getInternalAuth = (): Auth => { if (Platform.OS === "web") { return getAuth(firebaseApp); } - // Check if Auth has already been initialized to prevent Hot-Reload errors - // Not needed in prod app + const appAny = firebaseApp as FirebaseAppInternal; const authProvider = appAny.container?.getProvider("auth"); @@ -45,31 +51,54 @@ const getInternalAuth = (): Auth => { const persistence = createAsyncStorage("app"); - // Initialize for the first time return initializeAuth(firebaseApp, { persistence: getReactNativePersistence(persistence), }); }; const auth = getInternalAuth(); -const remoteConfig: RemoteConfig | null = Platform.OS === "web" ? getRemoteConfig(firebaseApp) : null; -const remoteConfigValues: Record = {}; +const remoteConfig = getRemoteConfig(firebaseApp); -const loadRemoteConfigValues = async (): Promise> => { +const DEFAULT_REMOTE_CONFIG_VALUES: Record = { + useAltTheme: false, +}; + +const remoteConfigValues: Record = { ...DEFAULT_REMOTE_CONFIG_VALUES }; + + +export const initializeRemoteConfig = async (): Promise> => { if (!remoteConfig) { return remoteConfigValues; } - await fetchAndActivate(remoteConfig); + remoteConfig.settings.minimumFetchIntervalMillis = 0; // 10 seconds for testing purposes, adjust as needed - Object.keys(remoteConfig.defaultConfig).forEach((key) => { - remoteConfigValues[key] = getValue(remoteConfig, key).asString(); + try { + await fetchAndActivate(remoteConfig); + } catch { + return remoteConfigValues; + } + + Object.keys(DEFAULT_REMOTE_CONFIG_VALUES).forEach((key) => { + remoteConfigValues[key] = getValue(remoteConfig, key).asBoolean(); }); return remoteConfigValues; }; -void loadRemoteConfigValues(); +export const getRemoteConfigValue = (key: string): boolean => { + if (!remoteConfig) { + return DEFAULT_REMOTE_CONFIG_VALUES[key] ?? false; + } + + const value = getValue(remoteConfig, key).asBoolean(); + console.log(`Remote config value for key "${key}": ${value}`); + return value ?? DEFAULT_REMOTE_CONFIG_VALUES[key] ?? false; +}; + +if (Platform.OS === "web" && typeof indexedDB !== "undefined") { + void initializeRemoteConfig(); +} export { firebaseApp, auth, remoteConfig, remoteConfigValues }; diff --git a/src/styles/theme.ts b/src/styles/theme.ts index b51902c..f6ce691 100644 --- a/src/styles/theme.ts +++ b/src/styles/theme.ts @@ -1,14 +1,11 @@ -import { remoteConfigValues } from "@/firebaseConfig"; +import {getRemoteConfigValue} from "@/firebaseConfig"; import * as defaultTheme from "./theme.default"; import * as altTheme from "./theme.alt"; -const useAltTheme = remoteConfigValues.newThemeTest === "true"; -const activeTheme = useAltTheme ? altTheme : defaultTheme; +const featureFlagValue = getRemoteConfigValue("newThemeTest") ?? false; +const activeTheme = featureFlagValue ? altTheme : defaultTheme; export const COLORS = activeTheme.COLORS; - export const SPACING = activeTheme.SPACING; - export const TYPOGRAPHY = activeTheme.TYPOGRAPHY; - export const RADIUS = activeTheme.RADIUS; From 34d86ec8e890603957fc432c47ed396a7de22316 Mon Sep 17 00:00:00 2001 From: Bogdan Stefanescu <26150024+bog1200@users.noreply.github.com> Date: Wed, 9 Sep 2026 16:10:20 +0200 Subject: [PATCH 3/5] Theme change test 2 --- src/views/navigation/IndexQuickActionsOverlay.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/views/navigation/IndexQuickActionsOverlay.tsx b/src/views/navigation/IndexQuickActionsOverlay.tsx index 9892b4a..d06b91f 100644 --- a/src/views/navigation/IndexQuickActionsOverlay.tsx +++ b/src/views/navigation/IndexQuickActionsOverlay.tsx @@ -93,7 +93,7 @@ const styles = StyleSheet.create({ alignItems: "center", justifyContent: "space-between", paddingHorizontal: SPACING._12, - backgroundColor: "rgba(255, 249, 239, 0.92)", + backgroundColor: COLORS.background, borderWidth: StyleSheet.hairlineWidth, borderColor: COLORS.border, }, @@ -145,7 +145,7 @@ const styles = StyleSheet.create({ gap: SPACING.xs, paddingHorizontal: SPACING.sm, paddingVertical: SPACING._10, - backgroundColor: "rgba(255, 249, 239, 0.92)", + backgroundColor: COLORS.background, borderRadius: RADIUS.pill, borderWidth: StyleSheet.hairlineWidth, borderColor: COLORS.border, From 9184dceaa9b69b22ee2431a81677764f93837714 Mon Sep 17 00:00:00 2001 From: Pavlos Spanoudakis Date: Wed, 9 Sep 2026 17:52:45 +0200 Subject: [PATCH 4/5] Add unified feature flags backed by Remote Config Adds a shared flag store with per-platform Remote Config clients: the Firebase JS SDK on web, React Native Firebase on native, both behind one initializeRemoteConfig() contract. Flags resolve during the existing startup gate, so the first render sees real values and a flag change applies on the next app start. Web falls back to a localStorage snapshot when the fetch fails; native falls back to the config the native SDK persists itself. Gates the Sober Check drawer entry behind enableSoberTest, and moves Remote Config setup out of firebaseConfig.ts. Co-Authored-By: Claude Opus 5 --- app.config.ts | 1 + package-lock.json | 773 ++++++++++++++++++++++ package.json | 2 + src/app/_layout.tsx | 19 +- src/featureFlags.ts | 71 ++ src/firebaseConfig.ts | 51 +- src/remoteConfigClient.ts | 52 ++ src/remoteConfigClient.web.ts | 53 ++ src/styles/theme.ts | 11 +- src/views/navigation/AppDrawerContent.tsx | 24 +- 10 files changed, 1003 insertions(+), 54 deletions(-) create mode 100644 src/featureFlags.ts create mode 100644 src/remoteConfigClient.ts create mode 100644 src/remoteConfigClient.web.ts diff --git a/app.config.ts b/app.config.ts index 9bf43ef..7bc0398 100644 --- a/app.config.ts +++ b/app.config.ts @@ -36,6 +36,7 @@ export default ({ config }: ConfigContext): ExpoConfig => ({ }, plugins: [ "expo-router", + "@react-native-firebase/app", [ "expo-location", { diff --git a/package-lock.json b/package-lock.json index 05fe143..d24d08f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,8 @@ "@react-native-async-storage/async-storage": "3.0.2", "@react-native-async-storage/expo-with-async-storage": "^1.0.0", "@react-native-community/datetimepicker": "8.6.0", + "@react-native-firebase/app": "^26.4.0", + "@react-native-firebase/remote-config": "^26.4.0", "@react-native-google-signin/google-signin": "16.1.2", "@react-navigation/drawer": "^7.9.8", "@reduxjs/toolkit": "^2.11.2", @@ -4193,6 +4195,735 @@ } } }, + "node_modules/@react-native-firebase/analytics": { + "version": "26.4.0", + "resolved": "https://registry.npmjs.org/@react-native-firebase/analytics/-/analytics-26.4.0.tgz", + "integrity": "sha512-moClYdlCnHTlgJzsK3VJENzhIga6vubK/SqE5NgzlCsjTC60Cs2jcm3phuZXgRL+LggMzz7lu+WirFNpQLk4Hg==", + "license": "Apache-2.0", + "peer": true, + "dependencies": { + "superstruct": "^2.0.2" + }, + "peerDependencies": { + "@react-native-firebase/app": "26.4.0", + "expo": ">=47.0.0" + }, + "peerDependenciesMeta": { + "expo": { + "optional": true + } + } + }, + "node_modules/@react-native-firebase/app": { + "version": "26.4.0", + "resolved": "https://registry.npmjs.org/@react-native-firebase/app/-/app-26.4.0.tgz", + "integrity": "sha512-lqs9vgPcniEw5a+NPRjGNXCQKwuGdVJoSB0iW0HvExR7aGEON/VZYOtSfElBCj3zTwQSiN732zREmqmKrW7Ixw==", + "license": "Apache-2.0", + "dependencies": { + "firebase": "12.17.1" + }, + "peerDependencies": { + "expo": ">=47.0.0", + "react": "*", + "react-native": "*" + }, + "peerDependenciesMeta": { + "expo": { + "optional": true + } + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/ai": { + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/@firebase/ai/-/ai-2.14.0.tgz", + "integrity": "sha512-TYEQqCQUTyVHuG/HVi9vau6F9kvEaS49o/hmdn/yUuN6ZXQkwIml2nNJTIBfjNl/r9LOxwUNILgcOY16nxObug==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/app-check-interop-types": "0.3.4", + "@firebase/component": "0.7.4", + "@firebase/logger": "0.5.1", + "@firebase/util": "1.15.2", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@firebase/app-types": "0.x" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/analytics": { + "version": "0.10.23", + "resolved": "https://registry.npmjs.org/@firebase/analytics/-/analytics-0.10.23.tgz", + "integrity": "sha512-34ALWXzWA6PTRUA5hipZmsm1RKzeecw5J1+qTCXsiMzwLqONC+GuTIQSdmm91MmTAEA+wG1Q5t0IFahcYQOqAA==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.4", + "@firebase/installations": "0.6.23", + "@firebase/logger": "0.5.1", + "@firebase/util": "1.15.2", + "tslib": "^2.1.0" + }, + "peerDependencies": { + "@firebase/app": "0.x" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/analytics-compat": { + "version": "0.2.29", + "resolved": "https://registry.npmjs.org/@firebase/analytics-compat/-/analytics-compat-0.2.29.tgz", + "integrity": "sha512-allztvCvCUlItZzD97TiRAtGoFJzR1FQFmLxbaLc6PvgscqD9cl5NdKPTtka6keShVYXvCZJpzWcRoH4TME8rw==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/analytics": "0.10.23", + "@firebase/analytics-types": "0.8.4", + "@firebase/component": "0.7.4", + "@firebase/util": "1.15.2", + "tslib": "^2.1.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@firebase/app-compat": "0.x" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/analytics-types": { + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/@firebase/analytics-types/-/analytics-types-0.8.4.tgz", + "integrity": "sha512-zQ+XTgkwH6CY/eUSHJRP7e4LxM30RCxlCmob5sy2axs25GE3Ny0XdgpDscMTHHQIGqWkxPXad4w2Mw9sCgT8zQ==", + "license": "Apache-2.0" + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/app": { + "version": "0.16.0", + "resolved": "https://registry.npmjs.org/@firebase/app/-/app-0.16.0.tgz", + "integrity": "sha512-G+ZGEyVP8YTb3ay6A+XpcYgFH3sTESHcnHU/EyTktodqhz2BHkLq+QEP7IVwjiMX0cxYwpVKip0/wC0KZcn9vQ==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.4", + "@firebase/logger": "0.5.1", + "@firebase/util": "1.15.2", + "idb": "7.1.1", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/app-check": { + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/@firebase/app-check/-/app-check-0.13.0.tgz", + "integrity": "sha512-AbMttBKazQvGVXBZhQdVAdPzRhwHyJAY3Ghu5y2C7IZKIDIppzNYz0shTZ1mP4FBJa+28BuC4t+5h1Q6pT3Asg==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.4", + "@firebase/logger": "0.5.1", + "@firebase/util": "1.15.2", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@firebase/app": "0.x" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/app-check-compat": { + "version": "0.4.6", + "resolved": "https://registry.npmjs.org/@firebase/app-check-compat/-/app-check-compat-0.4.6.tgz", + "integrity": "sha512-2pzNEZEkX84jSqy6TH6FI1HSLA1lc7kakRUybBbKjg9YhIttPlW/XX3N9CDtChji2PTTPWVPZiWhB10exHfA+A==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/app-check": "0.13.0", + "@firebase/app-check-types": "0.5.4", + "@firebase/component": "0.7.4", + "@firebase/logger": "0.5.1", + "@firebase/util": "1.15.2", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@firebase/app-compat": "0.x" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/app-check-interop-types": { + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/@firebase/app-check-interop-types/-/app-check-interop-types-0.3.4.tgz", + "integrity": "sha512-zz3i6e13B8BfWiLy8MABtTh8aGIACgKbf9UVnyHcWs+yQzJXgQcl8A46b0zfaiJHdQ+niF0ouAfcpuf+3LMPQg==", + "license": "Apache-2.0" + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/app-check-types": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/@firebase/app-check-types/-/app-check-types-0.5.4.tgz", + "integrity": "sha512-xV7JsIyzVr15aA7f3Pi0rB9gdBuVubs89FGA8VkRYA4g0l78poADgdfrScgf7NndSg9mm7cR7PJyY0+t22KaGw==", + "license": "Apache-2.0" + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/app-compat": { + "version": "0.5.16", + "resolved": "https://registry.npmjs.org/@firebase/app-compat/-/app-compat-0.5.16.tgz", + "integrity": "sha512-shQq37O8qELDzvsVwYPlDXwD1zlcrZ0m2bpBF5ov2HSbY8x+AHsnL5TtJ2e1JAfkQN05qHao1AfabS69PN6GiA==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/app": "0.16.0", + "@firebase/component": "0.7.4", + "@firebase/logger": "0.5.1", + "@firebase/util": "1.15.2", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/app-types": { + "version": "0.9.5", + "resolved": "https://registry.npmjs.org/@firebase/app-types/-/app-types-0.9.5.tgz", + "integrity": "sha512-YevqTjvo7Iujsa9Dwowmd6dSoElhzmD63ZSrq6bzjvQ6POjYgNjOFHLmNIgJs48eNO093NCERibuFnxbfOvU7A==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/logger": "0.5.1" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/auth": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/@firebase/auth/-/auth-1.13.4.tgz", + "integrity": "sha512-s+NS1aV0DDyyfoIMeSz53HXnVTv7ufJjJfrP63XyaWHweJ5vOoxKWrTm5tO7S7PDqvyOa/Wi3oP0dgAo6JTMMA==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.4", + "@firebase/logger": "0.5.1", + "@firebase/util": "1.15.2", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@react-native-async-storage/async-storage": "^2.2.0 || ^3.0.0" + }, + "peerDependenciesMeta": { + "@react-native-async-storage/async-storage": { + "optional": true + } + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/auth-compat": { + "version": "0.6.9", + "resolved": "https://registry.npmjs.org/@firebase/auth-compat/-/auth-compat-0.6.9.tgz", + "integrity": "sha512-/hHeTBmQ61+N5J1RECls+WfskZTY78JXr7aO5EMOfUpqJvDqvoS+568k0rp6Ss/4UWwBjadILs+H+SGy1zCS3A==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/auth": "1.13.4", + "@firebase/auth-types": "0.13.1", + "@firebase/component": "0.7.4", + "@firebase/util": "1.15.2", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@firebase/app-compat": "0.x" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/auth-interop-types": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/@firebase/auth-interop-types/-/auth-interop-types-0.2.5.tgz", + "integrity": "sha512-1Li/YuBDBAXcKv7BzY4U28gontUmAaw53sYiqbaVOMCFb2lFKK/c3CGMUWqtwe7+TXrl3poWnTCL5umYBg85Eg==", + "license": "Apache-2.0" + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/auth-types": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/@firebase/auth-types/-/auth-types-0.13.1.tgz", + "integrity": "sha512-0c1Mnid0uMDfGJHeUS4zfvBa4/CedJXotGy/n/NZJnBjwiJawt0ZYU+wH2VAVLiRCEfG2ncCkAX3yd1/2nrB7g==", + "license": "Apache-2.0", + "peerDependencies": { + "@firebase/app-types": "0.x", + "@firebase/util": "1.x" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/component": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.7.4.tgz", + "integrity": "sha512-tLpOaaCol9ugUIYp2R3CbWPPA8Ajg/papX/XHEy8U52b/QXH3BbX8tTJX9aShDCjp+9sMAxMLD94i7lresdugQ==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/util": "1.15.2", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/data-connect": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/@firebase/data-connect/-/data-connect-0.7.3.tgz", + "integrity": "sha512-nHBFk3Ntl+NZCRIUG2d5j7I69P0otjyQ/duhVKLbw4+5cNke/F6RK1pdE5Jnf831/QOTs2Bd00LlxlZ+jNsb9w==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/auth-interop-types": "0.2.5", + "@firebase/component": "0.7.4", + "@firebase/logger": "0.5.1", + "@firebase/util": "1.15.2", + "tslib": "^2.1.0" + }, + "peerDependencies": { + "@firebase/app": "0.x" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/database": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@firebase/database/-/database-1.1.4.tgz", + "integrity": "sha512-D+j4+8uhGtNd1tVD+X+c8JrC4ppStGJKyujSQt2NPwdN26QcCk0BeIxue+UqspHkHiFHyQOimwlzjLewGq6S+A==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/app-check-interop-types": "0.3.4", + "@firebase/auth-interop-types": "0.2.5", + "@firebase/component": "0.7.4", + "@firebase/logger": "0.5.1", + "@firebase/util": "1.15.2", + "faye-websocket": "0.11.4", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/database-compat": { + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/@firebase/database-compat/-/database-compat-2.1.6.tgz", + "integrity": "sha512-mu7S/75UIajB1A5M9Vfojk69LttW55uABp9nHEtWrV/mIaSEwvoaIe9GySsEzS2EKFK5/3f5okcAuUbihhYeJg==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.4", + "@firebase/database": "1.1.4", + "@firebase/database-types": "1.0.21", + "@firebase/logger": "0.5.1", + "@firebase/util": "1.15.2", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@firebase/app-compat": "0.x" + }, + "peerDependenciesMeta": { + "@firebase/app": { + "optional": true + }, + "@firebase/app-compat": { + "optional": true + } + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/database-types": { + "version": "1.0.21", + "resolved": "https://registry.npmjs.org/@firebase/database-types/-/database-types-1.0.21.tgz", + "integrity": "sha512-SX1jUqhttKgg/m9dYRTvqU9QvucBooziWfA986r4cpsbi4zlsvewe424j3Vpduwd6DG1MSAMfBVT2VqA61FnkA==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/app-types": "0.9.5", + "@firebase/util": "1.15.2" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/firestore": { + "version": "4.17.0", + "resolved": "https://registry.npmjs.org/@firebase/firestore/-/firestore-4.17.0.tgz", + "integrity": "sha512-P9tof6pyO1bnLlMWbux+5O7WFJqlb7OTPMKxxOiXKYiQl7mxykAvxr1BFCgWeEXUU7DZxQncyJ040B0IhFVZCg==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.4", + "@firebase/logger": "0.5.1", + "@firebase/util": "1.15.2", + "@firebase/webchannel-wrapper": "1.0.6", + "@grpc/grpc-js": "~1.9.0", + "@grpc/proto-loader": "^0.7.8", + "re2js": "^2.8.3", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@firebase/app": "0.x" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/firestore-compat": { + "version": "0.4.12", + "resolved": "https://registry.npmjs.org/@firebase/firestore-compat/-/firestore-compat-0.4.12.tgz", + "integrity": "sha512-k2uX81Ao/S0jnFcWGPOQpKK1cPlJHvD9WIqh/RE1XBDP2yg5zhE4rHhSg1rtB11k39q3nKon9XLNDDrPjGclag==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.4", + "@firebase/firestore": "4.17.0", + "@firebase/firestore-types": "3.0.4", + "@firebase/util": "1.15.2", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@firebase/app-compat": "0.x" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/firestore-types": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@firebase/firestore-types/-/firestore-types-3.0.4.tgz", + "integrity": "sha512-jGn+JSS4X9zZsrfu7Yw66v5YRdOLD1oyQh4USR0xWl4CUqV/DA6bNIXRPpxH/cUl3iVTNiP6MN7g+EL42A4qfA==", + "license": "Apache-2.0", + "peerDependencies": { + "@firebase/app-types": "0.x", + "@firebase/util": "1.x" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/functions": { + "version": "0.13.6", + "resolved": "https://registry.npmjs.org/@firebase/functions/-/functions-0.13.6.tgz", + "integrity": "sha512-9obLnzeQUivK5lmtGFOU2ucQ38BjTp+jpPtbfFp/mDsdVCvEpRqdWNvMMQ6aQwR4vcVc/utsvngm5BRkXbc7ZA==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/app-check-interop-types": "0.3.4", + "@firebase/auth-interop-types": "0.2.5", + "@firebase/component": "0.7.4", + "@firebase/messaging-interop-types": "0.2.5", + "@firebase/util": "1.15.2", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@firebase/app": "0.x" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/functions-compat": { + "version": "0.4.6", + "resolved": "https://registry.npmjs.org/@firebase/functions-compat/-/functions-compat-0.4.6.tgz", + "integrity": "sha512-dj9sOet+FIU91jeU4A3vGJoXHty7NqkSfjRLCwLgJXPDk1m72KFuxD3nlFgw/yXx/Fr7UjqzbxZ0LrIOdpx7+w==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.4", + "@firebase/functions": "0.13.6", + "@firebase/functions-types": "0.6.4", + "@firebase/util": "1.15.2", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@firebase/app-compat": "0.x" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/functions-types": { + "version": "0.6.4", + "resolved": "https://registry.npmjs.org/@firebase/functions-types/-/functions-types-0.6.4.tgz", + "integrity": "sha512-zV6kgqtduR4rUAdC/ilS7kmb93XD7bEZoJDlVBZqlOw2uGGGCNBQBuleww2rr0Ulr3L9o2TDjumEt68/l1f9DQ==", + "license": "Apache-2.0" + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/installations": { + "version": "0.6.23", + "resolved": "https://registry.npmjs.org/@firebase/installations/-/installations-0.6.23.tgz", + "integrity": "sha512-MBkbcQfd+3qHjW+slsH4s7jH5qTdGlYpwqmxEZ7QcIpgDxu1SKyU0f+mCZhCt1BCacLNiOWF5L0R06N0LtlfMg==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.4", + "@firebase/util": "1.15.2", + "idb": "7.1.1", + "tslib": "^2.1.0" + }, + "peerDependencies": { + "@firebase/app": "0.x" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/installations-compat": { + "version": "0.2.23", + "resolved": "https://registry.npmjs.org/@firebase/installations-compat/-/installations-compat-0.2.23.tgz", + "integrity": "sha512-isaXmjb9roM83eVeXAe+ZRNKYNsSo2s0aNM+cy04AAGEyVL/d8Aa11GwEXovRFeYjl9+1yRAOxRDTOukZRwTxA==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.4", + "@firebase/installations": "0.6.23", + "@firebase/installations-types": "0.5.4", + "@firebase/util": "1.15.2", + "tslib": "^2.1.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@firebase/app-compat": "0.x" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/installations-types": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/@firebase/installations-types/-/installations-types-0.5.4.tgz", + "integrity": "sha512-U2eFapdHwjb43Vx9o+Pmj4dFfvcHEK1IirEFLqMtWrTHvmdrS3gBpBD1kmJk/9HjsOtoHZxJ2Paoe79e+L1ZPg==", + "license": "Apache-2.0", + "peerDependencies": { + "@firebase/app-types": "0.x" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/logger": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.5.1.tgz", + "integrity": "sha512-vZKLsqE1ABOy8OjQiE7cUTFn4gvaqlk88yp8N94Pk/sDpq61YqZGqmVFZTvOyflTwuYFcWirBdYGoJgbDaXKYQ==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/messaging": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/@firebase/messaging/-/messaging-0.13.1.tgz", + "integrity": "sha512-kL8fdjbNBI7hprlXJrUjktDWosrpT4JtfwXtVVevImPF/rBRAsC+LS/jIs+kgQVuotnvMhaBCgAFipBoY9YU9g==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.4", + "@firebase/installations": "0.6.23", + "@firebase/messaging-interop-types": "0.2.5", + "@firebase/util": "1.15.2", + "idb": "7.1.1", + "tslib": "^2.1.0" + }, + "peerDependencies": { + "@firebase/app": "0.x" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/messaging-compat": { + "version": "0.2.28", + "resolved": "https://registry.npmjs.org/@firebase/messaging-compat/-/messaging-compat-0.2.28.tgz", + "integrity": "sha512-/AmMqHRnSQhPsdeED3ocs+s30/tpFvZDiiwIYY2uXFRvLujo1fnbPOeCFoe4Y+dRy1LCSjpvJf+dy5ZTsxi1yg==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.4", + "@firebase/messaging": "0.13.1", + "@firebase/util": "1.15.2", + "tslib": "^2.1.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@firebase/app-compat": "0.x" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/messaging-interop-types": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/@firebase/messaging-interop-types/-/messaging-interop-types-0.2.5.tgz", + "integrity": "sha512-tUEKnaAP2Y/MNIqgnriPpV6e5l13Vs/+p2yrd6NGlncPJT9O3a8muYZtdnWe+IJ4fgKLHJVC79n/asxk/N5Msw==", + "license": "Apache-2.0" + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/performance": { + "version": "0.7.13", + "resolved": "https://registry.npmjs.org/@firebase/performance/-/performance-0.7.13.tgz", + "integrity": "sha512-1u6fuXP9cj0s+lkTFAspr/ttfPebPbEdpx+5Wdr4mPZbp8qH2KCMxOddEAR1ZMRa5GI0E7hDYSnolEmbqOFOAg==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.4", + "@firebase/installations": "0.6.23", + "@firebase/logger": "0.5.1", + "@firebase/util": "1.15.2", + "tslib": "^2.1.0", + "web-vitals": "^4.2.4" + }, + "peerDependencies": { + "@firebase/app": "0.x" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/performance-compat": { + "version": "0.2.26", + "resolved": "https://registry.npmjs.org/@firebase/performance-compat/-/performance-compat-0.2.26.tgz", + "integrity": "sha512-jgoocXLN6ao26xWQ8pzosmzQ33uLzGBJQPNK0NTbVy1XvIHr5pfgBf9hWLOxsWe+R7sJq5bjD+8ybXprmt61mA==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.4", + "@firebase/logger": "0.5.1", + "@firebase/performance": "0.7.13", + "@firebase/performance-types": "0.2.4", + "@firebase/util": "1.15.2", + "tslib": "^2.1.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@firebase/app-compat": "0.x" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/performance-types": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/@firebase/performance-types/-/performance-types-0.2.4.tgz", + "integrity": "sha512-kJSEk7b0uhpcPRyL4SQ/GPujLqk52XNKcXlnsKDbWGAb9vugcLvOU3u6zfEdwd+d8hWJb5S5ZizV1JFFI0nkKg==", + "license": "Apache-2.0" + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/remote-config": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/@firebase/remote-config/-/remote-config-0.9.1.tgz", + "integrity": "sha512-nzQUSJnk1zAZEl2Q5O3I7Z61cYLK5JI4H6wyyOiHkVZ+bmgy1YXNNMptNbVjixMQ/eCzgA6nZRaC+1eBcJGUFA==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.4", + "@firebase/installations": "0.6.23", + "@firebase/logger": "0.5.1", + "@firebase/util": "1.15.2", + "tslib": "^2.1.0" + }, + "peerDependencies": { + "@firebase/app": "0.x" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/remote-config-compat": { + "version": "0.2.28", + "resolved": "https://registry.npmjs.org/@firebase/remote-config-compat/-/remote-config-compat-0.2.28.tgz", + "integrity": "sha512-kEO9Gn6fbmVj7eNUtZ6d59mLgUDUD0qo7aCicGOWNfuRWTaUv3CF9DMYychO61zaEQ3cfA+CEny4V1E8A1gRGA==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.4", + "@firebase/logger": "0.5.1", + "@firebase/remote-config": "0.9.1", + "@firebase/remote-config-types": "0.5.1", + "@firebase/util": "1.15.2", + "tslib": "^2.1.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@firebase/app-compat": "0.x" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/remote-config-types": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/@firebase/remote-config-types/-/remote-config-types-0.5.1.tgz", + "integrity": "sha512-cX/1LT6KQwkXzck2eSzeKnuvXZCyr8qaPpDcikoJs7jmI+oBOXixpDLeDtWj1U6GNMkIoXrEDNoyT2Ypcyp5/A==", + "license": "Apache-2.0" + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/storage": { + "version": "0.14.4", + "resolved": "https://registry.npmjs.org/@firebase/storage/-/storage-0.14.4.tgz", + "integrity": "sha512-jfzEWZb3Fpsq3FwAB2ifoc8mcSh935qXdDou3TpyjDWa45hhNcZUv8/w28/10njByhfK7snbakKN30nwnzQ3/w==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.4", + "@firebase/util": "1.15.2", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@firebase/app": "0.x" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/storage-compat": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/@firebase/storage-compat/-/storage-compat-0.4.4.tgz", + "integrity": "sha512-qSRgCB9f2R/nCp8t/8OC101cIFBFeUazlRInOMdzbnLzvrQBzEfx19SrR4pvdj/0+M+P/y8AK/a2s+3EB+B1Pw==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/component": "0.7.4", + "@firebase/storage": "0.14.4", + "@firebase/storage-types": "0.8.4", + "@firebase/util": "1.15.2", + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "@firebase/app": "0.x", + "@firebase/app-compat": "0.x" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/storage-types": { + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/@firebase/storage-types/-/storage-types-0.8.4.tgz", + "integrity": "sha512-BT7cwxJOx8SWwlQfrlC+bD/Sk3Cw+1odCi8UZNFNWTVZoPsBnA5W+mqtZzVnvsdJpXCFGSGQ7R7vOR6dtM/BRA==", + "license": "Apache-2.0", + "peerDependencies": { + "@firebase/app-types": "0.x", + "@firebase/util": "1.x" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/util": { + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.15.2.tgz", + "integrity": "sha512-974pWIZVLDMc5GW5YAsj8y0XxULxIy/sPUy7tsxmWbF93KRIyh9xpuHlh0zDL+shUcf5nHDjFOg9YLiQ763eiA==", + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@react-native-firebase/app/node_modules/@firebase/webchannel-wrapper": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@firebase/webchannel-wrapper/-/webchannel-wrapper-1.0.6.tgz", + "integrity": "sha512-Vr/Mqu79dMwGRAyGbJ4uN4+BtXB3/mRTdzetD1daWNeG8QaWuzhhbG77GltO5c0yYmYls8i250iX73624GJd7Q==", + "license": "Apache-2.0" + }, + "node_modules/@react-native-firebase/app/node_modules/firebase": { + "version": "12.17.1", + "resolved": "https://registry.npmjs.org/firebase/-/firebase-12.17.1.tgz", + "integrity": "sha512-dhp41ye9jMQvhx5FwjMkf/hjDHJApl7gXmvzOZGvP0M7c/GZGUnQ4qvsvlOBkF0Pa7wAwHMdcpL0ON2pXCQ4Sw==", + "license": "Apache-2.0", + "dependencies": { + "@firebase/ai": "2.14.0", + "@firebase/analytics": "0.10.23", + "@firebase/analytics-compat": "0.2.29", + "@firebase/app": "0.16.0", + "@firebase/app-check": "0.13.0", + "@firebase/app-check-compat": "0.4.6", + "@firebase/app-compat": "0.5.16", + "@firebase/app-types": "0.9.5", + "@firebase/auth": "1.13.4", + "@firebase/auth-compat": "0.6.9", + "@firebase/data-connect": "0.7.3", + "@firebase/database": "1.1.4", + "@firebase/database-compat": "2.1.6", + "@firebase/firestore": "4.17.0", + "@firebase/firestore-compat": "0.4.12", + "@firebase/functions": "0.13.6", + "@firebase/functions-compat": "0.4.6", + "@firebase/installations": "0.6.23", + "@firebase/installations-compat": "0.2.23", + "@firebase/messaging": "0.13.1", + "@firebase/messaging-compat": "0.2.28", + "@firebase/performance": "0.7.13", + "@firebase/performance-compat": "0.2.26", + "@firebase/remote-config": "0.9.1", + "@firebase/remote-config-compat": "0.2.28", + "@firebase/storage": "0.14.4", + "@firebase/storage-compat": "0.4.4", + "@firebase/util": "1.15.2" + } + }, + "node_modules/@react-native-firebase/app/node_modules/idb": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/idb/-/idb-7.1.1.tgz", + "integrity": "sha512-gchesWBzyvGHRO9W8tzUWFDycow5gwjvFKfyV9FF32Y7F50yZMp7mP+T2mJIWFx49zicqyC4uefHM17o6xKIVQ==", + "license": "ISC" + }, + "node_modules/@react-native-firebase/remote-config": { + "version": "26.4.0", + "resolved": "https://registry.npmjs.org/@react-native-firebase/remote-config/-/remote-config-26.4.0.tgz", + "integrity": "sha512-nKQ00zYVA/50BULJqNy3XKEOmNeWl26ho3XVb5in0HdJ/nwMzhAMy0ujMeLCpZRn8F31DGEe8ptJPa1nwcfG7w==", + "license": "Apache-2.0", + "dependencies": { + "react-native-fetch-api": "^3.0.0", + "text-encoding": "^0.7.0", + "web-streams-polyfill": "^4.2.0" + }, + "peerDependencies": { + "@react-native-firebase/analytics": "26.4.0", + "@react-native-firebase/app": "26.4.0" + } + }, "node_modules/@react-native-google-signin/google-signin": { "version": "16.1.2", "resolved": "https://registry.npmjs.org/@react-native-google-signin/google-signin/-/google-signin-16.1.2.tgz", @@ -10974,6 +11705,15 @@ "node": ">=4" } }, + "node_modules/p-defer": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-3.0.0.tgz", + "integrity": "sha512-ugZxsxmtTln604yeYd29EGrNhazN2lywetzpKhfmQjW/VJmhpDmWbiX+h0zL8V91R0UXkhb3KtPmyq9PZw3aYw==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", @@ -11808,6 +12548,15 @@ "react-native-reanimated": ">= 2.0.0" } }, + "node_modules/react-native-fetch-api": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/react-native-fetch-api/-/react-native-fetch-api-3.0.0.tgz", + "integrity": "sha512-g2rtqPjdroaboDKTsJCTlcmtw54E25OjyaunUP0anOZn4Fuo2IKs8BVfe02zVggA/UysbmfSnRJIqtNkAgggNA==", + "license": "MIT", + "dependencies": { + "p-defer": "^3.0.0" + } + }, "node_modules/react-native-gesture-handler": { "version": "2.31.1", "resolved": "https://registry.npmjs.org/react-native-gesture-handler/-/react-native-gesture-handler-2.31.1.tgz", @@ -13244,6 +13993,16 @@ "kdbush": "^4.0.2" } }, + "node_modules/superstruct": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-2.0.2.tgz", + "integrity": "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -13855,6 +14614,20 @@ "defaults": "^1.0.3" } }, + "node_modules/web-streams-polyfill": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-4.3.0.tgz", + "integrity": "sha512-/Gnggvj9oSrEvJbDyyPtAnxBt5fGQM2iWOKQNu7ie1OxDgK40iZpyV3TKaRiEzVj1oA1UxKnEy9XPXh6PW3eVw==", + "license": "MIT", + "workspaces": [ + "test/benchmark-test", + "test/rollup-test", + "test/webpack-test" + ], + "engines": { + "node": ">= 8" + } + }, "node_modules/web-vitals": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/web-vitals/-/web-vitals-4.2.4.tgz", diff --git a/package.json b/package.json index 509aaf1..5c6f8d1 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,8 @@ "@react-native-async-storage/async-storage": "3.0.2", "@react-native-async-storage/expo-with-async-storage": "^1.0.0", "@react-native-community/datetimepicker": "8.6.0", + "@react-native-firebase/app": "^26.4.0", + "@react-native-firebase/remote-config": "^26.4.0", "@react-native-google-signin/google-signin": "16.1.2", "@react-navigation/drawer": "^7.9.8", "@reduxjs/toolkit": "^2.11.2", diff --git a/src/app/_layout.tsx b/src/app/_layout.tsx index f78a364..0d0cd29 100644 --- a/src/app/_layout.tsx +++ b/src/app/_layout.tsx @@ -1,4 +1,4 @@ -import { ReactNode, useEffect } from "react"; +import { ReactNode, useEffect, useState } from "react"; import {router, Slot, useSegments} from "expo-router"; import { ActivityIndicator, StatusBar, View } from "react-native"; import { SafeAreaProvider, SafeAreaView } from "react-native-safe-area-context"; @@ -8,10 +8,13 @@ import { listenToAuthChanges } from "@/redux/actions/authActions"; import { useAppDispatch, useAppSelector } from "@/redux/store/hooks"; import store from "@/redux/store/store"; import { COLORS } from "@/styles/theme"; +import { initializeRemoteConfig } from "@/remoteConfigClient"; import MaterialIcons from "@expo/vector-icons/MaterialIcons"; import FontAwesome5 from "@expo/vector-icons/FontAwesome5"; import {useFonts} from "expo-font"; +const FLAG_FETCH_TIMEOUT_MS = 3000; + function AuthGate(): ReactNode { const { sessionChecked, user } = useAppSelector((state) => state.auth); const dispatch = useAppDispatch(); @@ -34,12 +37,24 @@ function AuthGate(): ReactNode { } }, [user, sessionChecked, segments]); + const [flagsResolved, setFlagsResolved] = useState(false); + + useEffect(() => { + // Feature flags are read during render, so they have to be resolved + // before the first paint. This runs alongside the session check that + // already gates rendering, and is bounded so a slow or offline network + // falls back to the stored values instead of hanging startup. + const deadline = new Promise((resolve) => setTimeout(resolve, FLAG_FETCH_TIMEOUT_MS)); + + void Promise.race([initializeRemoteConfig(), deadline]).then(() => setFlagsResolved(true)); + }, []); + const [fontLoaded, fontError] = useFonts({ ...MaterialIcons.font, ...FontAwesome5.font, }); - if (!sessionChecked || !fontLoaded) { + if (!sessionChecked || !fontLoaded || !flagsResolved) { return ( diff --git a/src/featureFlags.ts b/src/featureFlags.ts new file mode 100644 index 0000000..5c2431b --- /dev/null +++ b/src/featureFlags.ts @@ -0,0 +1,71 @@ +import { Platform } from "react-native"; + +// Values used until Remote Config answers, and whenever it cannot be reached. +export const FEATURE_FLAG_DEFAULTS = { + newThemeTest: false, + enableSoberTest: false, +}; + +export type FeatureFlagKey = keyof typeof FEATURE_FLAG_DEFAULTS; + +const STORAGE_KEY = "pubtrail.featureFlags"; + +// Web-only fallback for when the Remote Config fetch fails or times out at +// startup: the last known values are kept here so the app opens on real flags +// rather than defaults. Native needs no equivalent - the native SDK persists +// its own activated config, which `getValue` returns even after a failed +// fetch. On both platforms the fetched values are what normally win. +const readCachedFlags = (): Partial> => { + if (Platform.OS !== "web" || typeof localStorage === "undefined") { + return {}; + } + + try { + const cached = JSON.parse(localStorage.getItem(STORAGE_KEY) ?? "{}") as Record; + const values: Partial> = {}; + + (Object.keys(FEATURE_FLAG_DEFAULTS) as FeatureFlagKey[]).forEach((key) => { + const value = cached[key]; + if (typeof value === "boolean") { + values[key] = value; + } + }); + + return values; + } catch { + return {}; + } +}; + +const flags: Record = { ...FEATURE_FLAG_DEFAULTS, ...readCachedFlags() }; + +export const getFeatureFlag = (key: FeatureFlagKey): boolean => flags[key]; + +// Reads every declared flag through the caller's SDK, so the web and native +// Remote Config clients share one definition of "what a flag snapshot is". +export const collectFlagValues = ( + read: (key: FeatureFlagKey) => boolean, +): Record => { + const values = {} as Record; + + (Object.keys(FEATURE_FLAG_DEFAULTS) as FeatureFlagKey[]).forEach((key) => { + values[key] = read(key); + }); + + return values; +}; + +export const cacheFeatureFlags = (values: Record): void => { + // Applies on every platform; only the persistence below is web-specific. + Object.assign(flags, values); + + if (Platform.OS !== "web" || typeof localStorage === "undefined") { + return; + } + + try { + localStorage.setItem(STORAGE_KEY, JSON.stringify(values)); + } catch { + // Storage unavailable (e.g. private mode): flags fall back to defaults. + } +}; diff --git a/src/firebaseConfig.ts b/src/firebaseConfig.ts index 802c478..e6eb72a 100644 --- a/src/firebaseConfig.ts +++ b/src/firebaseConfig.ts @@ -1,10 +1,4 @@ import { FirebaseApp, getApp, getApps, initializeApp } from "firebase/app"; -import { - fetchAndActivate, - getRemoteConfig, - getValue, -} from "firebase/remote-config"; - import { initializeAuth, //@ts-ignore @@ -57,50 +51,11 @@ const getInternalAuth = (): Auth => { }; const auth = getInternalAuth(); -const remoteConfig = getRemoteConfig(firebaseApp); - -const DEFAULT_REMOTE_CONFIG_VALUES: Record = { - useAltTheme: false, -}; - -const remoteConfigValues: Record = { ...DEFAULT_REMOTE_CONFIG_VALUES }; - - -export const initializeRemoteConfig = async (): Promise> => { - if (!remoteConfig) { - return remoteConfigValues; - } - - remoteConfig.settings.minimumFetchIntervalMillis = 0; // 10 seconds for testing purposes, adjust as needed - - try { - await fetchAndActivate(remoteConfig); - } catch { - return remoteConfigValues; - } - - Object.keys(DEFAULT_REMOTE_CONFIG_VALUES).forEach((key) => { - remoteConfigValues[key] = getValue(remoteConfig, key).asBoolean(); - }); - - return remoteConfigValues; -}; -export const getRemoteConfigValue = (key: string): boolean => { - if (!remoteConfig) { - return DEFAULT_REMOTE_CONFIG_VALUES[key] ?? false; - } - - const value = getValue(remoteConfig, key).asBoolean(); - console.log(`Remote config value for key "${key}": ${value}`); - return value ?? DEFAULT_REMOTE_CONFIG_VALUES[key] ?? false; -}; - -if (Platform.OS === "web" && typeof indexedDB !== "undefined") { - void initializeRemoteConfig(); -} +// Remote Config lives in `remoteConfigClient.ts` / `.web.ts` so the feature flag +// plumbing stays out of the auth setup and can differ per platform. -export { firebaseApp, auth, remoteConfig, remoteConfigValues }; +export { firebaseApp, auth }; export const isFirebaseConfigured = Boolean( firebaseConfig.apiKey && firebaseConfig.projectId && firebaseConfig.appId diff --git a/src/remoteConfigClient.ts b/src/remoteConfigClient.ts new file mode 100644 index 0000000..b88b164 --- /dev/null +++ b/src/remoteConfigClient.ts @@ -0,0 +1,52 @@ +import { + fetchAndActivate, + getRemoteConfig, + getValue, +} from "@react-native-firebase/remote-config"; +import { cacheFeatureFlags, collectFlagValues, FEATURE_FLAG_DEFAULTS } from "@/featureFlags"; + +/** + * Native half of the Remote Config client, backed by React Native Firebase. + * Metro picks `remoteConfigClient.web.ts` for web builds instead. Both expose + * the same `initializeRemoteConfig` contract and write into the same store. + * + * Unlike the web SDK, the native SDK persists its activated config itself, so a + * cold start has the last known values available without waiting for a fetch. + */ + +type RemoteConfigInstance = ReturnType; + +let remoteConfig: RemoteConfigInstance | null = null; + +const getInstance = (): RemoteConfigInstance => { + if (!remoteConfig) { + remoteConfig = getRemoteConfig(); + // Both are setters that forward to the native SDK, so each has to be + // assigned whole - mutating a nested property would not propagate. + remoteConfig.defaultConfig = FEATURE_FLAG_DEFAULTS; + // Matches the web client: skip the fetch throttle so a published flag + // shows up immediately during a demo. + remoteConfig.settings = { minimumFetchIntervalMillis: 0, fetchTimeoutMillis: 60_000 }; + } + + return remoteConfig; +}; + +const publishValues = (config: RemoteConfigInstance): void => { + cacheFeatureFlags(collectFlagValues((key) => getValue(config, key).asBoolean())); +}; + +export const initializeRemoteConfig = async (): Promise => { + const config = getInstance(); + + try { + await fetchAndActivate(config); + } catch (error) { + console.warn("Remote Config fetch failed, falling back to the stored config.", error); + } + + // Publish either way: the native SDK keeps the last activated config on + // disk, so a failed fetch still leaves real values to read rather than + // dropping back to the defaults. + publishValues(config); +}; diff --git a/src/remoteConfigClient.web.ts b/src/remoteConfigClient.web.ts new file mode 100644 index 0000000..a7a9e23 --- /dev/null +++ b/src/remoteConfigClient.web.ts @@ -0,0 +1,53 @@ +import { + fetchAndActivate, + getRemoteConfig, + getValue, +} from "firebase/remote-config"; +import { firebaseApp } from "@/firebaseConfig"; +import { cacheFeatureFlags, collectFlagValues, FEATURE_FLAG_DEFAULTS } from "@/featureFlags"; + +/** + * Web half of the Remote Config client. The native half lives in + * `remoteConfigClient.ts`; Metro picks this file for web builds. Both expose + * the same `initializeRemoteConfig` contract and write into the same store. + */ + +type RemoteConfigInstance = ReturnType; + +let remoteConfig: RemoteConfigInstance | null = null; + +const getInstance = (): RemoteConfigInstance | null => { + // The web SDK needs IndexedDB, which is missing during the static render. + if (typeof indexedDB === "undefined") { + return null; + } + + if (!remoteConfig) { + remoteConfig = getRemoteConfig(firebaseApp); + remoteConfig.defaultConfig = FEATURE_FLAG_DEFAULTS; + // Remote Config serves its cached response until this interval elapses, + // and the 12h default is far too slow to flip a flag during a demo. + remoteConfig.settings.minimumFetchIntervalMillis = 0; + } + + return remoteConfig; +}; + +const publishValues = (config: RemoteConfigInstance): void => { + cacheFeatureFlags(collectFlagValues((key) => getValue(config, key).asBoolean())); +}; + +export const initializeRemoteConfig = async (): Promise => { + const config = getInstance(); + + if (!config) { + return; + } + + try { + await fetchAndActivate(config); + publishValues(config); + } catch (error) { + console.warn("Remote Config fetch failed, keeping the cached feature flags.", error); + } +}; diff --git a/src/styles/theme.ts b/src/styles/theme.ts index f6ce691..01ef851 100644 --- a/src/styles/theme.ts +++ b/src/styles/theme.ts @@ -1,9 +1,14 @@ -import {getRemoteConfigValue} from "@/firebaseConfig"; +import { getFeatureFlag } from "@/featureFlags"; import * as defaultTheme from "./theme.default"; import * as altTheme from "./theme.alt"; -const featureFlagValue = getRemoteConfigValue("newThemeTest") ?? false; -const activeTheme = featureFlagValue ? altTheme : defaultTheme; +const activeTheme = getFeatureFlag("newThemeTest") ? altTheme : defaultTheme; + +if (__DEV__) { + // TEMPORARY: diagnosing the flag rollout, remove once verified. + console.log(`[theme] newThemeTest=${getFeatureFlag("newThemeTest")} -> ${activeTheme === altTheme ? "alt" : "default"}`); +} +// const activeTheme = defaultTheme; export const COLORS = activeTheme.COLORS; export const SPACING = activeTheme.SPACING; diff --git a/src/views/navigation/AppDrawerContent.tsx b/src/views/navigation/AppDrawerContent.tsx index ad92613..2eede69 100644 --- a/src/views/navigation/AppDrawerContent.tsx +++ b/src/views/navigation/AppDrawerContent.tsx @@ -6,12 +6,15 @@ import {Pressable, StyleSheet, Text, View} from "react-native"; import {useSafeAreaInsets} from "react-native-safe-area-context"; import {COLORS, RADIUS, SPACING, TYPOGRAPHY} from "@/styles/theme"; import {router} from "expo-router"; +import {getFeatureFlag, type FeatureFlagKey} from "@/featureFlags"; type DrawerEntry = { routeName: string; label: string; description: string; icon: React.ComponentProps["name"]; + // Entry is only listed while this flag is on. Omit to always list it. + featureFlag?: FeatureFlagKey; }; // ShowDuringCrawl: true - only while crawl is active, false - only when crawl inactive, undefined - always show const DRAWER_GROUPS: Array<{ title: string; showDuringCrawl?: boolean; items: DrawerEntry[] }> = [ @@ -82,6 +85,7 @@ const DRAWER_GROUPS: Array<{ title: string; showDuringCrawl?: boolean; items: Dr label: "Sober Check", description: "Quick self-check before heading out", icon: "local-bar", + featureFlag: "enableSoberTest", }, ], @@ -113,6 +117,24 @@ export function AppDrawerContent({ return routeName === "index" ? "/" : routeName; }, [drawerProps.state.routeNames, drawerProps.state.index]); + // Resolved before the first render by the flag gate in the root layout. + const soberTestEnabled = getFeatureFlag("enableSoberTest"); + + const visibleGroups = useMemo(() => { + // Add an entry here when a new flag gates a drawer item. + const flagValues: Partial> = { + enableSoberTest: soberTestEnabled, + }; + + return DRAWER_GROUPS + .filter((group) => group.showDuringCrawl === undefined || group.showDuringCrawl === isActiveCrawl) + .map((group) => ({ + ...group, + items: group.items.filter((item) => !item.featureFlag || flagValues[item.featureFlag] === true), + })) + .filter((group) => group.items.length > 0); + }, [isActiveCrawl, soberTestEnabled]); + function onNavigate(routeName: string) { router.navigate(routeName); drawerProps.navigation.closeDrawer(); @@ -142,7 +164,7 @@ export function AppDrawerContent({ - {DRAWER_GROUPS.filter(item => item.showDuringCrawl === undefined || item.showDuringCrawl === isActiveCrawl).map((group) => ( + {visibleGroups.map((group) => ( {group.title} From 9192e3ba8c11256db5465daee4db50ec7445be91 Mon Sep 17 00:00:00 2001 From: Pavlos Spanoudakis Date: Wed, 9 Sep 2026 18:12:57 +0200 Subject: [PATCH 5/5] Replace module-scope theme with a ThemeProvider Theme tokens were captured by module-scope StyleSheet.create calls at import time, so the newThemeTest flag could never apply on native and was always a launch behind on web. Views now read the palette from context. createThemedStyles turns a stylesheet factory into a hook and caches the result per theme, and commonStyles becomes useCommonStyles. Removing theme.ts forced every consumer to move, so nothing is left reading tokens at import time. The root layout resolves the feature flags before mounting the provider, so the first themed render already has the right palette on both platforms. --- src/app/(app)/_layout.tsx | 3 +- src/app/_layout.tsx | 49 +++++++++++++------ src/styles/ThemeProvider.tsx | 20 ++++++++ src/styles/createThemedStyles.ts | 26 ++++++++++ src/styles/theme.ts | 16 ------ src/styles/themeProvider.test.tsx | 44 +++++++++++++++++ src/styles/themes.ts | 29 +++++++++++ .../{commonStyles.ts => useCommonStyles.ts} | 6 +-- src/views/ExternalJoinView.tsx | 7 +-- src/views/captureMediaView.tsx | 12 +++-- src/views/components/ActionButton.tsx | 9 ++-- src/views/components/BackButton.tsx | 3 +- src/views/components/ConfirmModal.tsx | 9 ++-- src/views/components/CrawlStopRow.tsx | 6 ++- .../components/CrawlVisibilitySection.tsx | 10 ++-- src/views/components/Divider.tsx | 7 +-- src/views/components/FallbackUserAvatar.tsx | 9 ++-- src/views/components/FullScreenMap.native.tsx | 9 ++-- src/views/components/GestureBottomSheet.tsx | 7 +-- src/views/components/HomeTile.tsx | 7 +-- src/views/components/MapRefocusButton.tsx | 9 ++-- src/views/components/MapStopMarkerShape.tsx | 7 +-- src/views/components/MediaPreviewStrip.tsx | 7 +-- .../components/ParticipantsAvatarStrip.tsx | 7 +-- src/views/components/RefreshIndicator.tsx | 3 +- src/views/components/ScreenLoader.tsx | 12 +++-- src/views/components/TitleInput.tsx | 6 ++- .../components/ViewOnlyMapPanel.native.tsx | 9 ++-- src/views/components/ViewOnlyMapPanel.web.tsx | 9 ++-- src/views/crawlDetailsView.tsx | 12 +++-- src/views/crawlHistoryView.tsx | 6 ++- src/views/editCrawlView.tsx | 6 ++- src/views/editStopView.tsx | 12 +++-- src/views/joinCrawlView.tsx | 12 +++-- src/views/loginView.tsx | 9 ++-- src/views/mediaAlbumView.tsx | 9 ++-- src/views/navigation/AppDrawerContent.tsx | 9 ++-- src/views/navigation/AppLayoutView.tsx | 3 +- .../navigation/IndexQuickActionsOverlay.tsx | 9 ++-- src/views/nearbyCrawlsView.tsx | 9 ++-- src/views/newStopView.tsx | 6 ++- src/views/shareCrawlView.tsx | 12 +++-- src/views/soberCheckView.tsx | 10 ++-- src/views/viewCrawlStopView.tsx | 12 +++-- 44 files changed, 352 insertions(+), 141 deletions(-) create mode 100644 src/styles/ThemeProvider.tsx create mode 100644 src/styles/createThemedStyles.ts delete mode 100644 src/styles/theme.ts create mode 100644 src/styles/themeProvider.test.tsx create mode 100644 src/styles/themes.ts rename src/styles/{commonStyles.ts => useCommonStyles.ts} (95%) diff --git a/src/app/(app)/_layout.tsx b/src/app/(app)/_layout.tsx index 0fab88f..e70c9d2 100644 --- a/src/app/(app)/_layout.tsx +++ b/src/app/(app)/_layout.tsx @@ -1,10 +1,11 @@ import { Stack } from "expo-router"; import { ReactElement } from "react"; -import { COLORS, TYPOGRAPHY } from "@/styles/theme"; import BackButton from "@/views/components/BackButton"; +import { useTheme } from "@/styles/ThemeProvider"; export default function AppGroupLayout(): ReactElement { + const { COLORS, TYPOGRAPHY } = useTheme(); return ( state.auth); const dispatch = useAppDispatch(); const segments = useSegments(); @@ -37,24 +39,12 @@ function AuthGate(): ReactNode { } }, [user, sessionChecked, segments]); - const [flagsResolved, setFlagsResolved] = useState(false); - - useEffect(() => { - // Feature flags are read during render, so they have to be resolved - // before the first paint. This runs alongside the session check that - // already gates rendering, and is bounded so a slow or offline network - // falls back to the stored values instead of hanging startup. - const deadline = new Promise((resolve) => setTimeout(resolve, FLAG_FETCH_TIMEOUT_MS)); - - void Promise.race([initializeRemoteConfig(), deadline]).then(() => setFlagsResolved(true)); - }, []); - const [fontLoaded, fontError] = useFonts({ ...MaterialIcons.font, ...FontAwesome5.font, }); - if (!sessionChecked || !fontLoaded || !flagsResolved) { + if (!sessionChecked || !fontLoaded) { return ( @@ -65,7 +55,9 @@ function AuthGate(): ReactNode { return ; } -export default function RootLayout(): ReactNode { +function AppChrome(): ReactNode { + const { COLORS } = useTheme(); + return ( @@ -79,3 +71,30 @@ export default function RootLayout(): ReactNode { ); } + +export default function RootLayout(): ReactNode { + const [flagsResolved, setFlagsResolved] = useState(false); + + useEffect(() => { + // The active theme comes from a feature flag, so the flags have to be + // resolved before anything themed renders. Bounded so a slow or offline + // network falls back to the stored values instead of hanging startup. + const deadline = new Promise((resolve) => setTimeout(resolve, FLAG_FETCH_TIMEOUT_MS)); + + void Promise.race([initializeRemoteConfig(), deadline]).then(() => setFlagsResolved(true)); + }, []); + + if (!flagsResolved) { + return ( + + + + ); + } + + return ( + + + + ); +} diff --git a/src/styles/ThemeProvider.tsx b/src/styles/ThemeProvider.tsx new file mode 100644 index 0000000..8e67268 --- /dev/null +++ b/src/styles/ThemeProvider.tsx @@ -0,0 +1,20 @@ +import { createContext, useContext, type ReactElement, type ReactNode } from "react"; +import { getFeatureFlag } from "@/featureFlags"; +import { altTheme, defaultTheme, type Theme } from "./themes"; + +/** + * The active theme is chosen once, from a feature flag that the root layout has + * already resolved before rendering this provider. It stays fixed for the app + * session, so a flag change applies on the next start. + */ +const ThemeContext = createContext(defaultTheme); + +export function ThemeProvider({ children }: { children: ReactNode }): ReactElement { + const theme = getFeatureFlag("newThemeTest") ? altTheme : defaultTheme; + + return {children}; +} + +export function useTheme(): Theme { + return useContext(ThemeContext); +} diff --git a/src/styles/createThemedStyles.ts b/src/styles/createThemedStyles.ts new file mode 100644 index 0000000..900984d --- /dev/null +++ b/src/styles/createThemedStyles.ts @@ -0,0 +1,26 @@ +import { useTheme } from "./ThemeProvider"; +import type { Theme } from "./themes"; + +/** + * Turns a stylesheet factory into a hook. Replaces module-scope + * `StyleSheet.create` calls, which capture theme tokens at import time and so + * cannot follow the active theme. + * + * Results are cached per theme object, so a stylesheet is built once per theme + * rather than on every render. + */ +export function createThemedStyles(factory: (theme: Theme) => T): () => T { + const cache = new WeakMap(); + + return function useThemedStyles(): T { + const theme = useTheme(); + let styles = cache.get(theme); + + if (!styles) { + styles = factory(theme); + cache.set(theme, styles); + } + + return styles; + }; +} diff --git a/src/styles/theme.ts b/src/styles/theme.ts deleted file mode 100644 index 01ef851..0000000 --- a/src/styles/theme.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { getFeatureFlag } from "@/featureFlags"; -import * as defaultTheme from "./theme.default"; -import * as altTheme from "./theme.alt"; - -const activeTheme = getFeatureFlag("newThemeTest") ? altTheme : defaultTheme; - -if (__DEV__) { - // TEMPORARY: diagnosing the flag rollout, remove once verified. - console.log(`[theme] newThemeTest=${getFeatureFlag("newThemeTest")} -> ${activeTheme === altTheme ? "alt" : "default"}`); -} -// const activeTheme = defaultTheme; - -export const COLORS = activeTheme.COLORS; -export const SPACING = activeTheme.SPACING; -export const TYPOGRAPHY = activeTheme.TYPOGRAPHY; -export const RADIUS = activeTheme.RADIUS; diff --git a/src/styles/themeProvider.test.tsx b/src/styles/themeProvider.test.tsx new file mode 100644 index 0000000..7b2e955 --- /dev/null +++ b/src/styles/themeProvider.test.tsx @@ -0,0 +1,44 @@ +import { act, create, type ReactTestRenderer } from "react-test-renderer"; +import { StyleSheet, Text } from "react-native"; + +jest.mock("@/featureFlags", () => ({ getFeatureFlag: jest.fn() })); + +import { getFeatureFlag } from "@/featureFlags"; +import { ThemeProvider } from "@/styles/ThemeProvider"; +import { createThemedStyles } from "@/styles/createThemedStyles"; +import { HomeTile } from "@/views/components/HomeTile"; + +const useStyles = createThemedStyles(({ COLORS }) => StyleSheet.create({ probe: { color: COLORS.primary } })); + +function Probe() { + const styles = useStyles(); + return x; +} + +const render = (ui: React.ReactElement): ReactTestRenderer => { + let tree!: ReactTestRenderer; + act(() => { tree = create({ui}); }); + return tree; +}; + +describe("theme provider", () => { + it("uses the default palette when the flag is off", () => { + (getFeatureFlag as jest.Mock).mockReturnValue(false); + const style = StyleSheet.flatten(render().root.findByType(Text).props.style); + expect(style.color).toBe("#8b5e3c"); + }); + + it("uses the alt palette when the flag is on", () => { + (getFeatureFlag as jest.Mock).mockReturnValue(true); + const style = StyleSheet.flatten(render().root.findByType(Text).props.style); + expect(style.color).toBe("#4f46e5"); + }); + + it("themes a real converted view", () => { + (getFeatureFlag as jest.Mock).mockReturnValue(true); + const tree = render( {}} />); + const style = StyleSheet.flatten((tree.toJSON() as any).props.style); + expect(style.backgroundColor).toBe("#ffffff"); + expect(style.borderColor).toBe("#bfdbfe"); + }); +}); diff --git a/src/styles/themes.ts b/src/styles/themes.ts new file mode 100644 index 0000000..2e5b635 --- /dev/null +++ b/src/styles/themes.ts @@ -0,0 +1,29 @@ +import * as altTokens from "./theme.alt"; +import * as defaultTokens from "./theme.default"; + +/** + * Colours are widened to `string` because the two palettes hold different + * literals. Spacing, typography and radius are identical across themes, so they + * keep their literal types - `TYPOGRAPHY.weights` in particular has to stay + * literal for React Native to accept it as a `fontWeight`. + */ +export type Theme = { + COLORS: Record; + SPACING: typeof defaultTokens.SPACING; + TYPOGRAPHY: typeof defaultTokens.TYPOGRAPHY; + RADIUS: typeof defaultTokens.RADIUS; +}; + +export const defaultTheme: Theme = { + COLORS: defaultTokens.COLORS, + SPACING: defaultTokens.SPACING, + TYPOGRAPHY: defaultTokens.TYPOGRAPHY, + RADIUS: defaultTokens.RADIUS, +}; + +export const altTheme: Theme = { + COLORS: altTokens.COLORS, + SPACING: altTokens.SPACING, + TYPOGRAPHY: altTokens.TYPOGRAPHY, + RADIUS: altTokens.RADIUS, +}; diff --git a/src/styles/commonStyles.ts b/src/styles/useCommonStyles.ts similarity index 95% rename from src/styles/commonStyles.ts rename to src/styles/useCommonStyles.ts index c90e842..7f27b58 100644 --- a/src/styles/commonStyles.ts +++ b/src/styles/useCommonStyles.ts @@ -1,7 +1,7 @@ import { StyleSheet } from "react-native"; -import { SPACING, TYPOGRAPHY, COLORS, RADIUS } from "./theme"; +import { createThemedStyles } from "./createThemedStyles"; -export const commonStyles = StyleSheet.create({ +export const useCommonStyles = createThemedStyles(({ SPACING, TYPOGRAPHY, COLORS, RADIUS }) => StyleSheet.create({ screenContent: { padding: SPACING._20, }, @@ -137,4 +137,4 @@ export const commonStyles = StyleSheet.create({ fontSize: TYPOGRAPHY.sizes.body, color: COLORS.textPrimary, }, -}); +})); diff --git a/src/views/ExternalJoinView.tsx b/src/views/ExternalJoinView.tsx index 07c5401..5e95b22 100644 --- a/src/views/ExternalJoinView.tsx +++ b/src/views/ExternalJoinView.tsx @@ -1,6 +1,6 @@ import React from "react"; import { Text, View, Pressable, StyleSheet } from "react-native"; -import { COLORS, SPACING, RADIUS, TYPOGRAPHY } from "@/styles/theme"; +import { createThemedStyles } from "@/styles/createThemedStyles"; export interface ExternalJoinViewProps { code: string; @@ -9,6 +9,7 @@ export interface ExternalJoinViewProps { } export function ExternalJoinView({ code, onOpen, onJoinBrowser }: ExternalJoinViewProps) { + const styles = useStyles(); return ( Joining Crawl with Code: @@ -25,7 +26,7 @@ export function ExternalJoinView({ code, onOpen, onJoinBrowser }: ExternalJoinVi ); } -const styles = StyleSheet.create({ +const useStyles = createThemedStyles(({ COLORS, SPACING, TYPOGRAPHY, RADIUS }) => StyleSheet.create({ container: { padding: SPACING.md, alignItems: "center" }, label: { fontSize: TYPOGRAPHY.sizes.body, marginBottom: SPACING.sm }, code: { fontWeight: TYPOGRAPHY.weights.semibold, marginBottom: SPACING.md }, @@ -50,5 +51,5 @@ const styles = StyleSheet.create({ opacity: 0.7, }, buttonSecondaryText: { color: COLORS.primary, fontWeight: TYPOGRAPHY.weights.semibold }, -}); +})); diff --git a/src/views/captureMediaView.tsx b/src/views/captureMediaView.tsx index c46b682..6c0c9ec 100644 --- a/src/views/captureMediaView.tsx +++ b/src/views/captureMediaView.tsx @@ -10,10 +10,11 @@ import { import { CameraView } from "expo-camera"; import MaterialIcons from "@expo/vector-icons/MaterialIcons"; import FontAwesome5 from "@expo/vector-icons/FontAwesome5"; -import { COLORS, RADIUS, SPACING, TYPOGRAPHY } from "@/styles/theme"; -import { commonStyles } from "@/styles/commonStyles"; +import { useCommonStyles } from "@/styles/useCommonStyles"; import { ActionButton } from "@/views/components/ActionButton"; import { WatermarkedPhoto, WatermarkedPhotoHandle } from "@/views/components/WatermarkedPhoto"; +import { createThemedStyles } from "@/styles/createThemedStyles"; +import { useTheme } from "@/styles/ThemeProvider"; export type PendingCapture = { uri: string; @@ -49,6 +50,9 @@ export function CaptureMediaView({ onRetake, onCancel, }: CaptureMediaViewProps): ReactElement { + const styles = useStyles(); + const commonStyles = useCommonStyles(); + const { COLORS } = useTheme(); const canUseCamera = Platform.OS !== "web"; if (!canUseCamera) { @@ -186,7 +190,7 @@ export function CaptureMediaView({ ); } -const styles = StyleSheet.create({ +const useStyles = createThemedStyles(({ COLORS, SPACING, TYPOGRAPHY, RADIUS }) => StyleSheet.create({ container: { flex: 1, padding: SPACING.md, @@ -296,4 +300,4 @@ const styles = StyleSheet.create({ previewActions: { gap: SPACING.sm, }, -}); +})); diff --git a/src/views/components/ActionButton.tsx b/src/views/components/ActionButton.tsx index a0f3dd2..f077673 100644 --- a/src/views/components/ActionButton.tsx +++ b/src/views/components/ActionButton.tsx @@ -1,6 +1,7 @@ import { ReactElement, ReactNode } from "react"; import { Pressable, View, ActivityIndicator, Text, StyleSheet } from "react-native"; -import { COLORS } from "@/styles/theme"; +import { createThemedStyles } from "@/styles/createThemedStyles"; +import { useTheme } from "@/styles/ThemeProvider"; export type ActionButtonProps = { label: string; @@ -15,6 +16,8 @@ export type ActionButtonProps = { export function ActionButton({ label, onPress, compact, icon, loading = false, disabled = false, loadingLabel, }: ActionButtonProps): ReactElement { + const styles = useStyles(); + const { COLORS } = useTheme(); const isDisabled = disabled || loading; const displayLabel = loading && loadingLabel ? loadingLabel : label; @@ -40,7 +43,7 @@ export function ActionButton({ ); } -const styles = StyleSheet.create({ +const useStyles = createThemedStyles(({ COLORS }) => StyleSheet.create({ actionButton: { borderWidth: 1, borderColor: COLORS.primary, @@ -77,4 +80,4 @@ const styles = StyleSheet.create({ alignItems: "center", justifyContent: "center", }, -}); +})); diff --git a/src/views/components/BackButton.tsx b/src/views/components/BackButton.tsx index b6c1663..bdb29b7 100644 --- a/src/views/components/BackButton.tsx +++ b/src/views/components/BackButton.tsx @@ -2,10 +2,11 @@ import React from "react"; import { Pressable } from "react-native"; import { MaterialIcons } from "@expo/vector-icons"; import { router, useNavigation } from "expo-router"; // Add useNavigation -import { COLORS } from "@/styles/theme"; import type { ReactElement } from "react"; +import { useTheme } from "@/styles/ThemeProvider"; export default function BackButton(): ReactElement { + const { COLORS } = useTheme(); const navigation = useNavigation(); diff --git a/src/views/components/ConfirmModal.tsx b/src/views/components/ConfirmModal.tsx index f5146e8..4f844c0 100644 --- a/src/views/components/ConfirmModal.tsx +++ b/src/views/components/ConfirmModal.tsx @@ -1,6 +1,7 @@ import { ReactElement } from "react"; import { ActivityIndicator, Modal, Pressable, StyleSheet, Text, View } from "react-native"; -import { COLORS, RADIUS, SPACING, TYPOGRAPHY } from "@/styles/theme"; +import { createThemedStyles } from "@/styles/createThemedStyles"; +import { useTheme } from "@/styles/ThemeProvider"; type ConfirmModalProps = { visible: boolean; @@ -27,6 +28,8 @@ export function ConfirmModal({ onConfirm, onCancel, }: ConfirmModalProps): ReactElement { + const styles = useStyles(); + const { COLORS } = useTheme(); const isConfirmDisabled = confirmDisabled || isConfirmLoading; const confirmButtonColor = destructive ? COLORS.error : COLORS.primary; @@ -68,7 +71,7 @@ export function ConfirmModal({ ); } -const styles = StyleSheet.create({ +const useStyles = createThemedStyles(({ COLORS, SPACING, TYPOGRAPHY, RADIUS }) => StyleSheet.create({ backdrop: { flex: 1, backgroundColor: "rgba(0, 0, 0, 0.45)", @@ -135,4 +138,4 @@ const styles = StyleSheet.create({ buttonDisabled: { opacity: 0.7, }, -}); +})); diff --git a/src/views/components/CrawlStopRow.tsx b/src/views/components/CrawlStopRow.tsx index 3db7c8a..2a7a584 100644 --- a/src/views/components/CrawlStopRow.tsx +++ b/src/views/components/CrawlStopRow.tsx @@ -1,9 +1,9 @@ import { ReactElement } from "react"; import { Pressable, Text, View } from "react-native"; import FontAwesome5 from "@expo/vector-icons/FontAwesome5"; -import { COLORS } from "@/styles/theme"; -import { commonStyles } from "@/styles/commonStyles"; +import { useCommonStyles } from "@/styles/useCommonStyles"; import { formatDateTimeShort } from "@/utils/dateUtils"; +import { useTheme } from "@/styles/ThemeProvider"; type CrawlStopRowProps = { index: number; @@ -22,6 +22,8 @@ export function CrawlStopRow({ onPress, disabled = false, }: CrawlStopRowProps): ReactElement { + const commonStyles = useCommonStyles(); + const { COLORS } = useTheme(); const isPressable = Boolean(onPress) && !disabled; return ( diff --git a/src/views/components/CrawlVisibilitySection.tsx b/src/views/components/CrawlVisibilitySection.tsx index 5868967..ff44a1d 100644 --- a/src/views/components/CrawlVisibilitySection.tsx +++ b/src/views/components/CrawlVisibilitySection.tsx @@ -1,6 +1,6 @@ import { Text, View, TouchableOpacity, StyleSheet } from "react-native"; -import { commonStyles } from "@/styles/commonStyles"; -import { COLORS } from "@/styles/theme"; +import { useCommonStyles } from "@/styles/useCommonStyles"; +import { createThemedStyles } from "@/styles/createThemedStyles"; type CrawlVisibilitySectionProps = { isPublic: boolean, @@ -13,6 +13,8 @@ export function CrawlVisibilitySection({ onIsPublicChange, isEditable, }: CrawlVisibilitySectionProps) { + const styles = useStyles(); + const commonStyles = useCommonStyles(); return ( { isEditable ? <> @@ -52,7 +54,7 @@ export function CrawlVisibilitySection({ ); } -const styles = StyleSheet.create({ +const useStyles = createThemedStyles(({ COLORS }) => StyleSheet.create({ container: { flexDirection: "column", alignItems: "flex-start", @@ -99,5 +101,5 @@ const styles = StyleSheet.create({ segmentTextUnselected: { color: '#222', }, -}); +})); diff --git a/src/views/components/Divider.tsx b/src/views/components/Divider.tsx index 20033d1..96b7ab5 100644 --- a/src/views/components/Divider.tsx +++ b/src/views/components/Divider.tsx @@ -1,14 +1,15 @@ import { ReactElement } from "react"; import { View, StyleSheet } from "react-native"; -import { COLORS } from "@/styles/theme"; +import { createThemedStyles } from "@/styles/createThemedStyles"; export function Divider(): ReactElement { + const styles = useStyles(); return ; } -const styles = StyleSheet.create({ +const useStyles = createThemedStyles(({ COLORS }) => StyleSheet.create({ divider: { height: 1, backgroundColor: COLORS.divider, }, -}); +})); diff --git a/src/views/components/FallbackUserAvatar.tsx b/src/views/components/FallbackUserAvatar.tsx index 6a4314d..203ba3e 100644 --- a/src/views/components/FallbackUserAvatar.tsx +++ b/src/views/components/FallbackUserAvatar.tsx @@ -1,12 +1,15 @@ import { StyleProp, View, ViewStyle, ImageStyle, StyleSheet } from "react-native"; import MaterialIcons from "@expo/vector-icons/MaterialIcons"; -import { COLORS } from "@/styles/theme"; +import { createThemedStyles } from "@/styles/createThemedStyles"; +import { useTheme } from "@/styles/ThemeProvider"; type FallBackUserAvatarProps = { style: StyleProp; }; export function FallBackUserAvatar({ style }: FallBackUserAvatarProps) { + const styles = useStyles(); + const { COLORS } = useTheme(); return ( , styles.avatarFallback]}> @@ -14,10 +17,10 @@ export function FallBackUserAvatar({ style }: FallBackUserAvatarProps) { ); } -const styles = StyleSheet.create({ +const useStyles = createThemedStyles(({ COLORS }) => StyleSheet.create({ avatarFallback: { backgroundColor: COLORS.mapBackground, alignItems: "center", justifyContent: "center", }, -}); +})); diff --git a/src/views/components/FullScreenMap.native.tsx b/src/views/components/FullScreenMap.native.tsx index 32fda4f..d8c683f 100644 --- a/src/views/components/FullScreenMap.native.tsx +++ b/src/views/components/FullScreenMap.native.tsx @@ -3,8 +3,9 @@ import { ReactElement, useRef, useEffect } from "react"; import Mapbox from "@/mapboxConfig"; import { coordinatesToArray, GeoCoordinates } from "@/utils/geo"; import { MapOverlay } from "@/views/components/mapOverlay"; -import { COLORS } from "@/styles/theme"; import { MapRefocusButton } from "@/views/components/MapRefocusButton"; +import { createThemedStyles } from "@/styles/createThemedStyles"; +import { useTheme } from "@/styles/ThemeProvider"; interface FullScreenMapProps { isLocationGranted: boolean; @@ -25,6 +26,8 @@ export function FullScreenMap({ bottomPadding, showSheen, }: FullScreenMapProps): ReactElement { + const styles = useStyles(); + const { COLORS } = useTheme(); const cameraRef = useRef(null); const opacity = useRef(new Animated.Value(0)).current; const hasCompletedInitialRender = useRef(false); @@ -144,7 +147,7 @@ export function FullScreenMap({ ); } -const styles = StyleSheet.create({ +const useStyles = createThemedStyles(({ COLORS }) => StyleSheet.create({ container: { flex: 1, }, @@ -170,4 +173,4 @@ const styles = StyleSheet.create({ ...StyleSheet.absoluteFillObject, backgroundColor: "rgba(0,0,0,0.05)", }, -}); +})); diff --git a/src/views/components/GestureBottomSheet.tsx b/src/views/components/GestureBottomSheet.tsx index 22924c0..2913c99 100644 --- a/src/views/components/GestureBottomSheet.tsx +++ b/src/views/components/GestureBottomSheet.tsx @@ -10,7 +10,7 @@ import { useWindowDimensions, View, } from "react-native"; -import { COLORS, RADIUS, SPACING } from "@/styles/theme"; +import { createThemedStyles } from "@/styles/createThemedStyles"; type GestureBottomSheetProps = { collapsedHeight: number; @@ -35,6 +35,7 @@ export function GestureBottomSheet({ handleAreaStyle, sheetStyle, }: GestureBottomSheetProps): ReactElement { + const styles = useStyles(); const { height: screenHeight } = useWindowDimensions(); const [expanded, setExpanded] = useState(false); @@ -127,7 +128,7 @@ export function GestureBottomSheet({ ); } -const styles = StyleSheet.create({ +const useStyles = createThemedStyles(({ COLORS, SPACING, RADIUS }) => StyleSheet.create({ sheet: { position: "absolute", left: 0, @@ -165,4 +166,4 @@ const styles = StyleSheet.create({ sheetScroll: { flex: 1, }, -}); +})); diff --git a/src/views/components/HomeTile.tsx b/src/views/components/HomeTile.tsx index 225d5de..1177007 100644 --- a/src/views/components/HomeTile.tsx +++ b/src/views/components/HomeTile.tsx @@ -1,6 +1,6 @@ import { ReactElement, ReactNode } from "react"; import { Pressable, View, Text, StyleSheet } from "react-native"; -import { COLORS } from "@/styles/theme"; +import { createThemedStyles } from "@/styles/createThemedStyles"; export type HomeTileProps = { label: string; @@ -9,6 +9,7 @@ export type HomeTileProps = { }; export function HomeTile({ label, icon, onPress }: HomeTileProps): ReactElement { + const styles = useStyles(); return ( {icon} @@ -17,7 +18,7 @@ export function HomeTile({ label, icon, onPress }: HomeTileProps): ReactElement ); } -const styles = StyleSheet.create({ +const useStyles = createThemedStyles(({ COLORS }) => StyleSheet.create({ homeTile: { width: "100%", minHeight: 60, @@ -46,4 +47,4 @@ const styles = StyleSheet.create({ color: COLORS.textPrimary, paddingTop: 8, }, -}); +})); diff --git a/src/views/components/MapRefocusButton.tsx b/src/views/components/MapRefocusButton.tsx index 8d81dea..b7ec445 100644 --- a/src/views/components/MapRefocusButton.tsx +++ b/src/views/components/MapRefocusButton.tsx @@ -1,6 +1,7 @@ import { Pressable, StyleProp, StyleSheet, ViewStyle } from "react-native"; import MaterialIcons from "@expo/vector-icons/MaterialIcons"; -import { COLORS, RADIUS, SPACING } from "@/styles/theme"; +import { createThemedStyles } from "@/styles/createThemedStyles"; +import { useTheme } from "@/styles/ThemeProvider"; type MapRefocusButtonProps = { onPress: () => void; @@ -19,6 +20,8 @@ export function MapRefocusButton({ right = 12, style, }: MapRefocusButtonProps) { + const styles = useStyles(); + const { COLORS } = useTheme(); return ( StyleSheet.create({ button: { position: "absolute", alignItems: "center", @@ -51,4 +54,4 @@ const styles = StyleSheet.create({ padding: SPACING.xs, zIndex: 10, }, -}); +})); diff --git a/src/views/components/MapStopMarkerShape.tsx b/src/views/components/MapStopMarkerShape.tsx index 2f0a252..6c7f364 100644 --- a/src/views/components/MapStopMarkerShape.tsx +++ b/src/views/components/MapStopMarkerShape.tsx @@ -1,7 +1,8 @@ import { StyleSheet, View } from "react-native"; -import { COLORS } from "@/styles/theme"; +import { createThemedStyles } from "@/styles/createThemedStyles"; export function MapStopMarkerShape() { + const styles = useStyles(); return ( @@ -9,7 +10,7 @@ export function MapStopMarkerShape() { ) } -const styles = StyleSheet.create({ +const useStyles = createThemedStyles(({ COLORS }) => StyleSheet.create({ pinOuter: { width: 28, height: 28, @@ -31,4 +32,4 @@ const styles = StyleSheet.create({ borderRadius: 6, backgroundColor: COLORS.primary, }, -}); +})); diff --git a/src/views/components/MediaPreviewStrip.tsx b/src/views/components/MediaPreviewStrip.tsx index 35e08e5..0c420dc 100644 --- a/src/views/components/MediaPreviewStrip.tsx +++ b/src/views/components/MediaPreviewStrip.tsx @@ -1,6 +1,6 @@ import { ReactElement } from "react"; import { View, Image, Pressable, Text, StyleSheet } from "react-native"; -import { COLORS } from "@/styles/theme"; +import { createThemedStyles } from "@/styles/createThemedStyles"; export type MediaPreviewItem = { url: string; @@ -18,6 +18,7 @@ export function MediaPreviewStrip({ items, onPressItem, }: MediaPreviewStripProps): ReactElement | null { + const styles = useStyles(); const resolvedItems: MediaPreviewItem[] = items ?? (imageUrls ?? []).map((url) => ({ url })); @@ -68,7 +69,7 @@ export function MediaPreviewStrip({ ); } -const styles = StyleSheet.create({ +const useStyles = createThemedStyles(({ COLORS }) => StyleSheet.create({ mediaRow: { flexDirection: "row", alignItems: "center", @@ -102,4 +103,4 @@ const styles = StyleSheet.create({ fontWeight: "700", color: COLORS.textSecondary, }, -}); +})); diff --git a/src/views/components/ParticipantsAvatarStrip.tsx b/src/views/components/ParticipantsAvatarStrip.tsx index 38e09a9..4eece02 100644 --- a/src/views/components/ParticipantsAvatarStrip.tsx +++ b/src/views/components/ParticipantsAvatarStrip.tsx @@ -1,7 +1,7 @@ import React, { ReactElement, useEffect, useState } from "react"; import { View, Image, Text, StyleSheet, ImageStyle, StyleProp, Platform } from "react-native"; -import { COLORS } from "@/styles/theme"; import { FallBackUserAvatar } from "./FallbackUserAvatar"; +import { createThemedStyles } from "@/styles/createThemedStyles"; export const MAX_VISIBLE_PARTICIPANTS = 3; @@ -59,6 +59,7 @@ const AvatarImage = ({ uri, style }: AvatarImageProps): ReactElement => { }; export function ParticipantsAvatarStrip({ avatarUrls }: ParticipantsAvatarStripProps): ReactElement | null { + const styles = useStyles(); if (!avatarUrls.length) { return null; } @@ -84,7 +85,7 @@ export function ParticipantsAvatarStrip({ avatarUrls }: ParticipantsAvatarStripP ); } -const styles = StyleSheet.create({ +const useStyles = createThemedStyles(({ COLORS }) => StyleSheet.create({ avatarRow: { flexDirection: "row", alignItems: "center", @@ -115,4 +116,4 @@ const styles = StyleSheet.create({ fontWeight: "700", color: COLORS.textSecondary, }, -}); \ No newline at end of file +})); \ No newline at end of file diff --git a/src/views/components/RefreshIndicator.tsx b/src/views/components/RefreshIndicator.tsx index 5f0807d..66057d4 100644 --- a/src/views/components/RefreshIndicator.tsx +++ b/src/views/components/RefreshIndicator.tsx @@ -1,11 +1,12 @@ import { RefreshControl, RefreshControlProps } from "react-native"; -import { COLORS } from "@/styles/theme"; +import { useTheme } from "@/styles/ThemeProvider"; export function RefreshIndicator({ refreshing, onRefresh, ...props }: RefreshControlProps) { + const { COLORS } = useTheme(); return ( @@ -16,11 +20,11 @@ export function ScreenLoader({ label = "Loading..." }: ScreenLoaderProps): React ); } -const styles = StyleSheet.create({ +const useStyles = createThemedStyles(() => StyleSheet.create({ screenLoader: { flex: 1, alignItems: "center", justifyContent: "center", gap: 12, }, -}); +})); diff --git a/src/views/components/TitleInput.tsx b/src/views/components/TitleInput.tsx index 5dff951..e6c7077 100644 --- a/src/views/components/TitleInput.tsx +++ b/src/views/components/TitleInput.tsx @@ -1,8 +1,8 @@ import { TextInput, View } from "react-native"; import FontAwesome5 from "@expo/vector-icons/FontAwesome5"; -import { commonStyles } from "@/styles/commonStyles"; -import { COLORS } from "@/styles/theme"; +import { useCommonStyles } from "@/styles/useCommonStyles"; import { ReactElement } from "react"; +import { useTheme } from "@/styles/ThemeProvider"; type TitleInputProps = { value: string; @@ -12,6 +12,8 @@ type TitleInputProps = { }; export function TitleInput({ value, onChangeText, placeholder, editable = true }: TitleInputProps): ReactElement { + const commonStyles = useCommonStyles(); + const { COLORS } = useTheme(); return ( diff --git a/src/views/components/ViewOnlyMapPanel.native.tsx b/src/views/components/ViewOnlyMapPanel.native.tsx index 63be3f2..230302e 100644 --- a/src/views/components/ViewOnlyMapPanel.native.tsx +++ b/src/views/components/ViewOnlyMapPanel.native.tsx @@ -1,10 +1,11 @@ import { ReactElement, useEffect, useMemo, useRef } from "react"; import { ActivityIndicator, Animated, StyleSheet, Text, View } from "react-native"; import Mapbox from "@/mapboxConfig"; -import { COLORS } from "@/styles/theme"; import { MapRefocusButton } from "./MapRefocusButton"; import { coordinatesToArray, DEFAULT_LOCATION, type GeoCoordinates } from "@/utils/geo"; import { MapStopMarkerShape } from "./MapStopMarkerShape"; +import { createThemedStyles } from "@/styles/createThemedStyles"; +import { useTheme } from "@/styles/ThemeProvider"; type ViewOnlyMapPanelProps = { coordinates?: GeoCoordinates; @@ -25,6 +26,8 @@ export function ViewOnlyMapPanel({ height = 340, onMapInteractionChange, }: ViewOnlyMapPanelProps): ReactElement { + const styles = useStyles(); + const { COLORS } = useTheme(); const mapOpacity = useRef(new Animated.Value(0)).current; const cameraRef = useRef(null); const hasCompletedInitialRender = useRef(false); @@ -168,7 +171,7 @@ export function ViewOnlyMapPanel({ ); } -const styles = StyleSheet.create({ +const useStyles = createThemedStyles(({ COLORS }) => StyleSheet.create({ mapSection: { gap: 8, }, @@ -221,4 +224,4 @@ const styles = StyleSheet.create({ height: 40, backgroundColor: "rgba(255, 255, 255, 0.15)", }, -}); +})); diff --git a/src/views/components/ViewOnlyMapPanel.web.tsx b/src/views/components/ViewOnlyMapPanel.web.tsx index 6b005f2..f562e16 100644 --- a/src/views/components/ViewOnlyMapPanel.web.tsx +++ b/src/views/components/ViewOnlyMapPanel.web.tsx @@ -1,11 +1,12 @@ import { ReactElement, useEffect, useMemo, useRef } from "react"; import { ActivityIndicator, Animated, StyleSheet, Text, View } from "react-native"; import Mapbox from "@/mapboxConfig"; -import { COLORS } from "@/styles/theme"; import { MapRefocusButton } from "./MapRefocusButton"; import { coordinatesToArray, DEFAULT_LOCATION, type GeoCoordinates } from "@/utils/geo"; import { MapStopMarkerShape } from "./MapStopMarkerShape"; import { MapUserLocationMarker } from "./MapUserLocationMarker"; +import { createThemedStyles } from "@/styles/createThemedStyles"; +import { useTheme } from "@/styles/ThemeProvider"; type ViewOnlyMapPanelProps = { coordinates?: GeoCoordinates; @@ -26,6 +27,8 @@ export function ViewOnlyMapPanel({ height = 340, onMapInteractionChange, }: ViewOnlyMapPanelProps): ReactElement { + const styles = useStyles(); + const { COLORS } = useTheme(); const mapOpacity = useRef(new Animated.Value(0)).current; const cameraRef = useRef(null); const didRevealMapRef = useRef(false); @@ -200,7 +203,7 @@ export function ViewOnlyMapPanel({ ); } -const styles = StyleSheet.create({ +const useStyles = createThemedStyles(({ COLORS }) => StyleSheet.create({ mapSection: { gap: 8, }, @@ -295,4 +298,4 @@ const styles = StyleSheet.create({ borderRadius: 4.5, backgroundColor: COLORS.secondary, }, -}); +})); diff --git a/src/views/crawlDetailsView.tsx b/src/views/crawlDetailsView.tsx index 2605206..083a2f1 100644 --- a/src/views/crawlDetailsView.tsx +++ b/src/views/crawlDetailsView.tsx @@ -6,8 +6,7 @@ import { } from "react-native"; import MaterialIcons from "@expo/vector-icons/MaterialIcons"; import {DEFAULT_LOCATION, GeoCoordinates} from "@/utils/geo"; -import { commonStyles } from "@/styles/commonStyles"; -import { COLORS, SPACING, TYPOGRAPHY } from "@/styles/theme"; +import { useCommonStyles } from "@/styles/useCommonStyles"; import { ParticipantsAvatarStrip } from "@/views/components/ParticipantsAvatarStrip"; import { ScreenLoader } from "@/views/components/ScreenLoader"; import { ActionButton } from "@/views/components/ActionButton"; @@ -16,6 +15,8 @@ import { CrawlStopRow } from "@/views/components/CrawlStopRow"; import { FullScreenMap } from "@/views/components/FullScreenMap"; import { GestureBottomSheet } from "@/views/components/GestureBottomSheet"; import { pluralize } from "./shared/shared"; +import { createThemedStyles } from "@/styles/createThemedStyles"; +import { useTheme } from "@/styles/ThemeProvider"; type CrawlDetailsViewProps = { isLoading?: boolean; @@ -48,6 +49,9 @@ export function CrawlDetailsView({ onOpenAlbum, onAddMedia, }: CrawlDetailsViewProps): ReactElement { + const styles = useStyles(); + const commonStyles = useCommonStyles(); + const { COLORS, SPACING } = useTheme(); if (isLoading) { return ; } @@ -153,7 +157,7 @@ export function CrawlDetailsView({ ); } -const styles = StyleSheet.create({ +const useStyles = createThemedStyles(({ COLORS, SPACING, TYPOGRAPHY }) => StyleSheet.create({ container: { flex: 1, backgroundColor: COLORS.background, @@ -211,4 +215,4 @@ const styles = StyleSheet.create({ paddingTop: SPACING._14, paddingBottom: SPACING.xl, }, -}); +})); diff --git a/src/views/crawlHistoryView.tsx b/src/views/crawlHistoryView.tsx index 5f5ddd5..25d5871 100644 --- a/src/views/crawlHistoryView.tsx +++ b/src/views/crawlHistoryView.tsx @@ -1,12 +1,12 @@ import { ReactElement } from "react"; import MaterialIcons from "@expo/vector-icons/MaterialIcons"; import { Pressable, ScrollView, Text, View } from "react-native"; -import { COLORS } from "@/styles/theme"; -import { commonStyles } from "@/styles/commonStyles"; +import { useCommonStyles } from "@/styles/useCommonStyles"; import { ScreenLoader } from "@/views/components/ScreenLoader"; import { ActionButton } from "@/views/components/ActionButton"; import { CrawlHistoryItem } from "../types/crawlHistoryItem"; import { pluralize } from "./shared/shared"; +import { useTheme } from "@/styles/ThemeProvider"; type CrawlHistoryViewProps = { isLoading?: boolean; @@ -21,6 +21,8 @@ export function CrawlHistoryView({ onSelectCrawl, onNewPubCrawl, }: CrawlHistoryViewProps): ReactElement { + const commonStyles = useCommonStyles(); + const { COLORS } = useTheme(); if (isLoading) { return ; } diff --git a/src/views/editCrawlView.tsx b/src/views/editCrawlView.tsx index efcd57a..951c19c 100644 --- a/src/views/editCrawlView.tsx +++ b/src/views/editCrawlView.tsx @@ -2,8 +2,7 @@ import { ReactElement } from "react"; import FontAwesome5 from "@expo/vector-icons/FontAwesome5"; import MaterialIcons from "@expo/vector-icons/MaterialIcons"; import { Pressable, ScrollView, Text, View } from "react-native"; -import { COLORS } from "@/styles/theme"; -import { commonStyles } from "@/styles/commonStyles"; +import { useCommonStyles } from "@/styles/useCommonStyles"; import { TitleInput } from "@/views/components/TitleInput"; import { ParticipantsAvatarStrip } from "@/views/components/ParticipantsAvatarStrip"; import { ScreenLoader } from "@/views/components/ScreenLoader"; @@ -13,6 +12,7 @@ import { CrawlStopRow } from "@/views/components/CrawlStopRow"; import { CrawlVisibilitySection } from "@/views/components/CrawlVisibilitySection"; import { RefreshIndicator } from "@/views/components/RefreshIndicator"; import { ConfirmModal } from "@/views/components/ConfirmModal"; +import { useTheme } from "@/styles/ThemeProvider"; type EditCrawlViewProps = { mode?: "new" | "active"; @@ -81,6 +81,8 @@ export function EditCrawlView({ refreshing = false, onRefresh, }: EditCrawlViewProps): ReactElement { + const commonStyles = useCommonStyles(); + const { COLORS } = useTheme(); const isActiveMode = mode === "active"; const saveLabel = isActiveMode ? "Save Changes" : "Save"; const saveLoadingLabel = isActiveMode ? "Saving Changes..." : "Saving..."; diff --git a/src/views/editStopView.tsx b/src/views/editStopView.tsx index 5f9a3ce..ec4e84c 100644 --- a/src/views/editStopView.tsx +++ b/src/views/editStopView.tsx @@ -3,8 +3,7 @@ import FontAwesome5 from "@expo/vector-icons/FontAwesome5"; import { ActivityIndicator, Pressable, ScrollView, StyleSheet, Text, TextInput, View, Platform, TouchableOpacity } from "react-native"; import MaterialIcons from "@expo/vector-icons/MaterialIcons"; import DateTimePicker from "@react-native-community/datetimepicker"; -import { COLORS } from "@/styles/theme"; -import { commonStyles } from "@/styles/commonStyles"; +import { useCommonStyles } from "@/styles/useCommonStyles"; import { ScreenLoader } from "@/views/components/ScreenLoader"; import { ActionButton } from "@/views/components/ActionButton"; import { ViewOnlyMapPanel } from "@/views/components/ViewOnlyMapPanel"; @@ -12,6 +11,8 @@ import type { NearbyPlace } from "@/mapboxConfig"; import { formatDateTimeLong } from "@/utils/dateUtils"; import type { GeoCoordinates } from "@/utils/geo"; import { RefreshIndicator } from "@/views/components/RefreshIndicator"; +import { createThemedStyles } from "@/styles/createThemedStyles"; +import { useTheme } from "@/styles/ThemeProvider"; type EditStopViewProps = { isLoading?: boolean; @@ -62,6 +63,9 @@ export function EditStopView({ onNearbyPlacePress, onCustomPlacePress, }: EditStopViewProps): ReactElement { + const styles = useStyles(); + const commonStyles = useCommonStyles(); + const { COLORS } = useTheme(); const customNameInputRef = useRef(null); const [showDatePicker, setShowDatePicker] = useState(false); @@ -302,7 +306,7 @@ export function EditStopView({ ); } -const styles = StyleSheet.create({ +const useStyles = createThemedStyles(({ COLORS }) => StyleSheet.create({ nearbyPlacesSection: { gap: 12, }, @@ -367,7 +371,7 @@ const styles = StyleSheet.create({ paddingVertical: 0, paddingHorizontal: 0, }, -}); +})); function formatDistance(distanceInMeters: number): string { if (distanceInMeters < 1000) { diff --git a/src/views/joinCrawlView.tsx b/src/views/joinCrawlView.tsx index b8cdf26..e025ca9 100644 --- a/src/views/joinCrawlView.tsx +++ b/src/views/joinCrawlView.tsx @@ -2,9 +2,10 @@ import { ReactElement } from "react"; import { Platform, StyleSheet, Text, TextInput, View } from "react-native"; import { CameraView } from "expo-camera"; import MaterialIcons from "@expo/vector-icons/MaterialIcons"; -import { COLORS, RADIUS, SPACING, TYPOGRAPHY } from "@/styles/theme"; -import { commonStyles } from "@/styles/commonStyles"; +import { useCommonStyles } from "@/styles/useCommonStyles"; import { ActionButton } from "@/views/components/ActionButton"; +import { createThemedStyles } from "@/styles/createThemedStyles"; +import { useTheme } from "@/styles/ThemeProvider"; type JoinCrawlViewProps = { permissionGranted: boolean; @@ -31,6 +32,9 @@ export function JoinCrawlView({ onBarcodeScanned, onSubmitManualId, }: JoinCrawlViewProps): ReactElement { + const styles = useStyles(); + const commonStyles = useCommonStyles(); + const { COLORS } = useTheme(); const canUseCamera = Platform.OS !== "web"; return ( @@ -93,7 +97,7 @@ export function JoinCrawlView({ ); } -const styles = StyleSheet.create({ +const useStyles = createThemedStyles(({ COLORS, SPACING, TYPOGRAPHY, RADIUS }) => StyleSheet.create({ container: { flex: 1, gap: SPACING.md, @@ -152,4 +156,4 @@ const styles = StyleSheet.create({ color: COLORS.error, fontSize: TYPOGRAPHY.sizes.small, }, -}); +})); diff --git a/src/views/loginView.tsx b/src/views/loginView.tsx index b0b72c7..c2aee33 100644 --- a/src/views/loginView.tsx +++ b/src/views/loginView.tsx @@ -1,6 +1,7 @@ import { View, Text, TextInput, Pressable, StyleSheet, ActivityIndicator } from "react-native"; import { Image } from "expo-image"; -import { COLORS, SPACING, TYPOGRAPHY, RADIUS } from "@/styles/theme"; +import { createThemedStyles } from "@/styles/createThemedStyles"; +import { useTheme } from "@/styles/ThemeProvider"; interface LoginViewProps { email: string; @@ -16,6 +17,8 @@ interface LoginViewProps { } export function LoginView(props: LoginViewProps) { + const styles = useStyles(); + const { COLORS } = useTheme(); return ( StyleSheet.create({ container: { flex: 1, justifyContent: "center", @@ -212,4 +215,4 @@ const styles = StyleSheet.create({ color: COLORS.textSecondary, fontSize: TYPOGRAPHY.sizes.small, }, -}); +})); diff --git a/src/views/mediaAlbumView.tsx b/src/views/mediaAlbumView.tsx index 78917d0..f39e2e4 100644 --- a/src/views/mediaAlbumView.tsx +++ b/src/views/mediaAlbumView.tsx @@ -12,9 +12,10 @@ import { useWindowDimensions, } from "react-native"; import MaterialIcons from "@expo/vector-icons/MaterialIcons"; -import { COLORS, SPACING, TYPOGRAPHY } from "@/styles/theme"; import { ScreenLoader } from "@/views/components/ScreenLoader"; import type { MediaPreviewItem } from "@/views/components/MediaPreviewStrip"; +import { createThemedStyles } from "@/styles/createThemedStyles"; +import { useTheme } from "@/styles/ThemeProvider"; type MediaAlbumViewProps = { items: MediaPreviewItem[]; @@ -31,6 +32,8 @@ export function MediaAlbumView({ isExporting, onExport, }: MediaAlbumViewProps): ReactElement { + const styles = useStyles(); + const { COLORS } = useTheme(); const { width: screenWidth } = useWindowDimensions(); const safeInitialIndex = useMemo(() => { @@ -141,7 +144,7 @@ export function MediaAlbumView({ } } -const styles = StyleSheet.create({ +const useStyles = createThemedStyles(({ COLORS, SPACING, TYPOGRAPHY }) => StyleSheet.create({ container: { flex: 1, backgroundColor: "#000000", @@ -199,4 +202,4 @@ const styles = StyleSheet.create({ color: COLORS.textSecondary, fontSize: TYPOGRAPHY.sizes.body, }, -}); +})); diff --git a/src/views/navigation/AppDrawerContent.tsx b/src/views/navigation/AppDrawerContent.tsx index 2eede69..d780bed 100644 --- a/src/views/navigation/AppDrawerContent.tsx +++ b/src/views/navigation/AppDrawerContent.tsx @@ -4,9 +4,10 @@ import {DrawerContentComponentProps, DrawerContentScrollView} from "@react-navig import {ReactElement, useMemo} from "react"; import {Pressable, StyleSheet, Text, View} from "react-native"; import {useSafeAreaInsets} from "react-native-safe-area-context"; -import {COLORS, RADIUS, SPACING, TYPOGRAPHY} from "@/styles/theme"; import {router} from "expo-router"; import {getFeatureFlag, type FeatureFlagKey} from "@/featureFlags"; +import { createThemedStyles } from "@/styles/createThemedStyles"; +import { useTheme } from "@/styles/ThemeProvider"; type DrawerEntry = { routeName: string; @@ -111,6 +112,8 @@ export function AppDrawerContent({ isLoggedIn, isActiveCrawl }: AppDrawerContentProps): ReactElement { + const styles = useStyles(); + const { COLORS, SPACING } = useTheme(); const insets = useSafeAreaInsets(); const activeRouteName = useMemo(() => { const routeName = drawerProps.state.routeNames[drawerProps.state.index] ?? "/"; @@ -238,7 +241,7 @@ export function AppDrawerContent({ ); } -const styles = StyleSheet.create({ +const useStyles = createThemedStyles(({ COLORS, SPACING, TYPOGRAPHY, RADIUS }) => StyleSheet.create({ headerRow: { flexDirection: "row", alignItems: "center", @@ -365,7 +368,7 @@ const styles = StyleSheet.create({ fontSize: TYPOGRAPHY.sizes.small, lineHeight: 18, }, -}); +})); diff --git a/src/views/navigation/AppLayoutView.tsx b/src/views/navigation/AppLayoutView.tsx index da624ea..54bcf49 100644 --- a/src/views/navigation/AppLayoutView.tsx +++ b/src/views/navigation/AppLayoutView.tsx @@ -1,7 +1,7 @@ import {Drawer} from "expo-router/drawer"; import {ReactElement} from "react"; -import {COLORS} from "@/styles/theme"; import {AppDrawerContent} from "./AppDrawerContent"; +import { useTheme } from "@/styles/ThemeProvider"; type AppLayoutViewProps = { isLoggedIn: boolean, @@ -13,6 +13,7 @@ type AppLayoutViewProps = { }; export function AppLayoutView(props: AppLayoutViewProps): ReactElement { + const { COLORS } = useTheme(); return ( StyleSheet.create({ overlayRoot: { ...StyleSheet.absoluteFillObject, zIndex: 10, @@ -155,7 +158,7 @@ const styles = StyleSheet.create({ fontSize: TYPOGRAPHY.sizes.small, fontWeight: "600", }, -}); +})); diff --git a/src/views/nearbyCrawlsView.tsx b/src/views/nearbyCrawlsView.tsx index a2d1651..f3bea9c 100644 --- a/src/views/nearbyCrawlsView.tsx +++ b/src/views/nearbyCrawlsView.tsx @@ -1,8 +1,9 @@ import { ReactElement } from "react"; import { Pressable, ScrollView, StyleSheet, Text, View } from "react-native"; -import { commonStyles } from "@/styles/commonStyles"; +import { useCommonStyles } from "@/styles/useCommonStyles"; import { ScreenLoader } from "@/views/components/ScreenLoader"; import { RefreshIndicator } from "@/views/components/RefreshIndicator"; +import { createThemedStyles } from "@/styles/createThemedStyles"; export type NearbyCrawlCard = { id: string; @@ -28,6 +29,8 @@ export function NearbyCrawlsView({ onRefresh, onSelectCrawl, }: NearbyCrawlsViewProps): ReactElement { + const styles = useStyles(); + const commonStyles = useCommonStyles(); if (isLoading) { return ; } @@ -57,9 +60,9 @@ export function NearbyCrawlsView({ ); } -const styles = StyleSheet.create({ +const useStyles = createThemedStyles(() => StyleSheet.create({ cardTitle: { fontSize: 19, marginBottom: 4, }, -}); +})); diff --git a/src/views/newStopView.tsx b/src/views/newStopView.tsx index c6e2cc4..e67646c 100644 --- a/src/views/newStopView.tsx +++ b/src/views/newStopView.tsx @@ -1,10 +1,10 @@ import { ReactElement } from "react"; import FontAwesome5 from "@expo/vector-icons/FontAwesome5"; import { TextInput, View } from "react-native"; -import { COLORS } from "@/styles/theme"; -import { commonStyles } from "@/styles/commonStyles"; +import { useCommonStyles } from "@/styles/useCommonStyles"; import { MediaPreviewStrip } from "@/views/components/MediaPreviewStrip"; import { ActionButton } from "@/views/components/ActionButton"; +import { useTheme } from "@/styles/ThemeProvider"; type EditStopViewProps = { stopName: string; @@ -13,6 +13,8 @@ type EditStopViewProps = { }; export function EditStopView({ stopName, mediaImageUrls, onSave }: EditStopViewProps): ReactElement { + const commonStyles = useCommonStyles(); + const { COLORS } = useTheme(); return ( <> diff --git a/src/views/shareCrawlView.tsx b/src/views/shareCrawlView.tsx index 255bcb5..d75ac9d 100644 --- a/src/views/shareCrawlView.tsx +++ b/src/views/shareCrawlView.tsx @@ -1,8 +1,9 @@ import { ReactElement } from "react"; import { Pressable, StyleSheet, Text, View } from "react-native"; import QRCode from "react-native-qrcode-svg"; -import { COLORS, RADIUS, SPACING, TYPOGRAPHY } from "@/styles/theme"; -import { commonStyles } from "@/styles/commonStyles"; +import { useCommonStyles } from "@/styles/useCommonStyles"; +import { createThemedStyles } from "@/styles/createThemedStyles"; +import { useTheme } from "@/styles/ThemeProvider"; type ShareCrawlViewProps = { crawlId: string | null; @@ -19,6 +20,9 @@ export function ShareCrawlView({ onCopyId, copyFeedback, }: ShareCrawlViewProps): ReactElement { + const styles = useStyles(); + const commonStyles = useCommonStyles(); + const { COLORS } = useTheme(); return ( {crawlName ? {crawlName} : null} @@ -56,7 +60,7 @@ export function ShareCrawlView({ ); } -const styles = StyleSheet.create({ +const useStyles = createThemedStyles(({ COLORS, SPACING, TYPOGRAPHY, RADIUS }) => StyleSheet.create({ container: { alignItems: "center", gap: SPACING.md, @@ -113,4 +117,4 @@ const styles = StyleSheet.create({ color: COLORS.primary, fontSize: TYPOGRAPHY.sizes.small, }, -}); +})); diff --git a/src/views/soberCheckView.tsx b/src/views/soberCheckView.tsx index ed73501..2a6e57a 100644 --- a/src/views/soberCheckView.tsx +++ b/src/views/soberCheckView.tsx @@ -1,8 +1,8 @@ import {ReactElement} from "react"; import {StyleSheet, Text, View} from "react-native"; -import {COLORS, SPACING, TYPOGRAPHY} from "@/styles/theme"; import {ActionButton} from "@/views/components/ActionButton"; -import {commonStyles} from "@/styles/commonStyles"; +import { useCommonStyles } from "@/styles/useCommonStyles"; +import { createThemedStyles } from "@/styles/createThemedStyles"; export type GamePhase = "idle" | "countdown" | "playing" | "result"; @@ -44,6 +44,8 @@ export function SoberCheckView({ onCancel, gameEnabled }: SoberCheckViewProps): ReactElement { + const styles = useStyles(); + const commonStyles = useCommonStyles(); if (!gameEnabled) { return ( @@ -153,7 +155,7 @@ export function SoberCheckView({ } } -const styles = StyleSheet.create({ +const useStyles = createThemedStyles(({ COLORS, SPACING, TYPOGRAPHY }) => StyleSheet.create({ container: { flex: 1, backgroundColor: COLORS.background, @@ -256,4 +258,4 @@ const styles = StyleSheet.create({ alignItems: "center", justifyContent: "center", }, -}); +})); diff --git a/src/views/viewCrawlStopView.tsx b/src/views/viewCrawlStopView.tsx index 5d707c6..de23daa 100644 --- a/src/views/viewCrawlStopView.tsx +++ b/src/views/viewCrawlStopView.tsx @@ -1,11 +1,12 @@ import { ReactElement } from "react"; import FontAwesome5 from "@expo/vector-icons/FontAwesome5"; import { ScrollView, StyleSheet, Text, View } from "react-native"; -import { COLORS } from "@/styles/theme"; -import { commonStyles } from "@/styles/commonStyles"; +import { useCommonStyles } from "@/styles/useCommonStyles"; import { ScreenLoader } from "@/views/components/ScreenLoader"; import { ViewOnlyMapPanel } from "@/views/components/ViewOnlyMapPanel"; import type { GeoCoordinates } from "@/utils/geo"; +import { createThemedStyles } from "@/styles/createThemedStyles"; +import { useTheme } from "@/styles/ThemeProvider"; type ViewCrawlStopViewProps = { isLoading?: boolean; @@ -22,6 +23,9 @@ export function ViewCrawlStopView({ stopCoordinates, visitedOn, }: ViewCrawlStopViewProps): ReactElement { + const styles = useStyles(); + const commonStyles = useCommonStyles(); + const { COLORS } = useTheme(); if (isLoading) { return ; } @@ -66,10 +70,10 @@ export function ViewCrawlStopView({ ); } -const styles = StyleSheet.create({ +const useStyles = createThemedStyles(({ COLORS }) => StyleSheet.create({ locationText: { fontSize: 18, color: COLORS.textPrimary, fontWeight: "600", }, -}); +}));