mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-20 14:29:23 +02:00
- Add uload project with apps/web structure
- Reorganize from flat to monorepo structure
- Remove PocketBase binary and local data
- Update to pnpm and @uload/web namespace
- Add picture project to monorepo
- Remove embedded git repository
- Unify all package names to @{project}/{app} schema:
- @maerchenzauber/* (was @storyteller/*)
- @manacore/* (was manacore-*, manacore)
- @manadeck/* (was web, backend, manadeck)
- @memoro/* (was memoro-web, landing, memoro)
- @picture/* (already unified)
- @uload/web
- Add convenient dev scripts for all apps:
- pnpm dev:{project}:web
- pnpm dev:{project}:landing
- pnpm dev:{project}:mobile
- pnpm dev:{project}:backend
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
60 lines
1.7 KiB
TypeScript
60 lines
1.7 KiB
TypeScript
import React, { createContext, useContext, useEffect, ReactNode } from 'react';
|
|
import { StatusBar } from 'react-native';
|
|
import { useThemeStore, useTheme as useThemeHook } from '~/store/themeStore';
|
|
import type { NativeTheme as Theme, ThemeVariant, ColorMode } from '@picture/design-tokens/native';
|
|
|
|
// ThemeMode includes 'system' for automatic light/dark switching
|
|
type ThemeMode = ColorMode | 'system';
|
|
|
|
interface ThemeContextValue {
|
|
theme: Theme;
|
|
variant: ThemeVariant;
|
|
mode: ThemeMode;
|
|
actualMode: 'light' | 'dark';
|
|
isLoading: boolean;
|
|
setVariant: (variant: ThemeVariant) => Promise<void>;
|
|
setMode: (mode: ThemeMode) => Promise<void>;
|
|
toggleMode: () => void;
|
|
}
|
|
|
|
const ThemeContext = createContext<ThemeContextValue | undefined>(undefined);
|
|
|
|
interface ThemeProviderProps {
|
|
children: ReactNode;
|
|
}
|
|
|
|
export function ThemeProvider({ children }: ThemeProviderProps) {
|
|
const loadTheme = useThemeStore((state) => state.loadTheme);
|
|
const themeData = useThemeHook();
|
|
|
|
// Load theme on mount
|
|
useEffect(() => {
|
|
loadTheme();
|
|
}, []);
|
|
|
|
// Update StatusBar when theme changes
|
|
useEffect(() => {
|
|
if (!themeData.isLoading) {
|
|
StatusBar.setBarStyle(
|
|
themeData.actualMode === 'dark' ? 'light-content' : 'dark-content',
|
|
true
|
|
);
|
|
}
|
|
}, [themeData.actualMode, themeData.isLoading]);
|
|
|
|
return (
|
|
<ThemeContext.Provider value={themeData}>
|
|
{children}
|
|
</ThemeContext.Provider>
|
|
);
|
|
}
|
|
|
|
export function useTheme(): ThemeContextValue {
|
|
const context = useContext(ThemeContext);
|
|
if (context === undefined) {
|
|
// During initial render, return the hook directly as fallback
|
|
// This prevents crashes when components render before ThemeProvider is ready
|
|
return useThemeHook();
|
|
}
|
|
return context;
|
|
}
|