@hoddy-ui/core 2.0.0 → 2.0.36
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/README.md +60 -12
- package/next/dist/index.d.mts +113 -41
- package/next/dist/index.d.ts +113 -41
- package/next/dist/index.js +444 -297
- package/next/dist/index.js.map +1 -1
- package/next/dist/index.mjs +460 -307
- package/next/dist/index.mjs.map +1 -1
- package/next/package.json +4 -3
- package/package.json +2 -2
- package/src/Components/AlertX.tsx +4 -4
- package/src/Components/Animators/hooks/useFadeAnimation.ts +1 -3
- package/src/Components/Animators/hooks/useFloatAnimation.ts +9 -9
- package/src/Components/Animators/hooks/useGrowAnimation.ts +5 -4
- package/src/Components/Animators/hooks/useRollAnimation.ts +10 -6
- package/src/Components/Animators/hooks/useSlideAnimation.ts +5 -8
- package/src/Components/Animators/hooks/useThrownUpAnimation.ts +9 -12
- package/src/Components/Avatar.tsx +13 -7
- package/src/Components/Button.tsx +13 -12
- package/src/Components/FlashMessage.tsx +119 -42
- package/src/Components/FormWrapper.tsx +7 -2
- package/src/Components/Grid.tsx +5 -5
- package/src/Components/Locator.tsx +10 -2
- package/src/Components/Popup.tsx +95 -34
- package/src/Components/SafeAreaView.tsx +11 -11
- package/src/Components/SelectMenu.tsx +34 -52
- package/src/Components/TextField.tsx +16 -6
- package/src/Components/Typography.tsx +19 -16
- package/src/config/KeyManager.ts +6 -1
- package/src/config/index.ts +37 -2
- package/src/hooks.ts +21 -14
- package/src/theme/index.tsx +14 -6
- package/src/types.ts +10 -4
- package/src/utility.ts +11 -0
package/src/hooks.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
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";
|
|
5
|
+
import { ThemeModes, ThemeTypes } from "./types";
|
|
6
|
+
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
6
7
|
|
|
7
8
|
export const useColors = () => {
|
|
8
9
|
const { themeState } = useContext(UIThemeContext);
|
|
@@ -13,13 +14,26 @@ export const useTheme = () => {
|
|
|
13
14
|
const { themeState } = useContext(UIThemeContext);
|
|
14
15
|
return themeState.value;
|
|
15
16
|
};
|
|
17
|
+
|
|
18
|
+
export const useThemeContext = () => {
|
|
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
|
+
} else {
|
|
26
|
+
themeDispatch?.({ type: theme });
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
return { theme, setTheme };
|
|
30
|
+
};
|
|
31
|
+
|
|
16
32
|
export const useNavScreenOptions = (type: "stack" | "tab" | "drawer") => {
|
|
17
33
|
const colors = useColors();
|
|
18
|
-
const theme = useTheme();
|
|
19
34
|
const options: any = {
|
|
20
35
|
stack: {
|
|
21
36
|
headerShown: false,
|
|
22
|
-
|
|
23
37
|
headerStyle: {
|
|
24
38
|
backgroundColor: colors.white[1],
|
|
25
39
|
},
|
|
@@ -37,15 +51,12 @@ export const useNavScreenOptions = (type: "stack" | "tab" | "drawer") => {
|
|
|
37
51
|
headerShown: false,
|
|
38
52
|
headerTintColor: colors.dark.main,
|
|
39
53
|
tabBarStyle: {
|
|
40
|
-
borderTopColor:
|
|
54
|
+
borderTopColor: colors.white[2],
|
|
55
|
+
borderColor: colors.white[2],
|
|
41
56
|
borderTopWidth: 1,
|
|
42
|
-
// shadowColor: "#000",
|
|
43
|
-
// shadowOffset: { height: -3, width: 0 },
|
|
44
|
-
// shadowRadius: 7,
|
|
45
|
-
// shadowOpacity: 0.1,
|
|
46
57
|
backgroundColor: colors.white[1],
|
|
47
58
|
},
|
|
48
|
-
tabBarActiveTintColor: colors.
|
|
59
|
+
tabBarActiveTintColor: colors.primary.main,
|
|
49
60
|
tabBarInactiveTintColor: colors.textSecondary.main,
|
|
50
61
|
tabBarLabelStyle: {
|
|
51
62
|
// fontSize: ms(12),
|
|
@@ -70,9 +81,5 @@ export const useNavScreenOptions = (type: "stack" | "tab" | "drawer") => {
|
|
|
70
81
|
},
|
|
71
82
|
};
|
|
72
83
|
|
|
73
|
-
if (Platform.OS === "android") {
|
|
74
|
-
options.tab.tabBarStyle.height = Dimensions.get("screen").height * 0.08;
|
|
75
|
-
options.tab.tabBarStyle.paddingBottom = vs(15);
|
|
76
|
-
}
|
|
77
84
|
return options[type];
|
|
78
85
|
};
|
package/src/theme/index.tsx
CHANGED
|
@@ -24,7 +24,7 @@ function themeReducer(
|
|
|
24
24
|
{ type, payload }: ThemeActionTypes
|
|
25
25
|
): ThemeState {
|
|
26
26
|
// Platform
|
|
27
|
-
|
|
27
|
+
AsyncStorage.setItem("theme", type);
|
|
28
28
|
switch (type) {
|
|
29
29
|
case "dark":
|
|
30
30
|
return { mode: "dark", value: "dark" };
|
|
@@ -45,12 +45,20 @@ const ConfigureSystemUI = () => {
|
|
|
45
45
|
const config = getConfig();
|
|
46
46
|
if (colors) {
|
|
47
47
|
SystemUI.setBackgroundColorAsync(colors.white[1]);
|
|
48
|
-
if (Platform.OS === "android"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
if (Platform.OS === "android") {
|
|
49
|
+
if (config.EDGE_TO_EDGE) {
|
|
50
|
+
if (theme === "dark") {
|
|
51
|
+
NavigationBar.setStyle("light");
|
|
52
|
+
} else {
|
|
53
|
+
NavigationBar.setStyle("dark");
|
|
54
|
+
}
|
|
52
55
|
} else {
|
|
53
|
-
NavigationBar.
|
|
56
|
+
NavigationBar.setBackgroundColorAsync(colors.white[1]);
|
|
57
|
+
if (theme === "dark") {
|
|
58
|
+
NavigationBar.setButtonStyleAsync("light");
|
|
59
|
+
} else {
|
|
60
|
+
NavigationBar.setButtonStyleAsync("dark");
|
|
61
|
+
}
|
|
54
62
|
}
|
|
55
63
|
}
|
|
56
64
|
}
|
package/src/types.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ReactNode } from "react";
|
|
|
2
2
|
import {
|
|
3
3
|
NativeScrollEvent,
|
|
4
4
|
NativeSyntheticEvent,
|
|
5
|
+
StyleProp,
|
|
5
6
|
TextInputProps,
|
|
6
7
|
TextProps,
|
|
7
8
|
TextStyle,
|
|
@@ -54,7 +55,7 @@ export interface ThemeState {
|
|
|
54
55
|
|
|
55
56
|
export interface ThemeContext {
|
|
56
57
|
themeState: ThemeState;
|
|
57
|
-
themeDispatch?:
|
|
58
|
+
themeDispatch?: (action: ThemeActionTypes) => void;
|
|
58
59
|
}
|
|
59
60
|
export interface ThemeProviderProps {
|
|
60
61
|
children: ReactNode;
|
|
@@ -117,7 +118,7 @@ export interface LinkButtonProps {
|
|
|
117
118
|
style?: TextStyle & ViewStyle;
|
|
118
119
|
color?: colorTypes;
|
|
119
120
|
fontSize?: number;
|
|
120
|
-
fontWeight?:
|
|
121
|
+
fontWeight?: 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
|
|
121
122
|
disabled?: boolean;
|
|
122
123
|
onPress?: () => void;
|
|
123
124
|
}
|
|
@@ -214,7 +215,7 @@ export interface PopupProps {
|
|
|
214
215
|
open: boolean;
|
|
215
216
|
onClose?: () => void;
|
|
216
217
|
style?: ViewStyle;
|
|
217
|
-
|
|
218
|
+
disableAutoKeyboardManagement?: boolean;
|
|
218
219
|
onModalShow?: () => void;
|
|
219
220
|
onModalHide?: () => void;
|
|
220
221
|
}
|
|
@@ -229,6 +230,7 @@ export interface SpinnerProps {
|
|
|
229
230
|
|
|
230
231
|
export interface TextFieldProps extends TextInputProps {
|
|
231
232
|
label?: string;
|
|
233
|
+
labelProps?: TypographyProps;
|
|
232
234
|
variant?: "outlined" | "text" | "contained";
|
|
233
235
|
color?: colorTypes;
|
|
234
236
|
size?: "small" | "normal" | "large";
|
|
@@ -251,12 +253,13 @@ export interface TextFieldProps extends TextInputProps {
|
|
|
251
253
|
}[];
|
|
252
254
|
onFocus?: () => void;
|
|
253
255
|
onBlur?: () => void;
|
|
256
|
+
selectMenuProps?: Partial<SelectMenuProps>;
|
|
254
257
|
}
|
|
255
258
|
|
|
256
259
|
export interface TypographyProps extends TextProps {
|
|
257
260
|
children: ReactNode;
|
|
258
261
|
color?: colorTypes | (string & {});
|
|
259
|
-
style?: TextStyle | ViewStyle
|
|
262
|
+
style?: StyleProp<TextStyle | ViewStyle>;
|
|
260
263
|
textCase?: "capitalize" | "uppercase" | "lowercase" | undefined;
|
|
261
264
|
variant?:
|
|
262
265
|
| "caption"
|
|
@@ -273,6 +276,7 @@ export interface TypographyProps extends TextProps {
|
|
|
273
276
|
numberOfLines?: number;
|
|
274
277
|
adjustsFontSizeToFit?: boolean;
|
|
275
278
|
fontFamily?: string;
|
|
279
|
+
fontSize?: number;
|
|
276
280
|
fontWeight?: 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
|
|
277
281
|
}
|
|
278
282
|
|
|
@@ -291,6 +295,8 @@ export interface SelectMenuProps {
|
|
|
291
295
|
label?: string;
|
|
292
296
|
secondary?: string;
|
|
293
297
|
helperText?: string;
|
|
298
|
+
searchEnabled?: boolean;
|
|
299
|
+
searchPlaceholder?: string;
|
|
294
300
|
}
|
|
295
301
|
|
|
296
302
|
export interface OTPInputProps {
|
package/src/utility.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { getConfig } from "./config/KeyManager";
|
|
2
|
+
|
|
3
|
+
export const getFontFamily = (
|
|
4
|
+
fontWeight: 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
|
|
5
|
+
) => {
|
|
6
|
+
return (
|
|
7
|
+
getConfig().TYPOGRAPHY?.fontWeights?.[fontWeight] ||
|
|
8
|
+
getConfig().TYPOGRAPHY?.fontFamily ||
|
|
9
|
+
undefined
|
|
10
|
+
);
|
|
11
|
+
};
|