@hoddy-ui/core 2.5.23 → 2.5.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hoddy-ui/core",
3
- "version": "2.5.23",
3
+ "version": "2.5.25",
4
4
  "description": "Core rich react native components written in typescript",
5
5
  "main": "index.ts",
6
6
  "repository": {
package/src/hooks.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import { useContext } from "react";
2
- import { Platform } from "react-native";
2
+ import { Platform, useColorScheme } from "react-native";
3
3
  import { UIThemeContext } from "./theme";
4
4
  import colors from "./theme/colors";
5
+ import { ThemeModes, ThemeTypes } from "./types";
6
+ import AsyncStorage from "@react-native-async-storage/async-storage";
5
7
 
6
8
  export const useColors = () => {
7
9
  const { themeState } = useContext(UIThemeContext);
@@ -14,8 +16,18 @@ export const useTheme = () => {
14
16
  };
15
17
 
16
18
  export const useThemeContext = () => {
17
- const { themeState: theme, themeDispatch: setTheme } =
18
- useContext(UIThemeContext);
19
+ const { themeState: theme, themeDispatch } = useContext(UIThemeContext);
20
+ const colorScheme: ThemeTypes = useColorScheme()!;
21
+
22
+ const setTheme = (theme: ThemeModes) => {
23
+ if (theme === "default") {
24
+ themeDispatch?.({ type: "default", payload: colorScheme });
25
+ AsyncStorage.setItem("theme", "default");
26
+ } else {
27
+ themeDispatch?.({ type: theme });
28
+ AsyncStorage.setItem("theme", theme);
29
+ }
30
+ };
19
31
  return { theme, setTheme };
20
32
  };
21
33
 
@@ -24,7 +36,6 @@ export const useNavScreenOptions = (type: "stack" | "tab" | "drawer") => {
24
36
  const options: any = {
25
37
  stack: {
26
38
  headerShown: false,
27
-
28
39
  headerStyle: {
29
40
  backgroundColor: colors.white[1],
30
41
  },
package/src/types.ts CHANGED
@@ -55,7 +55,7 @@ export interface ThemeState {
55
55
 
56
56
  export interface ThemeContext {
57
57
  themeState: ThemeState;
58
- themeDispatch?: any;
58
+ themeDispatch?: (action: ThemeActionTypes) => void;
59
59
  }
60
60
  export interface ThemeProviderProps {
61
61
  children: ReactNode;