mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-18 21:21:23 +02:00
- Add nutriphi-database package with Drizzle ORM - meals and nutrition_goals schemas - PostgreSQL 16 Docker setup - Drizzle Kit configuration - Migrate backend from Supabase to Drizzle - Add DatabaseModule with connection pooling - Add StorageService for Hetzner Object Storage (S3-compatible) - Update MealsService with Drizzle queries - Add /api/meals/upload endpoint for image upload + analysis - Update web app to use backend for uploads - Remove Supabase Storage direct upload - Update uploadService to send images to backend - Remove Supabase dependencies from package.json - Simplify hooks.server.ts - Add Coolify deployment configuration - Dockerfile for production build - docker-compose.coolify.yml 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
62 lines
1.7 KiB
TypeScript
62 lines
1.7 KiB
TypeScript
import { useColorScheme } from 'nativewind';
|
|
import { useAppStore } from '../store/AppStore';
|
|
import { useEffect } from 'react';
|
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
|
|
const THEME_STORAGE_KEY = 'user-theme-preference';
|
|
|
|
export const useTheme = () => {
|
|
const { colorScheme, setColorScheme } = useColorScheme();
|
|
const { theme, setTheme } = useAppStore();
|
|
|
|
// Initialize theme from storage on app start
|
|
useEffect(() => {
|
|
const initializeTheme = async () => {
|
|
try {
|
|
const storedTheme = await AsyncStorage.getItem(THEME_STORAGE_KEY);
|
|
if (storedTheme && ['light', 'dark', 'system'].includes(storedTheme)) {
|
|
const parsedTheme = storedTheme as 'light' | 'dark' | 'system';
|
|
setTheme(parsedTheme);
|
|
|
|
// Apply the theme to NativeWind
|
|
if (parsedTheme === 'system') {
|
|
setColorScheme('system');
|
|
} else {
|
|
setColorScheme(parsedTheme);
|
|
}
|
|
}
|
|
} catch (error) {
|
|
console.error('Error loading theme from storage:', error);
|
|
}
|
|
};
|
|
|
|
initializeTheme();
|
|
}, [setTheme, setColorScheme]);
|
|
|
|
const updateTheme = async (newTheme: 'light' | 'dark' | 'system') => {
|
|
try {
|
|
// Update AppStore
|
|
setTheme(newTheme);
|
|
|
|
// Update NativeWind
|
|
if (newTheme === 'system') {
|
|
setColorScheme('system');
|
|
} else {
|
|
setColorScheme(newTheme);
|
|
}
|
|
|
|
// Persist to storage
|
|
await AsyncStorage.setItem(THEME_STORAGE_KEY, newTheme);
|
|
} catch (error) {
|
|
console.error('Error saving theme to storage:', error);
|
|
}
|
|
};
|
|
|
|
return {
|
|
theme,
|
|
colorScheme,
|
|
updateTheme,
|
|
isDark: colorScheme === 'dark',
|
|
isLight: colorScheme === 'light',
|
|
};
|
|
};
|