From 66fcf022695283268e80855365f10262ae6ec907 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Sat, 14 Sep 2024 17:08:40 +0100 Subject: feature(mobile): Add settings page for configuring the theme --- apps/mobile/app/_layout.tsx | 8 ++++- apps/mobile/app/dashboard/(tabs)/settings.tsx | 33 +++++++++++++++---- apps/mobile/app/dashboard/_layout.tsx | 11 +++++++ apps/mobile/app/dashboard/settings/theme.tsx | 47 +++++++++++++++++++++++++++ 4 files changed, 92 insertions(+), 7 deletions(-) create mode 100644 apps/mobile/app/dashboard/settings/theme.tsx (limited to 'apps/mobile/app') diff --git a/apps/mobile/app/_layout.tsx b/apps/mobile/app/_layout.tsx index 0f38165b..41186842 100644 --- a/apps/mobile/app/_layout.tsx +++ b/apps/mobile/app/_layout.tsx @@ -10,6 +10,7 @@ import { ShareIntentProvider, useShareIntent } from "expo-share-intent"; import { StatusBar } from "expo-status-bar"; import { StyledStack } from "@/components/navigation/stack"; import { Providers } from "@/lib/providers"; +import useAppSettings from "@/lib/settings"; import { cn } from "@/lib/utils"; import { BottomSheetModalProvider } from "@gorhom/bottom-sheet"; import { useColorScheme } from "nativewind"; @@ -17,7 +18,8 @@ import { useColorScheme } from "nativewind"; export default function RootLayout() { const router = useRouter(); const { hasShareIntent } = useShareIntent(); - const { colorScheme } = useColorScheme(); + const { colorScheme, setColorScheme } = useColorScheme(); + const { settings } = useAppSettings(); useEffect(() => { if (hasShareIntent) { @@ -27,6 +29,10 @@ export default function RootLayout() { } }, [hasShareIntent]); + useEffect(() => { + setColorScheme(settings.theme); + }, [settings.theme]); + return ( diff --git a/apps/mobile/app/dashboard/(tabs)/settings.tsx b/apps/mobile/app/dashboard/(tabs)/settings.tsx index 18d3d243..db118df8 100644 --- a/apps/mobile/app/dashboard/(tabs)/settings.tsx +++ b/apps/mobile/app/dashboard/(tabs)/settings.tsx @@ -1,7 +1,8 @@ import { useEffect } from "react"; -import { Text, View } from "react-native"; +import { Pressable, Text, View } from "react-native"; import { Slider } from "react-native-awesome-slider"; import { useSharedValue } from "react-native-reanimated"; +import { Link } from "expo-router"; import { Button } from "@/components/ui/Button"; import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; import { Divider } from "@/components/ui/Divider"; @@ -9,6 +10,7 @@ import PageTitle from "@/components/ui/PageTitle"; import { useSession } from "@/lib/session"; import useAppSettings from "@/lib/settings"; import { api } from "@/lib/trpc"; +import { ChevronRight } from "lucide-react-native"; export default function Dashboard() { const { logout } = useSession(); @@ -36,18 +38,35 @@ export default function Dashboard() { - + {isSettingsLoading ? "Loading ..." : settings.address} - - + {isLoading ? "Loading ..." : data?.email} -