@teamnhz/rn-ui-toolkit 1.0.1 → 1.0.3
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 +3 -2
- package/dist/assets/images/ic_calendar.png +0 -0
- package/dist/assets/images/ic_time.png +0 -0
- package/dist/components/BottomSheet/index.js +58 -2
- package/dist/components/Buttons/index.d.ts +2 -2
- package/dist/components/Buttons/index.js +102 -11
- package/dist/components/CheckBox/index.d.ts +2 -2
- package/dist/components/CheckBox/index.js +112 -15
- package/dist/components/DateTimePicker/index.d.ts +25 -3
- package/dist/components/DateTimePicker/index.js +248 -22
- package/dist/components/Dividers/index.d.ts +3 -3
- package/dist/components/Dividers/index.js +41 -5
- package/dist/components/HorizontalFlatList/index.d.ts +2 -2
- package/dist/components/HorizontalFlatList/index.js +47 -8
- package/dist/components/Image/index.d.ts +2 -4
- package/dist/components/Image/index.js +22 -4
- package/dist/components/ImagePicker/index.d.ts +8 -1
- package/dist/components/ImagePicker/index.js +154 -18
- package/dist/components/Input/index.d.ts +17 -3
- package/dist/components/Input/index.js +302 -19
- package/dist/components/KeyboardScroll/index.d.ts +3 -0
- package/dist/components/KeyboardScroll/index.js +76 -0
- package/dist/components/Modal/index.d.ts +2 -2
- package/dist/components/Modal/index.js +31 -3
- package/dist/components/Switch/index.d.ts +13 -3
- package/dist/components/Switch/index.js +93 -12
- package/dist/components/T/index.d.ts +5 -4
- package/dist/components/T/index.js +69 -10
- package/dist/components/Toast/index.js +123 -3
- package/dist/components/VerticalFlatList/index.d.ts +2 -2
- package/dist/components/VerticalFlatList/index.js +22 -5
- package/dist/components/index.d.ts +29 -29
- package/dist/components/index.js +29 -29
- package/dist/styles/colors.d.ts +1 -0
- package/dist/styles/colors.js +30 -29
- package/dist/styles/images.d.ts +2 -0
- package/dist/styles/images.js +5 -1
- package/package.json +20 -16
- package/dist/components/ScrolledContainer/index.d.ts +0 -13
- package/dist/components/ScrolledContainer/index.js +0 -30
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
|
|
3
|
+
const KeyboardScroll = (props) => {
|
|
4
|
+
return (React.createElement(KeyboardAwareScrollView, { showsVerticalScrollIndicator: false, keyboardShouldPersistTaps: "handled", bounces: false, enableAutomaticScroll: true, ...props }));
|
|
5
|
+
};
|
|
6
|
+
export default KeyboardScroll;
|
|
7
|
+
// import React from "react";
|
|
8
|
+
// import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
|
|
9
|
+
// const KeyboardScroll = (props: any) => {
|
|
10
|
+
// return (
|
|
11
|
+
// <KeyboardAwareScrollView
|
|
12
|
+
// showsVerticalScrollIndicator={false}
|
|
13
|
+
// keyboardShouldPersistTaps={"handled"}
|
|
14
|
+
// bounces={false}
|
|
15
|
+
// enableAutomaticScroll={true}
|
|
16
|
+
// {...props}
|
|
17
|
+
// ></KeyboardAwareScrollView>
|
|
18
|
+
// );
|
|
19
|
+
// };
|
|
20
|
+
// export default KeyboardScroll;
|
|
21
|
+
/////////////////////////////////////////////////////////////////////
|
|
22
|
+
// import React, { ReactNode } from 'react';
|
|
23
|
+
// import { StyleSheet, ViewStyle, Platform } from 'react-native';
|
|
24
|
+
// import { Edges, SafeAreaView } from 'react-native-safe-area-context';
|
|
25
|
+
// import { Colors, Scale } from '../../styles';
|
|
26
|
+
// import { ScrollView } from 'react-native';
|
|
27
|
+
// type ScrolledContainerProps = {
|
|
28
|
+
// children: ReactNode;
|
|
29
|
+
// containerStyle?: ViewStyle;
|
|
30
|
+
// safeEdgesTop?: boolean;
|
|
31
|
+
// safeEdgesBottom?: boolean;
|
|
32
|
+
// addPaddingTop?: boolean;
|
|
33
|
+
// scrollEnabled?: boolean; // in case you want to toggle scroll
|
|
34
|
+
// keyboardShouldPersistTaps?: 'always' | 'handled' | 'never';
|
|
35
|
+
// };
|
|
36
|
+
// const ScrolledContainer = ({
|
|
37
|
+
// containerStyle,
|
|
38
|
+
// children,
|
|
39
|
+
// safeEdgesTop,
|
|
40
|
+
// safeEdgesBottom,
|
|
41
|
+
// addPaddingTop,
|
|
42
|
+
// scrollEnabled = true,
|
|
43
|
+
// keyboardShouldPersistTaps = 'handled',
|
|
44
|
+
// }: ScrolledContainerProps) => {
|
|
45
|
+
// const edges: any = ['left', 'right'];
|
|
46
|
+
// if (safeEdgesTop) edges.push('top');
|
|
47
|
+
// if (safeEdgesBottom) edges.push('bottom');
|
|
48
|
+
// return (
|
|
49
|
+
// <SafeAreaView edges={edges} style={styles.globalSafeAreaStyle}>
|
|
50
|
+
// <ScrollView
|
|
51
|
+
// contentContainerStyle={[
|
|
52
|
+
// styles.screen,
|
|
53
|
+
// addPaddingTop && { paddingTop: Scale?.moderateScale(50) },
|
|
54
|
+
// containerStyle,
|
|
55
|
+
// ]}
|
|
56
|
+
// showsVerticalScrollIndicator={false}
|
|
57
|
+
// scrollEnabled={scrollEnabled}
|
|
58
|
+
// keyboardShouldPersistTaps={keyboardShouldPersistTaps}
|
|
59
|
+
// >
|
|
60
|
+
// {children}
|
|
61
|
+
// </ScrollView>
|
|
62
|
+
// </SafeAreaView>
|
|
63
|
+
// );
|
|
64
|
+
// };
|
|
65
|
+
// export default ScrolledContainer;
|
|
66
|
+
// const styles = StyleSheet.create({
|
|
67
|
+
// globalSafeAreaStyle: {
|
|
68
|
+
// flex: 1,
|
|
69
|
+
// backgroundColor: Colors.background,
|
|
70
|
+
// paddingBottom: Platform.OS === 'android' ? Scale?.moderateScale(10) : 0,
|
|
71
|
+
// },
|
|
72
|
+
// screen: {
|
|
73
|
+
// flexGrow: 1, // makes ScrollView expand & scroll
|
|
74
|
+
// paddingTop: Scale?.moderateScale(20),
|
|
75
|
+
// },
|
|
76
|
+
// });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { ReactNode } from
|
|
2
|
-
import { ModalProps } from
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import { ModalProps } from "react-native-modal";
|
|
3
3
|
type AppModalProps = Partial<ModalProps> & {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
closing: () => void;
|
|
@@ -1,5 +1,33 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import Modal from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Modal from "react-native-modal";
|
|
3
3
|
// Base Modal Component customized for app needs
|
|
4
|
-
const Modals = ({ children, closing, bkO = 0.5, ...props }) => (React.createElement(Modal, { backdropOpacity: bkO, animationInTiming: 400, animationOutTiming: 400, backdropTransitionOutTiming: 0, swipeDirection: [
|
|
4
|
+
const Modals = ({ children, closing, bkO = 0.5, ...props }) => (React.createElement(Modal, { backdropOpacity: bkO, animationInTiming: 400, animationOutTiming: 400, backdropTransitionOutTiming: 0, swipeDirection: ["down", "left", "right", "up"], onSwipeComplete: closing, onBackdropPress: closing, onBackButtonPress: closing, ...props }, children));
|
|
5
5
|
export default Modals;
|
|
6
|
+
// import React, { ReactNode } from 'react';
|
|
7
|
+
// import Modal, { ModalProps } from 'react-native-modal';
|
|
8
|
+
// type AppModalProps = Partial<ModalProps> & {
|
|
9
|
+
// children: ReactNode;
|
|
10
|
+
// closing: () => void;
|
|
11
|
+
// bkO?: number;
|
|
12
|
+
// };
|
|
13
|
+
// // Base Modal Component customized for app needs
|
|
14
|
+
// const Modals = ({
|
|
15
|
+
// children,
|
|
16
|
+
// closing,
|
|
17
|
+
// bkO = 0.5,
|
|
18
|
+
// ...props
|
|
19
|
+
// }: AppModalProps) => (
|
|
20
|
+
// <Modal
|
|
21
|
+
// backdropOpacity={bkO}
|
|
22
|
+
// animationInTiming={400}
|
|
23
|
+
// animationOutTiming={400}
|
|
24
|
+
// backdropTransitionOutTiming={0}
|
|
25
|
+
// swipeDirection={['down', 'left', 'right', 'up']}
|
|
26
|
+
// onSwipeComplete={closing}
|
|
27
|
+
// onBackdropPress={closing}
|
|
28
|
+
// onBackButtonPress={closing}
|
|
29
|
+
// {...props}>
|
|
30
|
+
// {children}
|
|
31
|
+
// </Modal>
|
|
32
|
+
// );
|
|
33
|
+
// export default Modals;
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyleProp, ViewStyle, ColorValue } from "react-native";
|
|
3
|
+
type SwitchUIProps = {
|
|
3
4
|
isEnabled?: boolean;
|
|
4
5
|
onValueChange?: (value: boolean) => void;
|
|
5
|
-
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
trackColor?: {
|
|
8
|
+
false?: ColorValue;
|
|
9
|
+
true?: ColorValue;
|
|
10
|
+
};
|
|
11
|
+
thumbColor?: ColorValue;
|
|
12
|
+
ios_backgroundColor?: ColorValue;
|
|
13
|
+
switchStyle?: StyleProp<ViewStyle>;
|
|
14
|
+
};
|
|
15
|
+
declare const SwitchUI: ({ isEnabled, onValueChange, disabled, trackColor, thumbColor, ios_backgroundColor, switchStyle, }: SwitchUIProps) => React.JSX.Element;
|
|
6
16
|
export default SwitchUI;
|
|
@@ -1,23 +1,104 @@
|
|
|
1
|
-
import React, { useState } from
|
|
2
|
-
import { View, Switch, StyleSheet } from
|
|
3
|
-
import { Colors } from
|
|
4
|
-
// Switch component
|
|
5
|
-
const SwitchUI = ({
|
|
1
|
+
// import React, { useState } from "react";
|
|
2
|
+
// import { View, Switch, StyleSheet } from "react-native";
|
|
3
|
+
// import { Colors } from "../../styles";
|
|
4
|
+
// // Switch component
|
|
5
|
+
// const SwitchUI = ({
|
|
6
|
+
// isEnabled,
|
|
7
|
+
// onValueChange,
|
|
8
|
+
// }: {
|
|
9
|
+
// isEnabled?: boolean;
|
|
10
|
+
// onValueChange?: (value: boolean) => void;
|
|
11
|
+
// }) => {
|
|
12
|
+
// const [internalState, setInternalState] = useState(isEnabled ?? false);
|
|
13
|
+
// const toggleSwitch = () => {
|
|
14
|
+
// setInternalState((prev) => !prev);
|
|
15
|
+
// onValueChange && onValueChange(!internalState);
|
|
16
|
+
// };
|
|
17
|
+
// const value = isEnabled ?? internalState;
|
|
18
|
+
// return (
|
|
19
|
+
// <View
|
|
20
|
+
// style={[
|
|
21
|
+
// styles.container,
|
|
22
|
+
// { borderColor: value ? Colors.primaryColor : Colors.disabledGrey },
|
|
23
|
+
// ]}
|
|
24
|
+
// >
|
|
25
|
+
// <Switch
|
|
26
|
+
// trackColor={{ false: Colors.textGrey, true: Colors.appThemeColor }}
|
|
27
|
+
// style={{ transform: [{ scaleX: 0.8 }, { scaleY: 0.8 }] }}
|
|
28
|
+
// thumbColor={value ? Colors.black : Colors.disabledGrey}
|
|
29
|
+
// onValueChange={toggleSwitch}
|
|
30
|
+
// value={value}
|
|
31
|
+
// />
|
|
32
|
+
// </View>
|
|
33
|
+
// );
|
|
34
|
+
// };
|
|
35
|
+
// const styles = StyleSheet.create({
|
|
36
|
+
// container: {
|
|
37
|
+
// flex: 1,
|
|
38
|
+
// },
|
|
39
|
+
// });
|
|
40
|
+
// export default SwitchUI;
|
|
41
|
+
import React, { useState } from "react";
|
|
42
|
+
import { View, Switch, StyleSheet, } from "react-native";
|
|
43
|
+
import { Colors } from "../../styles";
|
|
44
|
+
const SwitchUI = ({ isEnabled, onValueChange, disabled = false, trackColor = { false: Colors.textGrey, true: Colors.appThemeColor }, thumbColor, ios_backgroundColor = Colors.disabledGrey, switchStyle, }) => {
|
|
6
45
|
const [internalState, setInternalState] = useState(isEnabled ?? false);
|
|
7
46
|
const toggleSwitch = () => {
|
|
8
|
-
setInternalState(prev => !prev);
|
|
47
|
+
setInternalState((prev) => !prev);
|
|
9
48
|
onValueChange && onValueChange(!internalState);
|
|
10
49
|
};
|
|
11
50
|
const value = isEnabled ?? internalState;
|
|
12
|
-
return (React.createElement(View, { style:
|
|
13
|
-
|
|
14
|
-
{ borderColor: value ? Colors.primaryColor : Colors.disabledGrey },
|
|
15
|
-
] },
|
|
16
|
-
React.createElement(Switch, { trackColor: { false: 'grey', true: 'green' }, style: { transform: [{ scaleX: 0.8 }, { scaleY: 0.8 }] }, thumbColor: value ? Colors.primaryColor : Colors.disabledGrey, onValueChange: toggleSwitch, value: value })));
|
|
51
|
+
return (React.createElement(View, { style: styles.container },
|
|
52
|
+
React.createElement(Switch, { disabled: disabled, trackColor: trackColor, thumbColor: thumbColor ?? (value ? Colors.black : Colors.disabledGrey), ios_backgroundColor: ios_backgroundColor, style: [styles.switch, switchStyle], onValueChange: toggleSwitch, value: value })));
|
|
17
53
|
};
|
|
18
54
|
const styles = StyleSheet.create({
|
|
19
55
|
container: {
|
|
20
|
-
flex:
|
|
56
|
+
flex: 0,
|
|
57
|
+
alignItems: "center",
|
|
58
|
+
justifyContent: "center",
|
|
59
|
+
},
|
|
60
|
+
switch: {
|
|
61
|
+
transform: [{ scaleX: 1 }, { scaleY: 1 }], // default broad look
|
|
21
62
|
},
|
|
22
63
|
});
|
|
23
64
|
export default SwitchUI;
|
|
65
|
+
// import React, { useState } from "react";
|
|
66
|
+
// import { View, Switch, StyleSheet } from "react-native";
|
|
67
|
+
// import { Colors } from "../../styles";
|
|
68
|
+
// // Switch component
|
|
69
|
+
// const SwitchUI = ({
|
|
70
|
+
// isEnabled,
|
|
71
|
+
// onValueChange,
|
|
72
|
+
// }: {
|
|
73
|
+
// isEnabled?: boolean;
|
|
74
|
+
// onValueChange?: (value: boolean) => void;
|
|
75
|
+
// }) => {
|
|
76
|
+
// const [internalState, setInternalState] = useState(isEnabled ?? false);
|
|
77
|
+
// const toggleSwitch = () => {
|
|
78
|
+
// setInternalState((prev) => !prev);
|
|
79
|
+
// onValueChange && onValueChange(!internalState);
|
|
80
|
+
// };
|
|
81
|
+
// const value = isEnabled ?? internalState;
|
|
82
|
+
// return (
|
|
83
|
+
// <View
|
|
84
|
+
// style={[
|
|
85
|
+
// styles.container,
|
|
86
|
+
// { borderColor: value ? Colors.primaryColor : Colors.disabledGrey },
|
|
87
|
+
// ]}
|
|
88
|
+
// >
|
|
89
|
+
// <Switch
|
|
90
|
+
// trackColor={{ false: "grey", true: "green" }}
|
|
91
|
+
// style={{ transform: [{ scaleX: 0.8 }, { scaleY: 0.8 }] }}
|
|
92
|
+
// thumbColor={value ? Colors.primaryColor : Colors.disabledGrey}
|
|
93
|
+
// onValueChange={toggleSwitch}
|
|
94
|
+
// value={value}
|
|
95
|
+
// />
|
|
96
|
+
// </View>
|
|
97
|
+
// );
|
|
98
|
+
// };
|
|
99
|
+
// const styles = StyleSheet.create({
|
|
100
|
+
// container: {
|
|
101
|
+
// flex: 1,
|
|
102
|
+
// },
|
|
103
|
+
// });
|
|
104
|
+
// export default SwitchUI;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { TextProps, TextStyle } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TextProps, TextStyle } from "react-native";
|
|
3
3
|
type AppTextProps = TextProps & {
|
|
4
|
-
title
|
|
4
|
+
title?: string;
|
|
5
5
|
value?: string | number;
|
|
6
6
|
value2?: string | number;
|
|
7
7
|
value3?: string | number;
|
|
@@ -12,6 +12,7 @@ type AppTextProps = TextProps & {
|
|
|
12
12
|
isTime?: boolean;
|
|
13
13
|
isDate?: boolean;
|
|
14
14
|
reactComponent?: React.ReactNode;
|
|
15
|
+
children?: React.ReactNode;
|
|
15
16
|
};
|
|
16
|
-
declare const T: ({ title, value, value2, value3, intlType, textStyle, isTime, isDate, reactComponent, color, size, ...props }: AppTextProps) => React.JSX.Element;
|
|
17
|
+
declare const T: ({ title, value, value2, value3, intlType, textStyle, isTime, isDate, reactComponent, children, color, size, ...props }: AppTextProps) => React.JSX.Element;
|
|
17
18
|
export default T;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Text } from
|
|
3
|
-
import { useTranslation } from
|
|
4
|
-
import { Colors, Scale, Typography } from
|
|
5
|
-
const T = ({ title, value, value2, value3, intlType, textStyle, isTime, isDate, reactComponent, color = Colors.textColor, size = 14, ...props }) => {
|
|
6
|
-
const { t } = useTranslation([
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Text } from "react-native";
|
|
3
|
+
import { useTranslation } from "react-i18next";
|
|
4
|
+
import { Colors, Scale, Typography } from "../../styles";
|
|
5
|
+
const T = ({ title, value, value2, value3, intlType, textStyle, isTime, isDate, reactComponent, children, color = Colors.textColor, size = 14, ...props }) => {
|
|
6
|
+
const { t } = useTranslation(["common", "validation", "address"]);
|
|
7
7
|
const defaultStyles = {
|
|
8
8
|
color,
|
|
9
9
|
...Typography.style.standardU(),
|
|
@@ -12,9 +12,68 @@ const T = ({ title, value, value2, value3, intlType, textStyle, isTime, isDate,
|
|
|
12
12
|
const textStyles = Array.isArray(textStyle)
|
|
13
13
|
? [defaultStyles, ...textStyle]
|
|
14
14
|
: [defaultStyles, textStyle];
|
|
15
|
-
const renderText = () =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
const renderText = () => {
|
|
16
|
+
if (children)
|
|
17
|
+
return children; // ✅ children take priority
|
|
18
|
+
if (reactComponent)
|
|
19
|
+
return reactComponent;
|
|
20
|
+
if (isTime || isDate)
|
|
21
|
+
return title;
|
|
22
|
+
if (intlType)
|
|
23
|
+
return t(title || "", { ns: intlType, value, value2, value3 });
|
|
24
|
+
return t(title || "", { value, value2, value3 });
|
|
25
|
+
};
|
|
26
|
+
return (React.createElement(Text, { style: textStyles, ...props }, renderText()));
|
|
19
27
|
};
|
|
20
28
|
export default T;
|
|
29
|
+
// import React from 'react';
|
|
30
|
+
// import { Text, TextProps, TextStyle } from 'react-native';
|
|
31
|
+
// import { useTranslation } from 'react-i18next';
|
|
32
|
+
// import { Colors, Scale, Typography } from '../../styles';
|
|
33
|
+
// type AppTextProps = TextProps & {
|
|
34
|
+
// title: string;
|
|
35
|
+
// value?: string | number;
|
|
36
|
+
// value2?: string | number;
|
|
37
|
+
// value3?: string | number;
|
|
38
|
+
// intlType?: string;
|
|
39
|
+
// textStyle?: TextStyle | TextStyle[];
|
|
40
|
+
// color?: string;
|
|
41
|
+
// size?: number;
|
|
42
|
+
// isTime?: boolean;
|
|
43
|
+
// isDate?: boolean;
|
|
44
|
+
// reactComponent?: React.ReactNode;
|
|
45
|
+
// };
|
|
46
|
+
// const T = ({
|
|
47
|
+
// title,
|
|
48
|
+
// value,
|
|
49
|
+
// value2,
|
|
50
|
+
// value3,
|
|
51
|
+
// intlType,
|
|
52
|
+
// textStyle,
|
|
53
|
+
// isTime,
|
|
54
|
+
// isDate,
|
|
55
|
+
// reactComponent,
|
|
56
|
+
// color = Colors.textColor,
|
|
57
|
+
// size = 14,
|
|
58
|
+
// ...props
|
|
59
|
+
// }: AppTextProps) => {
|
|
60
|
+
// const { t } = useTranslation(['common', 'validation', 'address']);
|
|
61
|
+
// const defaultStyles = {
|
|
62
|
+
// color,
|
|
63
|
+
// ...Typography.style.standardU(),
|
|
64
|
+
// fontSize: Scale.moderateScale(size),
|
|
65
|
+
// };
|
|
66
|
+
// const textStyles = Array.isArray(textStyle)
|
|
67
|
+
// ? [defaultStyles, ...textStyle]
|
|
68
|
+
// : [defaultStyles, textStyle];
|
|
69
|
+
// const renderText = () =>
|
|
70
|
+
// intlType
|
|
71
|
+
// ? t(title, { ns: intlType, value, value2, value3 })
|
|
72
|
+
// : t(title, { value, value2, value3 });
|
|
73
|
+
// return (
|
|
74
|
+
// <Text style={textStyles} {...props}>
|
|
75
|
+
// {reactComponent || (isTime || isDate ? title : renderText())}
|
|
76
|
+
// </Text>
|
|
77
|
+
// );
|
|
78
|
+
// };
|
|
79
|
+
// export default T;
|
|
@@ -43,9 +43,7 @@ const Toast = ({ visible, message, duration = 2000, onHide, type = "info", posit
|
|
|
43
43
|
styles.toast,
|
|
44
44
|
{ backgroundColor: getBackgroundColor(), opacity: fadeAnim },
|
|
45
45
|
] },
|
|
46
|
-
icon && (React.createElement(View, { style: styles.iconWrapper }, typeof icon === "string" && icon.startsWith("http")
|
|
47
|
-
? React.createElement(Image, { source: { uri: icon }, style: styles.icon, resizeMode: "contain" })
|
|
48
|
-
: React.createElement(Image, { source: icon, style: styles.icon, resizeMode: "contain" }))),
|
|
46
|
+
icon && (React.createElement(View, { style: styles.iconWrapper }, typeof icon === "string" && icon.startsWith("http") ? (React.createElement(Image, { source: { uri: icon }, style: styles.icon, resizeMode: "contain" })) : (React.createElement(Image, { source: icon, style: styles.icon, resizeMode: "contain" })))),
|
|
49
47
|
React.createElement(Text, { style: styles.text }, message)))));
|
|
50
48
|
};
|
|
51
49
|
export default Toast;
|
|
@@ -82,3 +80,125 @@ const styles = StyleSheet.create({
|
|
|
82
80
|
resizeMode: "contain",
|
|
83
81
|
},
|
|
84
82
|
});
|
|
83
|
+
// import React, { useEffect, useRef } from "react";
|
|
84
|
+
// import {
|
|
85
|
+
// Modal,
|
|
86
|
+
// View,
|
|
87
|
+
// Text,
|
|
88
|
+
// StyleSheet,
|
|
89
|
+
// Animated,
|
|
90
|
+
// Image,
|
|
91
|
+
// ViewStyle,
|
|
92
|
+
// } from "react-native";
|
|
93
|
+
// import { Colors } from "../../styles";
|
|
94
|
+
// interface AppToastProps {
|
|
95
|
+
// visible: boolean;
|
|
96
|
+
// message: string;
|
|
97
|
+
// duration?: number; // in ms
|
|
98
|
+
// onHide: () => void;
|
|
99
|
+
// type?: "success" | "danger" | "warning" | "info" | "custom";
|
|
100
|
+
// position?: "top" | "bottom";
|
|
101
|
+
// customColor?: string;
|
|
102
|
+
// icon?: any; // Image source or React Node
|
|
103
|
+
// }
|
|
104
|
+
// const Toast: React.FC<AppToastProps> = ({
|
|
105
|
+
// visible,
|
|
106
|
+
// message,
|
|
107
|
+
// duration = 2000,
|
|
108
|
+
// onHide,
|
|
109
|
+
// type = "info",
|
|
110
|
+
// position = "top",
|
|
111
|
+
// customColor,
|
|
112
|
+
// icon,
|
|
113
|
+
// }) => {
|
|
114
|
+
// const fadeAnim = useRef(new Animated.Value(0)).current;
|
|
115
|
+
// const getBackgroundColor = () => {
|
|
116
|
+
// if (customColor) return customColor;
|
|
117
|
+
// switch (type) {
|
|
118
|
+
// case "success":
|
|
119
|
+
// return Colors.lightGreen || "green";
|
|
120
|
+
// case "danger":
|
|
121
|
+
// return Colors.dangerRed || "red";
|
|
122
|
+
// case "warning":
|
|
123
|
+
// return Colors.starGold || "orange";
|
|
124
|
+
// case "info":
|
|
125
|
+
// return Colors.primaryColor || "blue";
|
|
126
|
+
// default:
|
|
127
|
+
// return Colors.black;
|
|
128
|
+
// }
|
|
129
|
+
// };
|
|
130
|
+
// useEffect(() => {
|
|
131
|
+
// if (visible) {
|
|
132
|
+
// Animated.timing(fadeAnim, {
|
|
133
|
+
// toValue: 1,
|
|
134
|
+
// duration: 300,
|
|
135
|
+
// useNativeDriver: true,
|
|
136
|
+
// }).start();
|
|
137
|
+
// const timer = setTimeout(() => {
|
|
138
|
+
// onHide();
|
|
139
|
+
// }, duration);
|
|
140
|
+
// return () => clearTimeout(timer);
|
|
141
|
+
// }
|
|
142
|
+
// }, [visible]);
|
|
143
|
+
// const containerStyle: ViewStyle = {
|
|
144
|
+
// justifyContent: position === "top" ? "flex-start" : "flex-end",
|
|
145
|
+
// marginTop: position === "top" ? 20 : 0,
|
|
146
|
+
// marginBottom: position === "bottom" ? 60 : 0,
|
|
147
|
+
// };
|
|
148
|
+
// return (
|
|
149
|
+
// <Modal transparent visible={visible} animationType="fade">
|
|
150
|
+
// <View style={[styles.overlay, containerStyle]}>
|
|
151
|
+
// <Animated.View
|
|
152
|
+
// style={[
|
|
153
|
+
// styles.toast,
|
|
154
|
+
// { backgroundColor: getBackgroundColor(), opacity: fadeAnim },
|
|
155
|
+
// ]}
|
|
156
|
+
// >
|
|
157
|
+
// {icon && (
|
|
158
|
+
// <View style={styles.iconWrapper}>
|
|
159
|
+
// {typeof icon === "string" && icon.startsWith("http")
|
|
160
|
+
// ? <Image source={{ uri: icon }} style={styles.icon} resizeMode="contain" />
|
|
161
|
+
// : <Image source={icon} style={styles.icon} resizeMode="contain" />
|
|
162
|
+
// }
|
|
163
|
+
// </View>
|
|
164
|
+
// )}
|
|
165
|
+
// <Text style={styles.text}>{message}</Text>
|
|
166
|
+
// </Animated.View>
|
|
167
|
+
// </View>
|
|
168
|
+
// </Modal>
|
|
169
|
+
// );
|
|
170
|
+
// };
|
|
171
|
+
// export default Toast;
|
|
172
|
+
// const styles = StyleSheet.create({
|
|
173
|
+
// overlay: {
|
|
174
|
+
// flex: 1,
|
|
175
|
+
// alignItems: "center",
|
|
176
|
+
// },
|
|
177
|
+
// toast: {
|
|
178
|
+
// flexDirection: "row",
|
|
179
|
+
// alignItems: "center",
|
|
180
|
+
// paddingHorizontal: 16,
|
|
181
|
+
// paddingVertical: 12,
|
|
182
|
+
// borderRadius: 10,
|
|
183
|
+
// maxWidth: "90%",
|
|
184
|
+
// minWidth: "70%",
|
|
185
|
+
// shadowColor: "#000",
|
|
186
|
+
// shadowOffset: { width: 0, height: 2 },
|
|
187
|
+
// shadowOpacity: 0.3,
|
|
188
|
+
// shadowRadius: 3,
|
|
189
|
+
// elevation: 4,
|
|
190
|
+
// },
|
|
191
|
+
// text: {
|
|
192
|
+
// color: Colors.white,
|
|
193
|
+
// fontSize: 14,
|
|
194
|
+
// flexShrink: 1,
|
|
195
|
+
// },
|
|
196
|
+
// iconWrapper: {
|
|
197
|
+
// marginRight: 8,
|
|
198
|
+
// },
|
|
199
|
+
// icon: {
|
|
200
|
+
// width: 20,
|
|
201
|
+
// height: 20,
|
|
202
|
+
// resizeMode: "contain",
|
|
203
|
+
// },
|
|
204
|
+
// });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { FlatListProps } from "react-native";
|
|
2
|
+
import { FlatList, FlatListProps } from "react-native";
|
|
3
3
|
interface VerticalFlatListProps<ItemT> extends FlatListProps<ItemT> {
|
|
4
4
|
spacing?: number;
|
|
5
5
|
}
|
|
6
|
-
declare const VerticalFlatList: <
|
|
6
|
+
declare const VerticalFlatList: React.ForwardRefExoticComponent<VerticalFlatListProps<unknown> & React.RefAttributes<FlatList<unknown>>>;
|
|
7
7
|
export default VerticalFlatList;
|
|
@@ -1,6 +1,23 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { FlatList, View } from "react-native";
|
|
3
|
-
const VerticalFlatList = ({ spacing = 0, ...props }) => {
|
|
4
|
-
return (React.createElement(FlatList, { ...props, ItemSeparatorComponent: () => React.createElement(View, { style: { height: spacing } }), showsVerticalScrollIndicator: props.showsVerticalScrollIndicator ?? false }));
|
|
5
|
-
};
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import { FlatList, View, } from "react-native";
|
|
3
|
+
const VerticalFlatList = forwardRef(({ spacing = 0, ...props }, ref) => {
|
|
4
|
+
return (React.createElement(FlatList, { ...props, ref: ref, ItemSeparatorComponent: () => React.createElement(View, { style: { height: spacing } }), showsVerticalScrollIndicator: props.showsVerticalScrollIndicator ?? false }));
|
|
5
|
+
});
|
|
6
6
|
export default VerticalFlatList;
|
|
7
|
+
// import { FlatList, FlatListProps, View, StyleSheet } from "react-native";
|
|
8
|
+
// interface VerticalFlatListProps<ItemT> extends FlatListProps<ItemT> {
|
|
9
|
+
// spacing?: number; // extra control for spacing between items
|
|
10
|
+
// }
|
|
11
|
+
// const VerticalFlatList = <ItemT,>({
|
|
12
|
+
// spacing = 0,
|
|
13
|
+
// ...props
|
|
14
|
+
// }: VerticalFlatListProps<ItemT>) => {
|
|
15
|
+
// return (
|
|
16
|
+
// <FlatList
|
|
17
|
+
// {...props}
|
|
18
|
+
// ItemSeparatorComponent={() => <View style={{ height: spacing }} />}
|
|
19
|
+
// showsVerticalScrollIndicator={props.showsVerticalScrollIndicator ?? false}
|
|
20
|
+
// />
|
|
21
|
+
// );
|
|
22
|
+
// };
|
|
23
|
+
// export default VerticalFlatList;
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
export { default as Buttons } from
|
|
2
|
-
export { default as Container } from
|
|
3
|
-
export { default as Dividers } from
|
|
4
|
-
export { default as Image } from
|
|
5
|
-
export { default as Input } from
|
|
6
|
-
export { default as Modal } from
|
|
7
|
-
export { default as Spinner } from
|
|
8
|
-
export { default as T } from
|
|
9
|
-
export { default as FullSpinner } from
|
|
10
|
-
export { default as
|
|
11
|
-
export { default as MyStatusBar } from
|
|
12
|
-
export { default as Switch } from
|
|
13
|
-
export { default as DropDown } from
|
|
14
|
-
export { default as CheckBox } from
|
|
15
|
-
export { default as RadioButton } from
|
|
16
|
-
export { default as DateTimePicker } from
|
|
17
|
-
export { default as VProgressSteps } from
|
|
18
|
-
export { default as HProgressSteps } from
|
|
19
|
-
export { default as VStack } from
|
|
20
|
-
export { default as HStack } from
|
|
21
|
-
export { default as Accordion } from
|
|
22
|
-
export { default as VerticalFlatList } from
|
|
23
|
-
export { default as HorizontalFlatList } from
|
|
24
|
-
export { default as Toast } from
|
|
25
|
-
export { default as BottomSheet } from
|
|
26
|
-
export { default as ProgressBar } from
|
|
27
|
-
export { default as DocumentPicker } from
|
|
28
|
-
export { default as ImagePicker } from
|
|
29
|
-
export { default as AppHeader } from
|
|
1
|
+
export { default as Buttons } from "./Buttons";
|
|
2
|
+
export { default as Container } from "./Container";
|
|
3
|
+
export { default as Dividers } from "./Dividers";
|
|
4
|
+
export { default as Image } from "./Image";
|
|
5
|
+
export { default as Input } from "./Input";
|
|
6
|
+
export { default as Modal } from "./Modal";
|
|
7
|
+
export { default as Spinner } from "./Spinner";
|
|
8
|
+
export { default as T } from "./T";
|
|
9
|
+
export { default as FullSpinner } from "./FullSpinner";
|
|
10
|
+
export { default as KeyboardScroll } from "./KeyboardScroll";
|
|
11
|
+
export { default as MyStatusBar } from "./MyStatusBar";
|
|
12
|
+
export { default as Switch } from "./Switch";
|
|
13
|
+
export { default as DropDown } from "./DropDown";
|
|
14
|
+
export { default as CheckBox } from "./CheckBox";
|
|
15
|
+
export { default as RadioButton } from "./RadioButton";
|
|
16
|
+
export { default as DateTimePicker } from "./DateTimePicker";
|
|
17
|
+
export { default as VProgressSteps } from "./VProgressSteps";
|
|
18
|
+
export { default as HProgressSteps } from "./HProgressSteps";
|
|
19
|
+
export { default as VStack } from "./VStack";
|
|
20
|
+
export { default as HStack } from "./HStack";
|
|
21
|
+
export { default as Accordion } from "./Accordion";
|
|
22
|
+
export { default as VerticalFlatList } from "./VerticalFlatList";
|
|
23
|
+
export { default as HorizontalFlatList } from "./HorizontalFlatList";
|
|
24
|
+
export { default as Toast } from "./Toast";
|
|
25
|
+
export { default as BottomSheet } from "./BottomSheet";
|
|
26
|
+
export { default as ProgressBar } from "./ProgressBar";
|
|
27
|
+
export { default as DocumentPicker } from "./DocumentPicker";
|
|
28
|
+
export { default as ImagePicker } from "./ImagePicker";
|
|
29
|
+
export { default as AppHeader } from "./AppHeader";
|