-
-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(mobile): Add settings page for configuring the theme
- Loading branch information
1 parent
b9c7857
commit 66fcf02
Showing
5 changed files
with
106 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Pressable, Text, View } from "react-native"; | ||
import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView"; | ||
import { Divider } from "@/components/ui/Divider"; | ||
import useAppSettings from "@/lib/settings"; | ||
import { Check } from "lucide-react-native"; | ||
|
||
export default function ThemePage() { | ||
const { settings, setSettings } = useAppSettings(); | ||
|
||
const options = (["light", "dark", "system"] as const) | ||
.map((theme) => { | ||
const isChecked = settings.theme === theme; | ||
return [ | ||
<Pressable | ||
onPress={() => setSettings({ ...settings, theme })} | ||
className="flex flex-row justify-between" | ||
key={theme} | ||
> | ||
<Text className="text-lg text-accent-foreground"> | ||
{ | ||
{ light: "Light Mode", dark: "Dark Mode", system: "System" }[ | ||
theme | ||
] | ||
} | ||
</Text> | ||
{isChecked && <Check />} | ||
</Pressable>, | ||
<Divider | ||
key={theme + "-divider"} | ||
orientation="horizontal" | ||
className="my-3 h-0.5 w-full" | ||
/>, | ||
]; | ||
}) | ||
.flat(); | ||
options.pop(); | ||
|
||
return ( | ||
<CustomSafeAreaView> | ||
<View className="flex h-full w-full items-center px-4 py-2"> | ||
<View className="w-full rounded-lg bg-white px-4 py-2 dark:bg-accent"> | ||
{options} | ||
</View> | ||
</View> | ||
</CustomSafeAreaView> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters