feat: add theme system with light/dark mode support
- Add ThemeStore (Zustand) for reactive theme switching - Add Themes.tsx with THEMES object (defaultLight, defaultDark) - Add Settings screen with theme switcher and logout button - Add BaseButton component for reusable themed buttons - Migrate all components from static currentTheme to useThemeStore() - Add shadowColor to theme (iOS only, Android uses elevation) - All text elements now use theme colors (textPrimary, textSecondary, etc.) - Update tab navigation to include Settings tab - Move logout from Header to Settings screen
This commit is contained in:
60
apps/client/src/app/(tabs)/settings.tsx
Normal file
60
apps/client/src/app/(tabs)/settings.tsx
Normal file
@@ -0,0 +1,60 @@
|
||||
import { Text, View } from "react-native";
|
||||
import BaseBackground from "../../components/BaseBackground";
|
||||
import BaseButton from "../../components/BaseButton";
|
||||
import { useThemeStore } from "../../stores/ThemeStore";
|
||||
import { AuthService } from "../../services/AuthService";
|
||||
import { router } from "expo-router";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import Header from "../../components/Header";
|
||||
import { THEMES } from "../../Themes";
|
||||
|
||||
const handleLogout = async () => {
|
||||
await AuthService.logout();
|
||||
router.replace("/login");
|
||||
};
|
||||
|
||||
const Settings = () => {
|
||||
const { theme, setTheme } = useThemeStore();
|
||||
|
||||
return (
|
||||
<BaseBackground>
|
||||
<Header>
|
||||
<View className="h-full flex justify-center">
|
||||
<Text className="text-center text-3xl font-bold">Settings</Text>
|
||||
</View>
|
||||
</Header>
|
||||
<View className="flex items-center mt-4">
|
||||
<BaseButton onPress={handleLogout} solid={true}>
|
||||
<Ionicons name="log-out-outline" size={24} color={theme.primeFg} />{" "}
|
||||
Logout
|
||||
</BaseButton>
|
||||
<View>
|
||||
<Text
|
||||
className="text-center text-2xl"
|
||||
style={{ color: theme.textPrimary }}
|
||||
>
|
||||
Select Theme
|
||||
</Text>
|
||||
</View>
|
||||
<BaseButton
|
||||
solid={theme == THEMES.defaultLight}
|
||||
onPress={() => {
|
||||
setTheme("defaultLight");
|
||||
}}
|
||||
>
|
||||
Default Light
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
solid={theme == THEMES.defaultDark}
|
||||
onPress={() => {
|
||||
setTheme("defaultDark");
|
||||
}}
|
||||
>
|
||||
Default Dark
|
||||
</BaseButton>
|
||||
</View>
|
||||
</BaseBackground>
|
||||
);
|
||||
};
|
||||
|
||||
export default Settings;
|
||||
Reference in New Issue
Block a user