mirror of
https://github.com/khairul169/vaulterm.git
synced 2026-09-15 17:03:30 +07:00
feat: update ui
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { create } from "zustand";
|
||||
import { persist, createJSONStorage } from "zustand/middleware";
|
||||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||
|
||||
type Store = {
|
||||
theme: "light" | "dark";
|
||||
setTheme: (theme: "light" | "dark") => void;
|
||||
toggle: () => void;
|
||||
};
|
||||
|
||||
const useThemeStore = create(
|
||||
persist<Store>(
|
||||
(set) => ({
|
||||
theme: "light",
|
||||
setTheme: (theme: "light" | "dark") => {
|
||||
set({ theme });
|
||||
},
|
||||
toggle: () => {
|
||||
set((state) => ({ theme: state.theme === "light" ? "dark" : "light" }));
|
||||
},
|
||||
}),
|
||||
{
|
||||
name: "theme",
|
||||
storage: createJSONStorage(() => AsyncStorage),
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
export default useThemeStore;
|
||||
Reference in New Issue
Block a user