Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add generic color definition (#771)
Leendert de Borst2e7fde861ee8
diff --git a/mobile-app/app/(tabs)/(credentials)/[id].tsx b/mobile-app/app/(tabs)/(credentials)/[id].tsxindex 942edd658..b30c825c1 100644--- a/mobile-app/app/(tabs)/(credentials)/[id].tsx+++ b/mobile-app/app/(tabs)/(credentials)/[id].tsx@@ -7,7 +7,6 @@ import { ThemedText } from '@/components/ThemedText';import { ThemedView } from '@/components/ThemedView';import { useDb } from '@/context/DbContext';import { Credential } from '@/utils/types/Credential';-import SqliteClient from '@/utils/SqliteClient';import { ThemedScrollView } from '@/components/ThemedScrollView';import { CredentialIcon } from '@/components/CredentialIcon';diff --git a/mobile-app/app/(tabs)/(credentials)/_layout.tsx b/mobile-app/app/(tabs)/(credentials)/_layout.tsxindex 1e452cac6..65cf5532d 100644--- a/mobile-app/app/(tabs)/(credentials)/_layout.tsx+++ b/mobile-app/app/(tabs)/(credentials)/_layout.tsx@@ -1,6 +1,10 @@+import { Colors } from '@/constants/Colors';import { Stack } from 'expo-router';+import { useColorScheme } from 'react-native';export default function CredentialsLayout() {+ const colorScheme = useColorScheme();+return (<Stack><Stack.Screen@@ -14,8 +18,12 @@ export default function CredentialsLayout() {options={{title: 'Credential Details',headerShown: true,+ headerStyle: {+ backgroundColor: Colors[colorScheme ?? 'light'].headerBackground,+ },+ headerTintColor: Colors[colorScheme ?? 'light'].text,}}/></Stack>);-}\ No newline at end of file+}\ No newline at end of filediff --git a/mobile-app/app/(tabs)/(credentials)/index.tsx b/mobile-app/app/(tabs)/(credentials)/index.tsxindex 75a7791d5..4755986fa 100644--- a/mobile-app/app/(tabs)/(credentials)/index.tsx+++ b/mobile-app/app/(tabs)/(credentials)/index.tsx@@ -10,13 +10,14 @@ import { useAuth } from '@/context/AuthContext';import { Credential } from '@/utils/types/Credential';import { CredentialIcon } from '@/components/CredentialIcon';import { useVaultSync } from '@/hooks/useVaultSync';-+import { useColors } from '@/hooks/useColorScheme';export default function CredentialsScreen() {const colorScheme = useColorScheme();const isDarkMode = colorScheme === 'dark';const [searchQuery, setSearchQuery] = useState('');const [refreshing, setRefreshing] = useState(false);const { syncVault } = useVaultSync();+ const colors = useColors();const dynamicStyles = {credentialItem: {@@ -134,7 +135,7 @@ export default function CredentialsScreen() {/><ThemedView style={styles.stepContainer}>{isLoadingCredentials ? (- <ActivityIndicator size="large" color="#f97316" />+ <ActivityIndicator size="large" color={colors.primaryButton} />) : (<FlatListdata={filteredCredentials}@@ -144,8 +145,8 @@ export default function CredentialsScreen() {<RefreshControlrefreshing={refreshing}onRefresh={onRefresh}- colors={['#f97316']}- tintColor={isDarkMode ? '#f97316' : '#f97316'}+ colors={[colors.primaryButton]}+ tintColor={isDarkMode ? colors.primaryButton : colors.primaryButton}/>}renderItem={({ item }) => (diff --git a/mobile-app/app/(tabs)/_layout.tsx b/mobile-app/app/(tabs)/_layout.tsxindex 97e3df440..d7a9b93a4 100644--- a/mobile-app/app/(tabs)/_layout.tsx+++ b/mobile-app/app/(tabs)/_layout.tsx@@ -6,13 +6,12 @@ import { router } from 'expo-router';import { HapticTab } from '@/components/HapticTab';import { IconSymbol } from '@/components/ui/IconSymbol';import TabBarBackground from '@/components/ui/TabBarBackground';-import { Colors } from '@/constants/Colors';-import { useColorScheme } from '@/hooks/useColorScheme';+import { useColors } from '@/hooks/useColorScheme';import { useAuth } from '@/context/AuthContext';import { useDb } from '@/context/DbContext';export default function TabLayout() {- const colorScheme = useColorScheme();+ const colors = useColors();const authContext = useAuth();const dbContext = useDb();@@ -39,13 +38,14 @@ export default function TabLayout() {return (<TabsscreenOptions={{- tabBarActiveTintColor: Colors[colorScheme ?? 'light'].tint,+ tabBarActiveTintColor: colors.tint,headerShown: false,tabBarButton: HapticTab,tabBarBackground: TabBarBackground,tabBarStyle: Platform.select({ios: {position: 'absolute',+ //backgroundColor: colors.tabBarBackground,},default: {},}),diff --git a/mobile-app/app/_layout.tsx b/mobile-app/app/_layout.tsxindex 32bb11090..ede346004 100644--- a/mobile-app/app/_layout.tsx+++ b/mobile-app/app/_layout.tsx@@ -4,21 +4,18 @@ import { Stack } from 'expo-router';import * as SplashScreen from 'expo-splash-screen';import { StatusBar } from 'expo-status-bar';import { useEffect } from 'react';-import { AppState, AppStateStatus, View, ActivityIndicator, Text } from 'react-native';+import { View, Text } from 'react-native';import 'react-native-reanimated';// Required for certain modules such as secure-remote-password which relies on crypto.getRandomValues// and this is not available in react-native without this polyfillimport 'react-native-get-random-values';import Toast from 'react-native-toast-message';-import { useColorScheme } from '@/hooks/useColorScheme';+import { useColors, useColorScheme } from '@/hooks/useColorScheme';import { LoadingProvider } from '@/context/LoadingContext';import { DbProvider } from '@/context/DbContext';import { AuthProvider } from '@/context/AuthContext';import { WebApiProvider } from '@/context/WebApiContext';-import { useAuth } from '@/context/AuthContext';-import { useDb } from '@/context/DbContext';-import { useVaultSync } from '@/hooks/useVaultSync';// Prevent the splash screen from auto-hiding before asset loading is complete.SplashScreen.preventAutoHideAsync();@@ -52,14 +49,25 @@ const toastConfig = {function RootLayoutNav() {const colorScheme = useColorScheme();+ const colors = useColors();return (<ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>- <Stack screenOptions={{ headerShown: false, animation: 'none' }}>- <Stack.Screen name="index" />- <Stack.Screen name="login" />- <Stack.Screen name="(tabs)" />- <Stack.Screen name="+not-found" />+ <Stack screenOptions={{+ headerShown: true,+ animation: 'none',+ headerStyle: {+ backgroundColor: colors.background,+ },+ headerTintColor: colors.text,+ headerTitleStyle: {+ fontWeight: 'bold',+ },+ }}>+ <Stack.Screen name="index" options={{ headerShown: false }} />+ <Stack.Screen name="login" options={{ headerShown: false }} />+ <Stack.Screen name="(tabs)" options={{ headerShown: false }} />+ <Stack.Screen name="+not-found" options={{ title: 'Not Found' }} /></Stack><StatusBar style="auto" /><Toast config={toastConfig} />diff --git a/mobile-app/constants/Colors.ts b/mobile-app/constants/Colors.tsindex 14e67844d..d6bab3678 100644--- a/mobile-app/constants/Colors.ts+++ b/mobile-app/constants/Colors.ts@@ -14,13 +14,24 @@ export const Colors = {icon: '#687076',tabIconDefault: '#687076',tabIconSelected: tintColorLight,+ headerBackground: '#fff',+ tabBarBackground: '#fff',+ primaryButton: '#f97316',+ secondaryButton: '#6b7280',},dark: {text: '#ECEDEE',- background: '#151718',+ background: '#111827',tint: tintColorDark,icon: '#9BA1A6',tabIconDefault: '#9BA1A6',tabIconSelected: tintColorDark,+ headerBackground: '#1f2937',+ tabBarBackground: '#1f2937',+ primaryButton: '#f97316',+ secondaryButton: '#6b7280',},-};+} as const;++// Export the type for TypeScript support+export type ThemeColors = typeof Colors.light;diff --git a/mobile-app/hooks/useColorScheme.ts b/mobile-app/hooks/useColorScheme.tsindex 17e3c63e1..2d0dd4ae1 100644--- a/mobile-app/hooks/useColorScheme.ts+++ b/mobile-app/hooks/useColorScheme.ts@@ -1 +1,15 @@-export { useColorScheme } from 'react-native';+import { useColorScheme as _useColorScheme } from 'react-native';+import { Colors } from '@/constants/Colors';++export type ColorSchemeName = 'light' | 'dark';++// Re-export the basic color scheme hook+export const useColorScheme = () => {+ return _useColorScheme() as ColorSchemeName;+};++// Simple hook that returns the current theme's colors+export const useColors = () => {+ const colorScheme = useColorScheme();+ return Colors[colorScheme ?? 'light'];+};diff --git a/mobile-app/hooks/useVaultSync.ts b/mobile-app/hooks/useVaultSync.tsindex 7d35520e5..c1f5b2fea 100644--- a/mobile-app/hooks/useVaultSync.ts+++ b/mobile-app/hooks/useVaultSync.ts@@ -52,7 +52,7 @@ export const useVaultSync = () => {if (statusError !== null) {console.log('Vault sync error:', statusError);await webApi.logout(statusError);- onError?.(statusError);+ onError?.(statusErrorr);return false;}@@ -60,6 +60,8 @@ export const useVaultSync = () => {const vaultMetadata = await dbContext.getVaultMetadata();const vaultRevisionNumber = vaultMetadata?.vaultRevisionNumber ?? 0;+ console.log('Vault revision local:', vaultRevisionNumber);+ console.log('Vault revision server:', statusResponse.vaultRevision);if (statusResponse.vaultRevision > vaultRevisionNumber) {const vaultResponseJson = await webApi.get<VaultResponse>('Vault');