@momo-kits/foundation 1.0.7 → 1.0.9
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/Consts/styles.ts +0 -59
- package/Consts/theme.ts +4 -4
- package/Icon/index.tsx +1 -1
- package/Input/SearchInput.tsx +28 -30
- package/Input/styles.ts +1 -2
- package/Navigation/Components.tsx +125 -11
- package/Navigation/ModalScreen.tsx +67 -66
- package/Navigation/NavigationButton.tsx +20 -5
- package/Navigation/Navigator.ts +2 -2
- package/Navigation/types.ts +9 -3
- package/Navigation/utils.tsx +19 -35
- package/Popup/PopupNotify.tsx +4 -1
- package/Text/index.tsx +19 -1
- package/index.ts +1 -3
- package/package.json +1 -1
- package/Playground/index.tsx +0 -249
- package/Playground/styles.ts +0 -16
- package/Playground/types.ts +0 -16
- /package/{Icon → Assets}/icon.json +0 -0
package/Consts/styles.ts
CHANGED
|
@@ -47,38 +47,6 @@ const Styles = StyleSheet.create({
|
|
|
47
47
|
alignItems: 'flex-end',
|
|
48
48
|
justifyContent: 'center',
|
|
49
49
|
},
|
|
50
|
-
//padding
|
|
51
|
-
padding4: {
|
|
52
|
-
padding: 4,
|
|
53
|
-
},
|
|
54
|
-
padding8: {
|
|
55
|
-
padding: 8,
|
|
56
|
-
},
|
|
57
|
-
padding16: {
|
|
58
|
-
padding: 16,
|
|
59
|
-
},
|
|
60
|
-
padding24: {
|
|
61
|
-
padding: 24,
|
|
62
|
-
},
|
|
63
|
-
padding32: {
|
|
64
|
-
padding: 32,
|
|
65
|
-
},
|
|
66
|
-
//margin
|
|
67
|
-
margin4: {
|
|
68
|
-
margin: 4,
|
|
69
|
-
},
|
|
70
|
-
margin8: {
|
|
71
|
-
margin: 8,
|
|
72
|
-
},
|
|
73
|
-
margin16: {
|
|
74
|
-
margin: 16,
|
|
75
|
-
},
|
|
76
|
-
margin24: {
|
|
77
|
-
margin: 24,
|
|
78
|
-
},
|
|
79
|
-
margin32: {
|
|
80
|
-
margin: 32,
|
|
81
|
-
},
|
|
82
50
|
//paddingHorizontal
|
|
83
51
|
paddingHorizontal4: {
|
|
84
52
|
paddingHorizontal: 4,
|
|
@@ -105,33 +73,6 @@ const Styles = StyleSheet.create({
|
|
|
105
73
|
paddingVertical24: {
|
|
106
74
|
paddingVertical: 24,
|
|
107
75
|
},
|
|
108
|
-
//button
|
|
109
|
-
buttonContent: {
|
|
110
|
-
paddingHorizontal: 16,
|
|
111
|
-
paddingVertical: 8,
|
|
112
|
-
flexDirection: 'row',
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
headerRightButton: {
|
|
116
|
-
flexDirection: 'row',
|
|
117
|
-
overflow: 'hidden',
|
|
118
|
-
justifyContent: 'center',
|
|
119
|
-
alignItems: 'center',
|
|
120
|
-
paddingHorizontal: 4,
|
|
121
|
-
},
|
|
122
|
-
//text
|
|
123
|
-
textCenter: {textAlign: 'center'},
|
|
124
|
-
//card
|
|
125
|
-
card: {
|
|
126
|
-
shadowColor: 'gray',
|
|
127
|
-
shadowOffset: {
|
|
128
|
-
width: 1,
|
|
129
|
-
height: 1,
|
|
130
|
-
},
|
|
131
|
-
shadowOpacity: 0.3,
|
|
132
|
-
shadowRadius: 4,
|
|
133
|
-
elevation: 4,
|
|
134
|
-
},
|
|
135
76
|
});
|
|
136
77
|
|
|
137
78
|
export {Styles};
|
package/Consts/theme.ts
CHANGED
|
@@ -60,14 +60,14 @@ const defaultTheme: Theme = {
|
|
|
60
60
|
const defaultDarkTheme: Theme = {
|
|
61
61
|
dark: true,
|
|
62
62
|
colors: {
|
|
63
|
-
primary:
|
|
64
|
-
secondary:
|
|
63
|
+
primary: Colors.pink_04,
|
|
64
|
+
secondary: Colors.pink_08,
|
|
65
65
|
background: {
|
|
66
66
|
default: '#121212', // Dark background
|
|
67
67
|
surface: '#1e1e1e', // Slightly lighter surface background
|
|
68
|
-
tonal:
|
|
68
|
+
tonal: Colors.pink_10,
|
|
69
69
|
pressed: '#1a1a1a', // Pressed state background
|
|
70
|
-
selected:
|
|
70
|
+
selected: Colors.pink_11,
|
|
71
71
|
disable: '#303030', // Disabled state background
|
|
72
72
|
},
|
|
73
73
|
text: {
|
package/Icon/index.tsx
CHANGED
package/Input/SearchInput.tsx
CHANGED
|
@@ -25,8 +25,9 @@ const SearchInput: FC<SearchInputProps> = ({
|
|
|
25
25
|
onChangeText,
|
|
26
26
|
icon,
|
|
27
27
|
buttonText = 'Hủy',
|
|
28
|
-
showButtonText,
|
|
28
|
+
showButtonText = true,
|
|
29
29
|
showIcon = true,
|
|
30
|
+
style,
|
|
30
31
|
...props
|
|
31
32
|
}) => {
|
|
32
33
|
const {theme} = useContext(ApplicationContext);
|
|
@@ -63,32 +64,25 @@ const SearchInput: FC<SearchInputProps> = ({
|
|
|
63
64
|
iconTintColor = disabledColor;
|
|
64
65
|
}
|
|
65
66
|
return (
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
{
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
onFocus={_onFocus}
|
|
86
|
-
onBlur={_onBlur}
|
|
87
|
-
placeholder={placeholder}
|
|
88
|
-
selectionColor={theme.colors.primary}
|
|
89
|
-
placeholderTextColor={placeholderColor}
|
|
90
|
-
/>
|
|
91
|
-
</View>
|
|
67
|
+
<TextInput
|
|
68
|
+
{...props}
|
|
69
|
+
editable={!disabled}
|
|
70
|
+
textAlignVertical="top"
|
|
71
|
+
ref={inputRef}
|
|
72
|
+
style={[
|
|
73
|
+
styles.searchInput,
|
|
74
|
+
{
|
|
75
|
+
color: textColor,
|
|
76
|
+
},
|
|
77
|
+
]}
|
|
78
|
+
value={value}
|
|
79
|
+
onChangeText={_onChangeText}
|
|
80
|
+
onFocus={_onFocus}
|
|
81
|
+
onBlur={_onBlur}
|
|
82
|
+
placeholder={placeholder}
|
|
83
|
+
selectionColor={theme.colors.primary}
|
|
84
|
+
placeholderTextColor={placeholderColor}
|
|
85
|
+
/>
|
|
92
86
|
);
|
|
93
87
|
};
|
|
94
88
|
|
|
@@ -108,7 +102,7 @@ const SearchInput: FC<SearchInputProps> = ({
|
|
|
108
102
|
</TouchableOpacity>
|
|
109
103
|
)}
|
|
110
104
|
{showIcon && icon && (
|
|
111
|
-
<View>
|
|
105
|
+
<View style={{flexDirection: 'row'}}>
|
|
112
106
|
<View
|
|
113
107
|
style={[
|
|
114
108
|
styles.divider,
|
|
@@ -117,7 +111,6 @@ const SearchInput: FC<SearchInputProps> = ({
|
|
|
117
111
|
},
|
|
118
112
|
]}
|
|
119
113
|
/>
|
|
120
|
-
|
|
121
114
|
<Image
|
|
122
115
|
tintColor={iconTintColor}
|
|
123
116
|
source={{uri: icon}}
|
|
@@ -129,13 +122,18 @@ const SearchInput: FC<SearchInputProps> = ({
|
|
|
129
122
|
);
|
|
130
123
|
};
|
|
131
124
|
return (
|
|
132
|
-
<View style={styles.searchInputContainer}>
|
|
125
|
+
<View style={[style, styles.searchInputContainer]}>
|
|
133
126
|
<View
|
|
134
127
|
style={[
|
|
135
128
|
getBorderColor(focused, errorMessage, disabled),
|
|
136
129
|
styles.searchInputWrapper,
|
|
137
130
|
{backgroundColor: theme.colors.background.surface},
|
|
138
131
|
]}>
|
|
132
|
+
<Icon
|
|
133
|
+
source={'navigation_search'}
|
|
134
|
+
size={24}
|
|
135
|
+
color={theme.colors.text.hint}
|
|
136
|
+
/>
|
|
139
137
|
{renderInputView()}
|
|
140
138
|
{renderIconView()}
|
|
141
139
|
</View>
|
package/Input/styles.ts
CHANGED
|
@@ -96,12 +96,11 @@ export default StyleSheet.create({
|
|
|
96
96
|
flex: 1,
|
|
97
97
|
},
|
|
98
98
|
searchInput: {
|
|
99
|
-
width: '100%',
|
|
100
99
|
height: 36,
|
|
101
100
|
marginLeft: Spacing.S,
|
|
101
|
+
flex: 1,
|
|
102
102
|
},
|
|
103
103
|
searchInputView: {
|
|
104
|
-
flex: 1,
|
|
105
104
|
flexDirection: 'row',
|
|
106
105
|
alignItems: 'center',
|
|
107
106
|
},
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import React, {useContext} from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
DeviceEventEmitter,
|
|
4
|
+
StatusBar,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
View,
|
|
8
|
+
} from 'react-native';
|
|
3
9
|
import {ApplicationContext, NavigationButton} from './index';
|
|
4
|
-
import {Colors, Styles} from '../Consts';
|
|
10
|
+
import {Colors, Spacing, Styles} from '../Consts';
|
|
5
11
|
import {Image} from '../Image';
|
|
6
12
|
import {HeaderBackgroundProps, TitleCustomProps} from './types';
|
|
7
13
|
import {useGridSystem} from '../Layout';
|
|
8
14
|
import {Text} from '../Text';
|
|
15
|
+
import {Icon} from '../Icon';
|
|
9
16
|
|
|
10
17
|
const styles = StyleSheet.create({
|
|
11
18
|
headerBackground: {
|
|
@@ -29,10 +36,47 @@ const styles = StyleSheet.create({
|
|
|
29
36
|
borderWidth: 1,
|
|
30
37
|
borderColor: Colors.black_01,
|
|
31
38
|
},
|
|
39
|
+
headerRightButton: {
|
|
40
|
+
flexDirection: 'row',
|
|
41
|
+
overflow: 'hidden',
|
|
42
|
+
justifyContent: 'center',
|
|
43
|
+
alignItems: 'center',
|
|
44
|
+
paddingRight: Spacing.M,
|
|
45
|
+
},
|
|
46
|
+
toolkitContainer: {
|
|
47
|
+
marginLeft: Spacing.S,
|
|
48
|
+
padding: Spacing.XS,
|
|
49
|
+
height: 28,
|
|
50
|
+
borderWidth: 0.5,
|
|
51
|
+
borderRadius: 14,
|
|
52
|
+
borderColor: '#00000066',
|
|
53
|
+
justifyContent: 'center',
|
|
54
|
+
alignItems: 'center',
|
|
55
|
+
flexDirection: 'row',
|
|
56
|
+
},
|
|
57
|
+
divider: {
|
|
58
|
+
width: 1,
|
|
59
|
+
height: 12,
|
|
60
|
+
marginHorizontal: 4,
|
|
61
|
+
},
|
|
62
|
+
headerLeft: {
|
|
63
|
+
marginLeft: 12,
|
|
64
|
+
},
|
|
32
65
|
});
|
|
33
66
|
|
|
34
|
-
const
|
|
35
|
-
|
|
67
|
+
const HeaderTitle = (props: any) => {
|
|
68
|
+
return (
|
|
69
|
+
<Text
|
|
70
|
+
{...props}
|
|
71
|
+
typography="header_default"
|
|
72
|
+
weight="bold"
|
|
73
|
+
color={props.tintColor}
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const HeaderLeft: React.FC<any> = ({tintColor}) => {
|
|
79
|
+
const {theme, navigator} = useContext(ApplicationContext);
|
|
36
80
|
const goBack = () => {
|
|
37
81
|
const canGoBack = navigator?.ref.current?.canGoBack();
|
|
38
82
|
if (canGoBack) {
|
|
@@ -43,21 +87,48 @@ const HeaderLeft = (props: any) => {
|
|
|
43
87
|
DeviceEventEmitter.emit('dismiss', {requestId});
|
|
44
88
|
}
|
|
45
89
|
};
|
|
46
|
-
|
|
90
|
+
|
|
91
|
+
let backgroundColor;
|
|
92
|
+
if (tintColor != Colors.black_01) {
|
|
93
|
+
backgroundColor = theme.colors.background.surface;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<View style={styles.headerLeft}>
|
|
98
|
+
<NavigationButton
|
|
99
|
+
icon="ic_back"
|
|
100
|
+
tintColor={tintColor}
|
|
101
|
+
backgroundColor={backgroundColor}
|
|
102
|
+
onPress={goBack}
|
|
103
|
+
/>
|
|
104
|
+
</View>
|
|
105
|
+
);
|
|
47
106
|
};
|
|
48
107
|
|
|
49
|
-
const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
|
|
108
|
+
const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
|
|
109
|
+
image,
|
|
110
|
+
backgroundColor,
|
|
111
|
+
}) => {
|
|
50
112
|
const {theme} = useContext(ApplicationContext);
|
|
113
|
+
let headerImage = theme.assets?.headerBackground;
|
|
114
|
+
if (image === null) {
|
|
115
|
+
headerImage = undefined;
|
|
116
|
+
}
|
|
51
117
|
return (
|
|
52
118
|
<View
|
|
53
119
|
style={[
|
|
54
120
|
Styles.flex,
|
|
55
|
-
{
|
|
121
|
+
{
|
|
122
|
+
backgroundColor: backgroundColor ?? theme.colors.background.default,
|
|
123
|
+
overflow: 'hidden',
|
|
124
|
+
},
|
|
56
125
|
]}>
|
|
57
126
|
<StatusBar
|
|
58
|
-
barStyle={
|
|
127
|
+
barStyle={headerImage || theme.dark ? 'light-content' : 'dark-content'}
|
|
59
128
|
/>
|
|
60
|
-
{
|
|
129
|
+
{headerImage && (
|
|
130
|
+
<Image style={styles.headerBackground} source={{uri: headerImage}} />
|
|
131
|
+
)}
|
|
61
132
|
</View>
|
|
62
133
|
);
|
|
63
134
|
};
|
|
@@ -120,7 +191,50 @@ const HeaderRightAction: React.FC<any> = ({children, ...restProps}) => {
|
|
|
120
191
|
validType(children);
|
|
121
192
|
return React.cloneElement(children, {...restProps});
|
|
122
193
|
};
|
|
123
|
-
return <View style={
|
|
194
|
+
return <View style={styles.headerRightButton}>{renderAction()}</View>;
|
|
124
195
|
};
|
|
125
196
|
|
|
126
|
-
|
|
197
|
+
const HeaderToolkitAction: React.FC<any> = ({tintColor}) => {
|
|
198
|
+
const {theme} = useContext(ApplicationContext);
|
|
199
|
+
let backgroundColor;
|
|
200
|
+
if (tintColor != Colors.black_01) {
|
|
201
|
+
backgroundColor = theme.colors.background.surface;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return (
|
|
205
|
+
<View style={styles.headerRightButton}>
|
|
206
|
+
<NavigationButton
|
|
207
|
+
icon="addFavorite"
|
|
208
|
+
tintColor={tintColor}
|
|
209
|
+
backgroundColor={backgroundColor}
|
|
210
|
+
onPress={() => {}}
|
|
211
|
+
/>
|
|
212
|
+
<View
|
|
213
|
+
style={[
|
|
214
|
+
styles.toolkitContainer,
|
|
215
|
+
{backgroundColor: backgroundColor ?? '#00000066'},
|
|
216
|
+
]}>
|
|
217
|
+
<TouchableOpacity>
|
|
218
|
+
<Icon color={tintColor} source="navigation_more_horiz" size={20} />
|
|
219
|
+
</TouchableOpacity>
|
|
220
|
+
<View style={[styles.divider, {backgroundColor: tintColor}]} />
|
|
221
|
+
<TouchableOpacity>
|
|
222
|
+
<Icon
|
|
223
|
+
color={tintColor}
|
|
224
|
+
source="16_navigation_close_circle"
|
|
225
|
+
size={20}
|
|
226
|
+
/>
|
|
227
|
+
</TouchableOpacity>
|
|
228
|
+
</View>
|
|
229
|
+
</View>
|
|
230
|
+
);
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
export {
|
|
234
|
+
HeaderTitle,
|
|
235
|
+
HeaderLeft,
|
|
236
|
+
HeaderBackground,
|
|
237
|
+
HeaderRightAction,
|
|
238
|
+
HeaderToolkitAction,
|
|
239
|
+
HeaderCustom,
|
|
240
|
+
};
|
|
@@ -10,7 +10,7 @@ import {SafeAreaView, useSafeAreaInsets} from 'react-native-safe-area-context';
|
|
|
10
10
|
import {BottomSheetBackdrop, BottomSheetModal} from '@gorhom/bottom-sheet';
|
|
11
11
|
import {BottomSheetModalMethods} from '@gorhom/bottom-sheet/lib/typescript/types';
|
|
12
12
|
import Navigation from './Navigation';
|
|
13
|
-
import {ModalParams} from './types';
|
|
13
|
+
import {BottomSheetParams, ModalParams} from './types';
|
|
14
14
|
import {Radius, Spacing, Styles} from '../Consts';
|
|
15
15
|
import {
|
|
16
16
|
ApplicationContext,
|
|
@@ -19,15 +19,22 @@ import {
|
|
|
19
19
|
NavigationContainer,
|
|
20
20
|
} from './index';
|
|
21
21
|
|
|
22
|
-
const ModalScreen: React.FC<
|
|
22
|
+
const ModalScreen: React.FC<any> = props => {
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
return () => {
|
|
25
|
+
props.route.params?.onDismiss?.();
|
|
26
|
+
};
|
|
27
|
+
}, []);
|
|
28
|
+
|
|
29
|
+
if (props.route?.params?.isBottomSheet) {
|
|
30
|
+
return <BottomSheet {...props} />;
|
|
31
|
+
}
|
|
32
|
+
return <Modal {...props} />;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const Modal: React.FC<ModalParams> = ({navigation, route}) => {
|
|
23
36
|
const {theme} = useContext(ApplicationContext);
|
|
24
|
-
const {
|
|
25
|
-
isBottomSheet,
|
|
26
|
-
backgroundColor,
|
|
27
|
-
screen,
|
|
28
|
-
barrierDismissible,
|
|
29
|
-
options,
|
|
30
|
-
}: ModalParams = route.params;
|
|
37
|
+
const {screen, barrierDismissible}: ModalParams = route.params;
|
|
31
38
|
const Component = useRef(screen).current;
|
|
32
39
|
const params = {
|
|
33
40
|
...route.params,
|
|
@@ -35,61 +42,13 @@ const ModalScreen: React.FC<ModalParams> = ({navigation, route, ...rest}) => {
|
|
|
35
42
|
};
|
|
36
43
|
delete params.screen;
|
|
37
44
|
|
|
38
|
-
/**
|
|
39
|
-
* onDismiss modal
|
|
40
|
-
*/
|
|
41
45
|
const onDismiss = (pop = true) => {
|
|
42
|
-
|
|
43
|
-
if (!pop) {
|
|
44
|
-
action = () => {};
|
|
45
|
-
}
|
|
46
|
-
if (barrierDismissible && !isBottomSheet) {
|
|
46
|
+
if (barrierDismissible) {
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
action();
|
|
49
|
+
navigation.pop();
|
|
51
50
|
};
|
|
52
51
|
|
|
53
|
-
/**
|
|
54
|
-
* build bottom sheet
|
|
55
|
-
*/
|
|
56
|
-
if (isBottomSheet) {
|
|
57
|
-
const bgColor = backgroundColor ?? theme.colors.background.surface;
|
|
58
|
-
const sheetTheme = {...theme, assets: undefined};
|
|
59
|
-
return (
|
|
60
|
-
<BottomSheet {...rest} onDismiss={onDismiss}>
|
|
61
|
-
<View style={[styles.sheetContainer, {backgroundColor: bgColor}]}>
|
|
62
|
-
<View style={styles.indicatorContainer}>
|
|
63
|
-
<View
|
|
64
|
-
style={[
|
|
65
|
-
styles.indicator,
|
|
66
|
-
{backgroundColor: theme.colors.text.disable},
|
|
67
|
-
]}
|
|
68
|
-
/>
|
|
69
|
-
</View>
|
|
70
|
-
<NavigationContainer
|
|
71
|
-
theme={sheetTheme}
|
|
72
|
-
screen={props => <Component {...props} {...params} />}
|
|
73
|
-
options={{
|
|
74
|
-
...options,
|
|
75
|
-
hiddenBack: true,
|
|
76
|
-
headerTitleAlign: 'center',
|
|
77
|
-
headerRight: (props: any) => (
|
|
78
|
-
<HeaderRightAction>
|
|
79
|
-
<NavigationButton
|
|
80
|
-
icon="24_navigation_close"
|
|
81
|
-
{...props}
|
|
82
|
-
onPress={() => navigation.pop()}
|
|
83
|
-
/>
|
|
84
|
-
</HeaderRightAction>
|
|
85
|
-
),
|
|
86
|
-
}}
|
|
87
|
-
/>
|
|
88
|
-
</View>
|
|
89
|
-
</BottomSheet>
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
52
|
return (
|
|
94
53
|
<KeyboardAvoidingView
|
|
95
54
|
style={Styles.flex}
|
|
@@ -121,7 +80,16 @@ const ModalScreen: React.FC<ModalParams> = ({navigation, route, ...rest}) => {
|
|
|
121
80
|
);
|
|
122
81
|
};
|
|
123
82
|
|
|
124
|
-
const BottomSheet: React.FC<
|
|
83
|
+
const BottomSheet: React.FC<BottomSheetParams> = ({navigation, route}) => {
|
|
84
|
+
const {theme} = useContext(ApplicationContext);
|
|
85
|
+
const {screen, options}: BottomSheetParams = route.params;
|
|
86
|
+
const Component = useRef(screen).current;
|
|
87
|
+
const params = {
|
|
88
|
+
...route.params,
|
|
89
|
+
navigation: new Navigation(navigation, theme),
|
|
90
|
+
};
|
|
91
|
+
delete params.screen;
|
|
92
|
+
|
|
125
93
|
const snapPoints = useMemo(() => ['50%', '90%'], []);
|
|
126
94
|
const {bottom} = useSafeAreaInsets();
|
|
127
95
|
const bottomSheetRef = useRef<BottomSheetModalMethods>(null);
|
|
@@ -142,24 +110,57 @@ const BottomSheet: React.FC<ModalParams> = ({children, onDismiss}) => {
|
|
|
142
110
|
/>
|
|
143
111
|
);
|
|
144
112
|
|
|
113
|
+
let backgroundColor = theme.colors.background.default;
|
|
114
|
+
if (options?.surface) {
|
|
115
|
+
backgroundColor = theme.colors.background.surface;
|
|
116
|
+
}
|
|
117
|
+
const sheetTheme = {...theme, assets: undefined};
|
|
118
|
+
|
|
145
119
|
return (
|
|
146
120
|
<SafeAreaView style={Styles.flex}>
|
|
147
121
|
<BottomSheetModal
|
|
148
122
|
ref={bottomSheetRef}
|
|
149
123
|
snapPoints={snapPoints}
|
|
150
|
-
onDismiss={
|
|
124
|
+
onDismiss={navigation.pop}
|
|
151
125
|
handleComponent={null}
|
|
152
126
|
backdropComponent={backdropComponent}>
|
|
153
|
-
<View style={{paddingBottom: bottom}}>
|
|
127
|
+
<View style={{paddingBottom: bottom}}>
|
|
128
|
+
<View style={[styles.sheetContainer, {backgroundColor}]}>
|
|
129
|
+
<View style={styles.indicatorContainer}>
|
|
130
|
+
<View
|
|
131
|
+
style={[
|
|
132
|
+
styles.indicator,
|
|
133
|
+
{backgroundColor: theme.colors.text.disable},
|
|
134
|
+
]}
|
|
135
|
+
/>
|
|
136
|
+
</View>
|
|
137
|
+
<NavigationContainer
|
|
138
|
+
theme={sheetTheme}
|
|
139
|
+
screen={props => <Component {...props} {...params} />}
|
|
140
|
+
options={{
|
|
141
|
+
...options,
|
|
142
|
+
...{headerLeft: null},
|
|
143
|
+
headerTitleAlign: 'center',
|
|
144
|
+
headerRight: props => (
|
|
145
|
+
<HeaderRightAction>
|
|
146
|
+
<NavigationButton
|
|
147
|
+
{...props}
|
|
148
|
+
icon="24_navigation_close"
|
|
149
|
+
backgroundColor="transparent"
|
|
150
|
+
useBorder={false}
|
|
151
|
+
onPress={() => bottomSheetRef.current?.dismiss()}
|
|
152
|
+
/>
|
|
153
|
+
</HeaderRightAction>
|
|
154
|
+
),
|
|
155
|
+
}}
|
|
156
|
+
/>
|
|
157
|
+
</View>
|
|
158
|
+
</View>
|
|
154
159
|
</BottomSheetModal>
|
|
155
160
|
</SafeAreaView>
|
|
156
161
|
);
|
|
157
162
|
};
|
|
158
163
|
|
|
159
|
-
ModalScreen.defaultProps = {
|
|
160
|
-
barrierDismissible: false,
|
|
161
|
-
};
|
|
162
|
-
|
|
163
164
|
const styles = StyleSheet.create({
|
|
164
165
|
container: {flex: 1, flexDirection: 'row'},
|
|
165
166
|
modalContent: {
|
|
@@ -8,20 +8,35 @@ const NavigationButton: React.FC<NavigationButtonProps> = ({
|
|
|
8
8
|
icon,
|
|
9
9
|
tintColor,
|
|
10
10
|
onPress,
|
|
11
|
+
backgroundColor,
|
|
12
|
+
useBorder = true,
|
|
11
13
|
}) => {
|
|
12
14
|
const {theme} = useContext(ApplicationContext);
|
|
13
15
|
return (
|
|
14
|
-
<TouchableOpacity
|
|
15
|
-
|
|
16
|
+
<TouchableOpacity
|
|
17
|
+
style={[
|
|
18
|
+
styles.container,
|
|
19
|
+
{
|
|
20
|
+
backgroundColor: backgroundColor ?? '#00000066',
|
|
21
|
+
borderWidth: useBorder ? 0.5 : 0,
|
|
22
|
+
},
|
|
23
|
+
]}
|
|
24
|
+
onPress={onPress}>
|
|
25
|
+
<Icon
|
|
26
|
+
source={icon}
|
|
27
|
+
color={tintColor ?? theme.colors.text.default}
|
|
28
|
+
size={20}
|
|
29
|
+
/>
|
|
16
30
|
</TouchableOpacity>
|
|
17
31
|
);
|
|
18
32
|
};
|
|
19
33
|
|
|
20
34
|
const styles = StyleSheet.create({
|
|
21
35
|
container: {
|
|
22
|
-
height:
|
|
23
|
-
width:
|
|
24
|
-
borderRadius:
|
|
36
|
+
height: 28,
|
|
37
|
+
width: 28,
|
|
38
|
+
borderRadius: 14,
|
|
39
|
+
borderColor: '#00000066',
|
|
25
40
|
justifyContent: 'center',
|
|
26
41
|
alignItems: 'center',
|
|
27
42
|
},
|
package/Navigation/Navigator.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {StackActions} from '@react-navigation/native';
|
|
2
|
-
import {ModalParams, ScreenParams} from './types';
|
|
2
|
+
import {BottomSheetParams, ModalParams, ScreenParams} from './types';
|
|
3
3
|
|
|
4
4
|
class Navigator {
|
|
5
5
|
ref?: any;
|
|
@@ -28,7 +28,7 @@ class Navigator {
|
|
|
28
28
|
this.ref.current.dispatch(StackActions.push('Modal', params));
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
showBottomSheet = (params:
|
|
31
|
+
showBottomSheet = (params: BottomSheetParams) => {
|
|
32
32
|
this.ref.current.dispatch(
|
|
33
33
|
StackActions.push('Modal', {
|
|
34
34
|
...params,
|
package/Navigation/types.ts
CHANGED
|
@@ -85,18 +85,23 @@ export interface ModalParams extends ScreenParams {
|
|
|
85
85
|
screen: React.ElementType;
|
|
86
86
|
onDismiss?: (mounted?: boolean) => void;
|
|
87
87
|
barrierDismissible?: boolean;
|
|
88
|
-
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface BottomSheetParams extends ScreenParams {
|
|
91
|
+
[key: string]: any;
|
|
92
|
+
onDismiss?: () => void;
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
export type NavigationButtonProps = {
|
|
92
96
|
icon: string;
|
|
93
97
|
tintColor?: string;
|
|
98
|
+
backgroundColor?: string;
|
|
99
|
+
useBorder?: boolean;
|
|
94
100
|
onPress: () => void;
|
|
95
101
|
};
|
|
96
102
|
|
|
97
103
|
export type NavigationOptions = {
|
|
98
104
|
surface?: boolean;
|
|
99
|
-
hiddenBack?: boolean;
|
|
100
105
|
title?: string;
|
|
101
106
|
headerTitleAlign?: 'left' | 'center';
|
|
102
107
|
customTitle?: TitleCustomProps;
|
|
@@ -104,7 +109,8 @@ export type NavigationOptions = {
|
|
|
104
109
|
};
|
|
105
110
|
|
|
106
111
|
export type HeaderBackgroundProps = {
|
|
107
|
-
image?: string;
|
|
112
|
+
image?: string | null;
|
|
113
|
+
backgroundColor?: string | null;
|
|
108
114
|
};
|
|
109
115
|
|
|
110
116
|
export type TitleCustomProps = {
|
package/Navigation/utils.tsx
CHANGED
|
@@ -3,21 +3,15 @@ import {
|
|
|
3
3
|
StackNavigationOptions,
|
|
4
4
|
TransitionPresets,
|
|
5
5
|
} from '@react-navigation/stack';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
HeaderBackground,
|
|
8
|
+
HeaderCustom,
|
|
9
|
+
HeaderLeft,
|
|
10
|
+
HeaderTitle,
|
|
11
|
+
HeaderToolkitAction,
|
|
12
|
+
} from './Components';
|
|
7
13
|
import {NavigationOptions, Theme} from './types';
|
|
8
14
|
import {Colors} from '../Consts';
|
|
9
|
-
import {Text} from '../Text';
|
|
10
|
-
|
|
11
|
-
const HeaderTitle = (props: any) => {
|
|
12
|
-
return (
|
|
13
|
-
<Text
|
|
14
|
-
{...props}
|
|
15
|
-
typography="header_default"
|
|
16
|
-
weight="bold"
|
|
17
|
-
color={props.tintColor}
|
|
18
|
-
/>
|
|
19
|
-
);
|
|
20
|
-
};
|
|
21
15
|
|
|
22
16
|
const getTintColor = (theme: Theme): any => {
|
|
23
17
|
if (theme.assets?.headerBackground) {
|
|
@@ -34,10 +28,9 @@ const getStackOptions = (theme: Theme): StackNavigationOptions => {
|
|
|
34
28
|
return {
|
|
35
29
|
headerTitleAlign: 'center',
|
|
36
30
|
headerTitle: HeaderTitle,
|
|
37
|
-
headerBackground:
|
|
38
|
-
<HeaderBackground image={theme.assets?.headerBackground} />
|
|
39
|
-
),
|
|
31
|
+
headerBackground: HeaderBackground,
|
|
40
32
|
headerLeft: (props: any) => <HeaderLeft {...props} />,
|
|
33
|
+
headerRight: (props: any) => <HeaderToolkitAction {...props} />,
|
|
41
34
|
...getTintColor(theme),
|
|
42
35
|
};
|
|
43
36
|
};
|
|
@@ -47,9 +40,8 @@ const getDialogOptions = (theme: Theme): StackNavigationOptions => {
|
|
|
47
40
|
headerTitleAlign: 'center',
|
|
48
41
|
headerTitle: HeaderTitle,
|
|
49
42
|
headerLeft: (props: any) => <HeaderLeft {...props} />,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
),
|
|
43
|
+
headerRight: (props: any) => <HeaderToolkitAction {...props} />,
|
|
44
|
+
headerBackground: HeaderBackground,
|
|
53
45
|
...getTintColor(theme),
|
|
54
46
|
...TransitionPresets.ModalTransition,
|
|
55
47
|
};
|
|
@@ -81,23 +73,17 @@ const getModalOptions = (): StackNavigationOptions => {
|
|
|
81
73
|
};
|
|
82
74
|
|
|
83
75
|
const getOptions = (params: NavigationOptions, theme: Theme) => {
|
|
84
|
-
let backTheme: {};
|
|
85
76
|
let surfaceTheme: {};
|
|
86
77
|
let titleTheme: {};
|
|
87
78
|
|
|
88
|
-
if (params.hiddenBack == true) {
|
|
89
|
-
backTheme = {
|
|
90
|
-
headerLeft: null,
|
|
91
|
-
};
|
|
92
|
-
} else {
|
|
93
|
-
backTheme = {
|
|
94
|
-
headerLeft: (props: any) => <HeaderLeft {...props} />,
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
79
|
if (params.surface == true) {
|
|
99
80
|
surfaceTheme = {
|
|
100
|
-
headerBackground: () =>
|
|
81
|
+
headerBackground: () => (
|
|
82
|
+
<HeaderBackground
|
|
83
|
+
image={null}
|
|
84
|
+
backgroundColor={theme.colors.background.surface}
|
|
85
|
+
/>
|
|
86
|
+
),
|
|
101
87
|
...getTintColor({
|
|
102
88
|
...theme,
|
|
103
89
|
assets: {...theme.assets, headerBackground: undefined},
|
|
@@ -105,9 +91,7 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
|
|
|
105
91
|
};
|
|
106
92
|
} else {
|
|
107
93
|
surfaceTheme = {
|
|
108
|
-
headerBackground:
|
|
109
|
-
<HeaderBackground image={theme.assets?.headerBackground} />
|
|
110
|
-
),
|
|
94
|
+
headerBackground: HeaderBackground,
|
|
111
95
|
...getTintColor(theme),
|
|
112
96
|
};
|
|
113
97
|
}
|
|
@@ -125,7 +109,7 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
|
|
|
125
109
|
};
|
|
126
110
|
}
|
|
127
111
|
|
|
128
|
-
return {...params, ...
|
|
112
|
+
return {...params, ...surfaceTheme, ...titleTheme};
|
|
129
113
|
};
|
|
130
114
|
|
|
131
115
|
export {getStackOptions, getDialogOptions, getModalOptions, getOptions};
|
package/Popup/PopupNotify.tsx
CHANGED
|
@@ -148,7 +148,10 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
148
148
|
</View>
|
|
149
149
|
{information && (
|
|
150
150
|
<View style={styles.information}>
|
|
151
|
-
<Text
|
|
151
|
+
<Text
|
|
152
|
+
typography={'description_xs'}
|
|
153
|
+
color={theme.colors.text.hint}
|
|
154
|
+
numberOfLines={1}>
|
|
152
155
|
{information}
|
|
153
156
|
</Text>
|
|
154
157
|
</View>
|
package/Text/index.tsx
CHANGED
|
@@ -18,6 +18,20 @@ const SFProText: TypographyWeight = {
|
|
|
18
18
|
bold: 'Bold',
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
const AlegreyaSans: TypographyWeight = {
|
|
22
|
+
100: 'Thin',
|
|
23
|
+
200: 'Thin',
|
|
24
|
+
300: 'Thin',
|
|
25
|
+
400: 'Regular',
|
|
26
|
+
500: 'Medium',
|
|
27
|
+
600: 'Medium',
|
|
28
|
+
700: 'Bold',
|
|
29
|
+
800: 'Black',
|
|
30
|
+
900: 'Black',
|
|
31
|
+
normal: 'Regular',
|
|
32
|
+
bold: 'Bold',
|
|
33
|
+
};
|
|
34
|
+
|
|
21
35
|
const FontStyle: {[key: string]: string} = {
|
|
22
36
|
italic: 'Italic',
|
|
23
37
|
normal: '',
|
|
@@ -43,14 +57,18 @@ const Text: React.FC<TextProps> = ({
|
|
|
43
57
|
} = styles;
|
|
44
58
|
const typoStyle = styleSheet[typo] ?? styleSheet.paragraph_default;
|
|
45
59
|
const {fontWeight, fontSize, fontStyle, lineHeight} = typoStyle;
|
|
46
|
-
let fontFamily: string;
|
|
47
60
|
const style = FontStyle[fontStyle ?? 'normal'];
|
|
61
|
+
let fontFamily: string;
|
|
48
62
|
|
|
49
63
|
switch (theme.font) {
|
|
50
64
|
case 'SFProText': {
|
|
51
65
|
fontFamily = `${theme.font}-${SFProText[fontWeight]}${style}`;
|
|
52
66
|
break;
|
|
53
67
|
}
|
|
68
|
+
case 'AlegreyaSans': {
|
|
69
|
+
fontFamily = `${theme.font}-${AlegreyaSans[fontWeight]}${style}`;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
54
72
|
default: {
|
|
55
73
|
fontFamily = `SFProText-${SFProText[fontWeight]}${style}`;
|
|
56
74
|
}
|
package/index.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
+
SafeAreaProvider,
|
|
2
3
|
SafeAreaView,
|
|
3
4
|
useSafeAreaInsets,
|
|
4
|
-
SafeAreaProvider,
|
|
5
5
|
} from 'react-native-safe-area-context';
|
|
6
6
|
import LinearGradient from 'react-native-linear-gradient';
|
|
7
|
-
import Playground from './Playground';
|
|
8
|
-
export {Playground};
|
|
9
7
|
|
|
10
8
|
export {SafeAreaView, useSafeAreaInsets, SafeAreaProvider, LinearGradient};
|
|
11
9
|
|
package/package.json
CHANGED
package/Playground/index.tsx
DELETED
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
import React, {FC, useContext, useEffect, useState} from 'react';
|
|
2
|
-
import {FlatList, TouchableOpacity, View} from 'react-native';
|
|
3
|
-
import {CheckBox, Input, Radio, Text} from '@momo-kits/foundation';
|
|
4
|
-
import {PlaygroundProps, PropValue} from './types';
|
|
5
|
-
import styles from './styles';
|
|
6
|
-
import {Colors, Radius, Spacing} from '../Consts';
|
|
7
|
-
import {ApplicationContext} from '../Navigation';
|
|
8
|
-
import {ScreenSection, SectionItem} from '../Layout';
|
|
9
|
-
import {Icon, IconSources} from '../Icon';
|
|
10
|
-
import {string} from 'prop-types';
|
|
11
|
-
|
|
12
|
-
const ChooseOptionScreen = (
|
|
13
|
-
data: string[] = [],
|
|
14
|
-
optionType: 'color' | 'icon' | 'text' = 'text',
|
|
15
|
-
onPress: (value: string) => void,
|
|
16
|
-
) => {
|
|
17
|
-
const {theme} = useContext(ApplicationContext);
|
|
18
|
-
|
|
19
|
-
let mapData = data;
|
|
20
|
-
if (optionType === 'color') {
|
|
21
|
-
mapData = Object.values(Colors);
|
|
22
|
-
}
|
|
23
|
-
if (optionType === 'icon') {
|
|
24
|
-
mapData = Object.keys(IconSources);
|
|
25
|
-
}
|
|
26
|
-
const renderItemView = (item: string) => {
|
|
27
|
-
switch (optionType) {
|
|
28
|
-
case 'color': {
|
|
29
|
-
return (
|
|
30
|
-
<View
|
|
31
|
-
style={{
|
|
32
|
-
width: 36,
|
|
33
|
-
height: 36,
|
|
34
|
-
borderRadius: Radius.M,
|
|
35
|
-
backgroundColor: item,
|
|
36
|
-
marginRight: Spacing.S,
|
|
37
|
-
}}
|
|
38
|
-
/>
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
case 'icon': {
|
|
42
|
-
return <Icon source={item} style={{marginRight: Spacing.S}} />;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const renderItem = ({item, index}) => {
|
|
48
|
-
const iconSource: {[key: string]: {uri: string}} = IconSources;
|
|
49
|
-
let key = item;
|
|
50
|
-
let chosenItem = item;
|
|
51
|
-
if (optionType === 'color') key = Object.keys(Colors)[index];
|
|
52
|
-
if (optionType === 'icon') chosenItem = iconSource[key].uri;
|
|
53
|
-
return (
|
|
54
|
-
<TouchableOpacity
|
|
55
|
-
key={`${item.toString()} ${index}`}
|
|
56
|
-
onPress={() => onPress(chosenItem)}
|
|
57
|
-
style={{
|
|
58
|
-
flexDirection: 'row',
|
|
59
|
-
alignItems: 'center',
|
|
60
|
-
marginBottom: Spacing.M,
|
|
61
|
-
borderBottomWidth: index !== mapData.length - 1 ? 1 : 0,
|
|
62
|
-
borderColor: theme.colors.border.default,
|
|
63
|
-
paddingBottom: Spacing.M,
|
|
64
|
-
}}>
|
|
65
|
-
{renderItemView(item)}
|
|
66
|
-
<Text typography={'description_default'}>{key}</Text>
|
|
67
|
-
</TouchableOpacity>
|
|
68
|
-
);
|
|
69
|
-
};
|
|
70
|
-
return (
|
|
71
|
-
<ScreenSection>
|
|
72
|
-
<SectionItem widthSpan={12}>
|
|
73
|
-
<FlatList
|
|
74
|
-
data={mapData}
|
|
75
|
-
renderItem={renderItem}
|
|
76
|
-
keyExtractor={(item, index) => `${item.toString()} ${index}`}
|
|
77
|
-
showsVerticalScrollIndicator={false}
|
|
78
|
-
/>
|
|
79
|
-
</SectionItem>
|
|
80
|
-
</ScreenSection>
|
|
81
|
-
);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const Playground: FC<PlaygroundProps> = ({params}) => {
|
|
85
|
-
const {theme, navigator} = useContext(ApplicationContext);
|
|
86
|
-
const {props} = params;
|
|
87
|
-
const [compProps, setCompProps] = useState<{[key: string]: any}>({});
|
|
88
|
-
useEffect(() => {
|
|
89
|
-
initProps();
|
|
90
|
-
return () => {};
|
|
91
|
-
}, [props]);
|
|
92
|
-
|
|
93
|
-
const initProps = () => {
|
|
94
|
-
let newProps = {};
|
|
95
|
-
Object.keys(props).forEach(i => {
|
|
96
|
-
newProps = {...newProps, [i]: props[i].value};
|
|
97
|
-
});
|
|
98
|
-
setCompProps(newProps);
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const onChangeOptions = (
|
|
102
|
-
value: string | boolean | undefined,
|
|
103
|
-
key: string,
|
|
104
|
-
) => {
|
|
105
|
-
const newProps = {...compProps, [key]: value};
|
|
106
|
-
setCompProps(newProps);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const onCheckUndefined = (value: boolean, key: string) => {
|
|
110
|
-
let newValue = !value ? undefined : props?.[key]?.value;
|
|
111
|
-
const newProps = {...compProps, [key]: newValue};
|
|
112
|
-
setCompProps(newProps);
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const showOptions = (prop: any, key: string) => {
|
|
116
|
-
navigator?.showBottomSheet({
|
|
117
|
-
options: {
|
|
118
|
-
title: 'Choose option',
|
|
119
|
-
},
|
|
120
|
-
screen: () =>
|
|
121
|
-
ChooseOptionScreen(prop.data, prop.optionType, optionValue => {
|
|
122
|
-
onChangeOptions(optionValue, key);
|
|
123
|
-
navigator?.pop();
|
|
124
|
-
}),
|
|
125
|
-
});
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
const generateView = (key: string, prop: PropValue) => {
|
|
129
|
-
let PlayGroundView = <View />;
|
|
130
|
-
switch (prop.type) {
|
|
131
|
-
case 'enum': {
|
|
132
|
-
PlayGroundView = (
|
|
133
|
-
<View style={styles.radioView}>
|
|
134
|
-
{prop?.options?.map(option => {
|
|
135
|
-
return (
|
|
136
|
-
<Radio
|
|
137
|
-
label={option}
|
|
138
|
-
value={option}
|
|
139
|
-
onChange={() => onChangeOptions(option, key)}
|
|
140
|
-
groupValue={compProps?.[key]}
|
|
141
|
-
style={{marginBottom: Spacing.S}}
|
|
142
|
-
/>
|
|
143
|
-
);
|
|
144
|
-
})}
|
|
145
|
-
</View>
|
|
146
|
-
);
|
|
147
|
-
break;
|
|
148
|
-
}
|
|
149
|
-
case 'string': {
|
|
150
|
-
PlayGroundView = (
|
|
151
|
-
<Input
|
|
152
|
-
size={'small'}
|
|
153
|
-
floatingValue={key}
|
|
154
|
-
value={compProps?.[key]}
|
|
155
|
-
onChangeText={text => onChangeOptions(text, key)}
|
|
156
|
-
/>
|
|
157
|
-
);
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
case 'bool': {
|
|
161
|
-
let label = compProps?.[key] === true ? 'True' : 'False';
|
|
162
|
-
if (compProps?.[key] === undefined) {
|
|
163
|
-
label = 'undefined';
|
|
164
|
-
}
|
|
165
|
-
PlayGroundView = (
|
|
166
|
-
<CheckBox
|
|
167
|
-
label={label}
|
|
168
|
-
value={compProps?.[key]}
|
|
169
|
-
onChange={value => onChangeOptions(value, key)}
|
|
170
|
-
/>
|
|
171
|
-
);
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
case 'options': {
|
|
175
|
-
PlayGroundView = (
|
|
176
|
-
<TouchableOpacity
|
|
177
|
-
style={{
|
|
178
|
-
width: '100%',
|
|
179
|
-
height: 48,
|
|
180
|
-
borderRadius: Radius.M,
|
|
181
|
-
borderColor: theme.colors.border.default,
|
|
182
|
-
borderWidth: 1,
|
|
183
|
-
justifyContent: 'center',
|
|
184
|
-
alignItems: 'center',
|
|
185
|
-
flexDirection: 'row',
|
|
186
|
-
backgroundColor: theme.colors.background.surface,
|
|
187
|
-
}}
|
|
188
|
-
onPress={() => showOptions(prop, key)}>
|
|
189
|
-
<Text typography={'description_default'}>{compProps?.[key]}</Text>
|
|
190
|
-
<View style={{position: 'absolute', right: Spacing.M}}>
|
|
191
|
-
<Icon source={'arrow_chevron_down_small'} size={24} />
|
|
192
|
-
</View>
|
|
193
|
-
</TouchableOpacity>
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
return (
|
|
199
|
-
<View
|
|
200
|
-
style={[
|
|
201
|
-
styles.propView,
|
|
202
|
-
{backgroundColor: theme.colors.background.surface},
|
|
203
|
-
]}>
|
|
204
|
-
<Text style={styles.propTitle} typography={'header_default'}>
|
|
205
|
-
{key}
|
|
206
|
-
</Text>
|
|
207
|
-
{PlayGroundView}
|
|
208
|
-
{typeof compProps?.[key] !== 'boolean' && (
|
|
209
|
-
<CheckBox
|
|
210
|
-
style={{marginTop: Spacing.M}}
|
|
211
|
-
label={'Is undefined'}
|
|
212
|
-
value={!compProps?.[key]}
|
|
213
|
-
onChange={value => onCheckUndefined(!value, key)}
|
|
214
|
-
/>
|
|
215
|
-
)}
|
|
216
|
-
</View>
|
|
217
|
-
);
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
const Component = params.component ?? <View />;
|
|
221
|
-
const propsKeys = Object.keys(props);
|
|
222
|
-
|
|
223
|
-
return (
|
|
224
|
-
<View>
|
|
225
|
-
<Text style={{marginBottom: Spacing.M}} typography={'title_s'}>
|
|
226
|
-
Component
|
|
227
|
-
</Text>
|
|
228
|
-
<View
|
|
229
|
-
style={[
|
|
230
|
-
styles.propView,
|
|
231
|
-
{
|
|
232
|
-
backgroundColor: theme.colors.background.surface,
|
|
233
|
-
justifyContent: 'center',
|
|
234
|
-
alignItems: 'center',
|
|
235
|
-
},
|
|
236
|
-
]}>
|
|
237
|
-
<Component {...compProps} />
|
|
238
|
-
</View>
|
|
239
|
-
<Text style={{marginBottom: Spacing.M}} typography={'title_s'}>
|
|
240
|
-
Props
|
|
241
|
-
</Text>
|
|
242
|
-
{propsKeys.map(prop => {
|
|
243
|
-
return generateView(prop, props[prop]);
|
|
244
|
-
})}
|
|
245
|
-
</View>
|
|
246
|
-
);
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
export default Playground;
|
package/Playground/styles.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {StyleSheet} from 'react-native';
|
|
2
|
-
import {Colors, Radius, Spacing} from '../Consts';
|
|
3
|
-
|
|
4
|
-
export default StyleSheet.create({
|
|
5
|
-
radioView: {
|
|
6
|
-
flexDirection: 'row',
|
|
7
|
-
flexWrap: 'wrap',
|
|
8
|
-
alignItems: 'center',
|
|
9
|
-
},
|
|
10
|
-
propView: {
|
|
11
|
-
borderRadius: Radius.M,
|
|
12
|
-
padding: Spacing.M,
|
|
13
|
-
marginBottom: Spacing.M,
|
|
14
|
-
},
|
|
15
|
-
propTitle: {marginBottom: Spacing.S, textTransform: 'capitalize'},
|
|
16
|
-
});
|
package/Playground/types.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {ReactElement} from 'react';
|
|
2
|
-
|
|
3
|
-
export type PropValue = {
|
|
4
|
-
value: any;
|
|
5
|
-
options?: string[];
|
|
6
|
-
type: 'string' | 'options' | 'enum' | 'bool';
|
|
7
|
-
description?: string;
|
|
8
|
-
data?: {[key: string]: string}[];
|
|
9
|
-
optionType?: 'icon' | 'color';
|
|
10
|
-
};
|
|
11
|
-
export type PlaygroundProps = {
|
|
12
|
-
params: {
|
|
13
|
-
component: ReactElement;
|
|
14
|
-
props: {[key: string]: PropValue};
|
|
15
|
-
};
|
|
16
|
-
};
|
|
File without changes
|