@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 +1 -1
- package/src/hooks.ts +17 -6
- package/src/types.ts +1 -1
package/package.json
CHANGED
package/src/hooks.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { useContext } from "react";
|
|
2
|
-
import {
|
|
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 {
|
|
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