mirror of
https://github.com/khairul169/vaulterm.git
synced 2025-04-28 16:49:39 +07:00
30 lines
704 B
TypeScript
30 lines
704 B
TypeScript
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: "dark",
|
|
setTheme: (theme: "light" | "dark") => {
|
|
set({ theme });
|
|
},
|
|
toggle: () => {
|
|
set((state) => ({ theme: state.theme === "light" ? "dark" : "light" }));
|
|
},
|
|
}),
|
|
{
|
|
name: "vaulterm:theme",
|
|
storage: createJSONStorage(() => AsyncStorage),
|
|
}
|
|
)
|
|
);
|
|
|
|
export default useThemeStore;
|