@hoddy-ui/core 2.5.22 → 2.5.24

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.22",
3
+ "version": "2.5.24",
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,9 +1,8 @@
1
1
  import { useContext } from "react";
2
- import { Dimensions, Platform } from "react-native";
3
- import { vs } from "react-native-size-matters";
2
+ import { Platform, useColorScheme } from "react-native";
4
3
  import { UIThemeContext } from "./theme";
5
4
  import colors from "./theme/colors";
6
- import { useSafeAreaInsets } from "react-native-safe-area-context";
5
+ import { ThemeModes, ThemeTypes } from "./types";
7
6
 
8
7
  export const useColors = () => {
9
8
  const { themeState } = useContext(UIThemeContext);
@@ -14,14 +13,26 @@ export const useTheme = () => {
14
13
  const { themeState } = useContext(UIThemeContext);
15
14
  return themeState.value;
16
15
  };
16
+
17
+ export const useThemeContext = () => {
18
+ const { themeState: theme, themeDispatch } = useContext(UIThemeContext);
19
+ const colorScheme: ThemeTypes = useColorScheme()!;
20
+
21
+ const setTheme = (theme: ThemeModes) => {
22
+ if (theme === "default") {
23
+ themeDispatch?.({ type: "default", payload: colorScheme });
24
+ } else {
25
+ themeDispatch?.({ type: theme });
26
+ }
27
+ };
28
+ return { theme, setTheme };
29
+ };
30
+
17
31
  export const useNavScreenOptions = (type: "stack" | "tab" | "drawer") => {
18
32
  const colors = useColors();
19
- const { bottom } = useSafeAreaInsets();
20
- const theme = useTheme();
21
33
  const options: any = {
22
34
  stack: {
23
35
  headerShown: false,
24
-
25
36
  headerStyle: {
26
37
  backgroundColor: colors.white[1],
27
38
  },
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;