@hoddy-ui/core 1.1.4 → 2.0.35
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 +155 -28
- 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 +7 -6
- package/package.json +7 -5
- package/src/Components/AlertX.tsx +4 -4
- package/src/Components/Animators/Animator.tsx +1 -1
- package/src/Components/Animators/hooks/useAppState.ts +4 -11
- package/src/Components/Animators/hooks/useBlinkAnimation.ts +31 -24
- package/src/Components/Animators/hooks/useFadeAnimation.ts +28 -26
- package/src/Components/Animators/hooks/useFloatAnimation.ts +67 -57
- package/src/Components/Animators/hooks/useGrowAnimation.ts +41 -28
- package/src/Components/Animators/hooks/useRollAnimation.ts +77 -57
- package/src/Components/Animators/hooks/useSlideAnimation.ts +44 -35
- package/src/Components/Animators/hooks/useThrownUpAnimation.ts +43 -50
- 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/OTPInput.tsx +0 -4
- package/src/Components/Popup.tsx +161 -83
- 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 +12 -3
- package/src/utility.ts +11 -0
- package/src/Components/Animators/README.md +0 -137
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { MaterialIcons } from "@expo/vector-icons";
|
|
2
2
|
import React, { useCallback, useState } from "react";
|
|
3
|
-
import { FlatList,
|
|
3
|
+
import { FlatList, TouchableOpacity, View } from "react-native";
|
|
4
4
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
5
5
|
import { ScaledSheet } from "react-native-size-matters";
|
|
6
6
|
import { useColors } from "../hooks";
|
|
7
7
|
import { SelectMenuProps } from "../types";
|
|
8
|
-
import
|
|
8
|
+
import { Popup } from "./Popup";
|
|
9
9
|
import TextField from "./TextField";
|
|
10
10
|
import Typography from "./Typography";
|
|
11
11
|
|
|
@@ -19,22 +19,15 @@ const SelectMenu: React.FC<SelectMenuProps> = ({
|
|
|
19
19
|
label,
|
|
20
20
|
secondary,
|
|
21
21
|
helperText,
|
|
22
|
+
searchEnabled = false,
|
|
23
|
+
searchPlaceholder = "Search",
|
|
22
24
|
}) => {
|
|
23
25
|
const colors = useColors();
|
|
24
26
|
const { bottom } = useSafeAreaInsets();
|
|
25
27
|
|
|
26
28
|
const [search, setSearch] = useState("");
|
|
27
29
|
const styles: any = ScaledSheet.create({
|
|
28
|
-
root: {
|
|
29
|
-
backgroundColor: colors.white[1],
|
|
30
|
-
flex: 1,
|
|
31
|
-
},
|
|
32
|
-
content: {
|
|
33
|
-
flex: 1,
|
|
34
|
-
paddingHorizontal: "10@ms",
|
|
35
|
-
},
|
|
36
30
|
header: {
|
|
37
|
-
paddingTop: "80@ms",
|
|
38
31
|
marginBottom: "20@vs",
|
|
39
32
|
},
|
|
40
33
|
|
|
@@ -46,11 +39,6 @@ const SelectMenu: React.FC<SelectMenuProps> = ({
|
|
|
46
39
|
alignItems: "center",
|
|
47
40
|
marginBottom: "10@vs",
|
|
48
41
|
},
|
|
49
|
-
footer: {
|
|
50
|
-
paddingBottom: bottom,
|
|
51
|
-
paddingHorizontal: "15@ms",
|
|
52
|
-
paddingTop: "15@ms",
|
|
53
|
-
},
|
|
54
42
|
});
|
|
55
43
|
|
|
56
44
|
const renderItem = useCallback(
|
|
@@ -70,6 +58,7 @@ const SelectMenu: React.FC<SelectMenuProps> = ({
|
|
|
70
58
|
{item.start && <View style={{ marginRight: 10 }}>{item.start}</View>}
|
|
71
59
|
<View style={{ flex: 1 }}>
|
|
72
60
|
<Typography
|
|
61
|
+
variant="body2"
|
|
73
62
|
style={{
|
|
74
63
|
color: item.value === value ? colors.blue.light : colors.black[2],
|
|
75
64
|
}}
|
|
@@ -102,51 +91,44 @@ const SelectMenu: React.FC<SelectMenuProps> = ({
|
|
|
102
91
|
[value, colors]
|
|
103
92
|
);
|
|
104
93
|
return (
|
|
105
|
-
<
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
94
|
+
<Popup
|
|
95
|
+
open={open}
|
|
96
|
+
onClose={onClose}
|
|
97
|
+
title={label}
|
|
98
|
+
disableAutoKeyboardManagement
|
|
99
|
+
>
|
|
100
|
+
<View style={styles.content}>
|
|
101
|
+
<View style={styles.header}>
|
|
102
|
+
{helperText && (
|
|
103
|
+
<Typography variant="body2" color="textSecondary" gutterBottom={5}>
|
|
104
|
+
{helperText}
|
|
111
105
|
</Typography>
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
{helperText}
|
|
115
|
-
</Typography>
|
|
116
|
-
) : null}
|
|
117
|
-
|
|
106
|
+
)}
|
|
107
|
+
{searchEnabled && (
|
|
118
108
|
<TextField
|
|
119
|
-
label=
|
|
109
|
+
label={searchPlaceholder}
|
|
120
110
|
value={search}
|
|
121
111
|
type="search"
|
|
122
112
|
onChangeText={setSearch}
|
|
123
113
|
variant="outlined"
|
|
124
114
|
/>
|
|
125
|
-
|
|
126
|
-
<FlatList
|
|
127
|
-
removeClippedSubviews
|
|
128
|
-
keyExtractor={(item) => item.value}
|
|
129
|
-
renderItem={renderItem}
|
|
130
|
-
data={options
|
|
131
|
-
.filter((item) =>
|
|
132
|
-
search.length > 1
|
|
133
|
-
? item.label.toLowerCase().indexOf(search.toLowerCase()) > -1
|
|
134
|
-
: item
|
|
135
|
-
)
|
|
136
|
-
.sort((a, b) => a.label.localeCompare(b.label))}
|
|
137
|
-
/>
|
|
138
|
-
</View>
|
|
139
|
-
<View style={styles.footer}>
|
|
140
|
-
<Button
|
|
141
|
-
color="error"
|
|
142
|
-
variant="outlined"
|
|
143
|
-
fullWidth
|
|
144
|
-
title="Close"
|
|
145
|
-
onPress={onClose}
|
|
146
|
-
/>
|
|
115
|
+
)}
|
|
147
116
|
</View>
|
|
117
|
+
<FlatList
|
|
118
|
+
removeClippedSubviews
|
|
119
|
+
keyExtractor={(item) => item.value}
|
|
120
|
+
bounces={false}
|
|
121
|
+
renderItem={renderItem}
|
|
122
|
+
data={options
|
|
123
|
+
.filter((item) =>
|
|
124
|
+
search.length > 1
|
|
125
|
+
? item.label.toLowerCase().indexOf(search.toLowerCase()) > -1
|
|
126
|
+
: item
|
|
127
|
+
)
|
|
128
|
+
.sort((a, b) => a.label.localeCompare(b.label))}
|
|
129
|
+
/>
|
|
148
130
|
</View>
|
|
149
|
-
</
|
|
131
|
+
</Popup>
|
|
150
132
|
);
|
|
151
133
|
};
|
|
152
134
|
|
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
ms,
|
|
8
8
|
verticalScale,
|
|
9
9
|
} from "react-native-size-matters";
|
|
10
|
-
import { getConfig } from "../config/KeyManager";
|
|
11
10
|
import { useColors } from "../hooks";
|
|
12
11
|
import { TextFieldProps } from "../types";
|
|
12
|
+
import { getFontFamily } from "../utility";
|
|
13
13
|
import SelectMenu from "./SelectMenu";
|
|
14
14
|
import Typography from "./Typography";
|
|
15
15
|
|
|
@@ -35,6 +35,7 @@ const TextField: React.FC<TextFieldProps> = ({
|
|
|
35
35
|
gutterBottom = 0,
|
|
36
36
|
end,
|
|
37
37
|
options,
|
|
38
|
+
selectMenuProps,
|
|
38
39
|
...props
|
|
39
40
|
}) => {
|
|
40
41
|
const colors = useColors();
|
|
@@ -64,7 +65,7 @@ const TextField: React.FC<TextFieldProps> = ({
|
|
|
64
65
|
}, [focused, value]);
|
|
65
66
|
const styles: any = ScaledSheet.create({
|
|
66
67
|
root: {
|
|
67
|
-
marginBottom: gutterBottom
|
|
68
|
+
marginBottom: ms(gutterBottom),
|
|
68
69
|
width: "100%",
|
|
69
70
|
...style,
|
|
70
71
|
},
|
|
@@ -98,7 +99,7 @@ const TextField: React.FC<TextFieldProps> = ({
|
|
|
98
99
|
paddingLeft: variant === "text" ? 0 : moderateScale(15),
|
|
99
100
|
paddingRight: moderateScale(10),
|
|
100
101
|
paddingTop: "11@vs",
|
|
101
|
-
fontFamily:
|
|
102
|
+
fontFamily: getFontFamily(400),
|
|
102
103
|
color: colors.black[1],
|
|
103
104
|
zIndex: 10,
|
|
104
105
|
// backgroundColor: "#284",
|
|
@@ -110,7 +111,7 @@ const TextField: React.FC<TextFieldProps> = ({
|
|
|
110
111
|
paddingTop: "13@ms",
|
|
111
112
|
},
|
|
112
113
|
label: {
|
|
113
|
-
fontFamily:
|
|
114
|
+
fontFamily: getFontFamily(400),
|
|
114
115
|
position: "absolute",
|
|
115
116
|
left: variant === "text" ? 0 : moderateScale(15),
|
|
116
117
|
fontSize: focused || value ? "10@s" : "13@s",
|
|
@@ -269,6 +270,7 @@ const TextField: React.FC<TextFieldProps> = ({
|
|
|
269
270
|
label={label}
|
|
270
271
|
helperText={helperText}
|
|
271
272
|
onChange={onChangeText!}
|
|
273
|
+
{...selectMenuProps}
|
|
272
274
|
/>
|
|
273
275
|
)}
|
|
274
276
|
</>
|
|
@@ -279,6 +281,7 @@ export const TextField2 = React.forwardRef<TextInput, TextFieldProps>(
|
|
|
279
281
|
(
|
|
280
282
|
{
|
|
281
283
|
label,
|
|
284
|
+
labelProps,
|
|
282
285
|
keyboardType,
|
|
283
286
|
color = "primary",
|
|
284
287
|
value,
|
|
@@ -299,6 +302,7 @@ export const TextField2 = React.forwardRef<TextInput, TextFieldProps>(
|
|
|
299
302
|
end,
|
|
300
303
|
options,
|
|
301
304
|
multiline,
|
|
305
|
+
selectMenuProps,
|
|
302
306
|
...props
|
|
303
307
|
},
|
|
304
308
|
ref
|
|
@@ -317,7 +321,7 @@ export const TextField2 = React.forwardRef<TextInput, TextFieldProps>(
|
|
|
317
321
|
|
|
318
322
|
const styles: any = ScaledSheet.create({
|
|
319
323
|
root: {
|
|
320
|
-
marginBottom: gutterBottom
|
|
324
|
+
marginBottom: ms(gutterBottom),
|
|
321
325
|
...style,
|
|
322
326
|
},
|
|
323
327
|
container: {
|
|
@@ -409,7 +413,12 @@ export const TextField2 = React.forwardRef<TextInput, TextFieldProps>(
|
|
|
409
413
|
<>
|
|
410
414
|
<View style={styles.root}>
|
|
411
415
|
{label && (
|
|
412
|
-
<Typography
|
|
416
|
+
<Typography
|
|
417
|
+
variant="body2"
|
|
418
|
+
color="textSecondary"
|
|
419
|
+
gutterBottom={7}
|
|
420
|
+
{...labelProps}
|
|
421
|
+
>
|
|
413
422
|
{label}
|
|
414
423
|
</Typography>
|
|
415
424
|
)}
|
|
@@ -509,6 +518,7 @@ export const TextField2 = React.forwardRef<TextInput, TextFieldProps>(
|
|
|
509
518
|
label={label}
|
|
510
519
|
helperText={helperText}
|
|
511
520
|
onChange={onChangeText!}
|
|
521
|
+
{...selectMenuProps}
|
|
512
522
|
/>
|
|
513
523
|
)}
|
|
514
524
|
</>
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
2
|
import { StyleSheet, Text } from "react-native";
|
|
3
|
-
import { moderateScale, verticalScale } from "react-native-size-matters";
|
|
3
|
+
import { moderateScale, ms, verticalScale } from "react-native-size-matters";
|
|
4
4
|
import { useColors } from "../hooks";
|
|
5
5
|
import { TypographyProps } from "../types";
|
|
6
6
|
import { getConfig } from "../config/KeyManager";
|
|
7
|
+
import { getFontFamily } from "../utility";
|
|
7
8
|
|
|
8
9
|
const Typography: React.FC<TypographyProps> = forwardRef(
|
|
9
10
|
(
|
|
@@ -11,40 +12,42 @@ const Typography: React.FC<TypographyProps> = forwardRef(
|
|
|
11
12
|
children,
|
|
12
13
|
color = "dark",
|
|
13
14
|
style = {},
|
|
14
|
-
textCase
|
|
15
|
+
textCase,
|
|
15
16
|
variant = "body1",
|
|
16
17
|
align = "left",
|
|
17
18
|
gutterBottom = 0,
|
|
18
19
|
adjustsFontSizeToFit,
|
|
19
20
|
fontWeight = 400,
|
|
20
21
|
fontFamily, // NEW PROP ADDED
|
|
22
|
+
fontSize,
|
|
21
23
|
...props
|
|
22
24
|
},
|
|
23
25
|
ref
|
|
24
26
|
) => {
|
|
25
27
|
const colors: any = useColors();
|
|
26
|
-
const
|
|
27
|
-
h1:
|
|
28
|
-
h2:
|
|
29
|
-
h3:
|
|
30
|
-
h4:
|
|
31
|
-
h5:
|
|
32
|
-
h6:
|
|
33
|
-
body1:
|
|
34
|
-
body2:
|
|
35
|
-
caption:
|
|
28
|
+
const _fontSize = {
|
|
29
|
+
h1: ms(42),
|
|
30
|
+
h2: ms(37),
|
|
31
|
+
h3: ms(32),
|
|
32
|
+
h4: ms(27),
|
|
33
|
+
h5: ms(22),
|
|
34
|
+
h6: ms(17),
|
|
35
|
+
body1: ms(15),
|
|
36
|
+
body2: ms(12),
|
|
37
|
+
caption: ms(10),
|
|
36
38
|
};
|
|
37
|
-
|
|
39
|
+
const f = fontSize || _fontSize[variant];
|
|
38
40
|
const styles: any = StyleSheet.create({
|
|
39
41
|
text: {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
lineHeight: f * 1.2,
|
|
43
|
+
fontSize: f,
|
|
44
|
+
marginBottom: ms(gutterBottom) || 0,
|
|
42
45
|
color: colors[color]?.main || color,
|
|
43
46
|
textTransform: textCase,
|
|
44
47
|
alignItems: "center",
|
|
45
48
|
textAlign: align,
|
|
46
49
|
fontWeight: fontWeight,
|
|
47
|
-
fontFamily: fontFamily ||
|
|
50
|
+
fontFamily: fontFamily || getFontFamily(fontWeight),
|
|
48
51
|
},
|
|
49
52
|
});
|
|
50
53
|
|
package/src/config/KeyManager.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
type configTypes = {
|
|
2
2
|
GOOGLE_MAP_API_KEY?: string;
|
|
3
|
-
|
|
3
|
+
TYPOGRAPHY?: {
|
|
4
|
+
fontFamily?: string;
|
|
5
|
+
fontWeights?: {
|
|
6
|
+
[K in 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900]?: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
4
9
|
EDGE_TO_EDGE?: boolean;
|
|
5
10
|
};
|
|
6
11
|
|
package/src/config/index.ts
CHANGED
|
@@ -3,18 +3,53 @@ import { setExtraColors } from "../theme/colors";
|
|
|
3
3
|
import { extraColorTypes } from "../types";
|
|
4
4
|
import { setConfig } from "./KeyManager";
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Configuration options for the Hoddy UI library
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* initialize({
|
|
12
|
+
* googleMapApiKey: "AIzaSyBxxxxxxxxxxxxxxxxxxxxxx",
|
|
13
|
+
* edgeToEdge: true,
|
|
14
|
+
* colors: {
|
|
15
|
+
* primary: "#007AFF",
|
|
16
|
+
* secondary: "#34C759"
|
|
17
|
+
* },
|
|
18
|
+
* typography: {
|
|
19
|
+
* fontFamily: "Inter",
|
|
20
|
+
* fontWeights: {
|
|
21
|
+
* 400: "Inter-Regular",
|
|
22
|
+
* 500: "Inter-Medium",
|
|
23
|
+
* 600: "Inter-SemiBold",
|
|
24
|
+
* 700: "Inter-Bold"
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
6
30
|
type configProps = {
|
|
31
|
+
/** Google Maps API key for map components */
|
|
7
32
|
googleMapApiKey?: string;
|
|
33
|
+
/** Custom color palette overrides */
|
|
8
34
|
colors?: extraColorTypes;
|
|
9
|
-
|
|
35
|
+
/** Enable edge-to-edge display mode */
|
|
10
36
|
edgeToEdge?: boolean;
|
|
37
|
+
/** Typography settings */
|
|
38
|
+
typography?: {
|
|
39
|
+
/** Primary font family */
|
|
40
|
+
fontFamily?: string;
|
|
41
|
+
/** Font family mappings for each weight (Android support) */
|
|
42
|
+
fontWeights?: {
|
|
43
|
+
[K in 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900]?: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
11
46
|
};
|
|
12
47
|
|
|
13
48
|
export function initialize(config: configProps): void {
|
|
14
49
|
try {
|
|
15
50
|
setConfig({
|
|
16
51
|
GOOGLE_MAP_API_KEY: config.googleMapApiKey,
|
|
17
|
-
|
|
52
|
+
TYPOGRAPHY: config.typography,
|
|
18
53
|
EDGE_TO_EDGE: config.edgeToEdge ?? false,
|
|
19
54
|
});
|
|
20
55
|
if (config.colors) setExtraColors(config.colors);
|
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,6 +215,9 @@ export interface PopupProps {
|
|
|
214
215
|
open: boolean;
|
|
215
216
|
onClose?: () => void;
|
|
216
217
|
style?: ViewStyle;
|
|
218
|
+
disableAutoKeyboardManagement?: boolean;
|
|
219
|
+
onModalShow?: () => void;
|
|
220
|
+
onModalHide?: () => void;
|
|
217
221
|
}
|
|
218
222
|
|
|
219
223
|
export interface SpinnerProps {
|
|
@@ -226,6 +230,7 @@ export interface SpinnerProps {
|
|
|
226
230
|
|
|
227
231
|
export interface TextFieldProps extends TextInputProps {
|
|
228
232
|
label?: string;
|
|
233
|
+
labelProps?: TypographyProps;
|
|
229
234
|
variant?: "outlined" | "text" | "contained";
|
|
230
235
|
color?: colorTypes;
|
|
231
236
|
size?: "small" | "normal" | "large";
|
|
@@ -248,12 +253,13 @@ export interface TextFieldProps extends TextInputProps {
|
|
|
248
253
|
}[];
|
|
249
254
|
onFocus?: () => void;
|
|
250
255
|
onBlur?: () => void;
|
|
256
|
+
selectMenuProps?: Partial<SelectMenuProps>;
|
|
251
257
|
}
|
|
252
258
|
|
|
253
259
|
export interface TypographyProps extends TextProps {
|
|
254
260
|
children: ReactNode;
|
|
255
261
|
color?: colorTypes | (string & {});
|
|
256
|
-
style?: TextStyle | ViewStyle
|
|
262
|
+
style?: StyleProp<TextStyle | ViewStyle>;
|
|
257
263
|
textCase?: "capitalize" | "uppercase" | "lowercase" | undefined;
|
|
258
264
|
variant?:
|
|
259
265
|
| "caption"
|
|
@@ -270,6 +276,7 @@ export interface TypographyProps extends TextProps {
|
|
|
270
276
|
numberOfLines?: number;
|
|
271
277
|
adjustsFontSizeToFit?: boolean;
|
|
272
278
|
fontFamily?: string;
|
|
279
|
+
fontSize?: number;
|
|
273
280
|
fontWeight?: 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
|
|
274
281
|
}
|
|
275
282
|
|
|
@@ -288,6 +295,8 @@ export interface SelectMenuProps {
|
|
|
288
295
|
label?: string;
|
|
289
296
|
secondary?: string;
|
|
290
297
|
helperText?: string;
|
|
298
|
+
searchEnabled?: boolean;
|
|
299
|
+
searchPlaceholder?: string;
|
|
291
300
|
}
|
|
292
301
|
|
|
293
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
|
+
};
|