Base dark theme implementation
This commit is contained in:
37
components/theme-selector/theme-selector.tsx
Normal file
37
components/theme-selector/theme-selector.tsx
Normal file
@@ -0,0 +1,37 @@
|
||||
import { setTheme } from "@/redux/user/user.actions";
|
||||
import { selectTheme } from "@/redux/user/user.selectors";
|
||||
import React from "react";
|
||||
import { SegmentedButtons } from "react-native-paper";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
||||
/**
|
||||
* Example component showing how to use the useTheme hook
|
||||
* and how to dispatch theme changes
|
||||
*/
|
||||
export const ThemeSelector = () => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const currentTheme = useSelector(selectTheme);
|
||||
|
||||
const handleThemeChange = (theme: "light" | "dark" | "system") => {
|
||||
dispatch(setTheme(theme));
|
||||
};
|
||||
|
||||
return (
|
||||
<SegmentedButtons
|
||||
value={currentTheme}
|
||||
onValueChange={handleThemeChange}
|
||||
buttons={[
|
||||
{
|
||||
value: "light",
|
||||
label: "Light",
|
||||
},
|
||||
{
|
||||
value: "dark",
|
||||
label: "Dark",
|
||||
},
|
||||
{ value: "system", label: "System" },
|
||||
]}
|
||||
/>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user