@momo-kits/foundation 1.0.1 → 1.0.4
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/Button/index.tsx +39 -23
- package/CheckBox/index.tsx +11 -7
- package/CheckBox/types.ts +6 -3
- package/Consts/theme.ts +57 -1
- package/ContentLoader/index.tsx +2 -3
- package/Icon/icon.json +3 -0
- package/Icon/index.tsx +9 -4
- package/Icon/types.ts +4 -1
- package/IconButton/index.tsx +24 -4
- package/Image/index.tsx +11 -12
- package/Image/types.ts +1 -3
- package/Input/Input.tsx +160 -0
- package/Input/TextArea.tsx +26 -65
- package/Input/common.tsx +70 -0
- package/Input/index.tsx +23 -197
- package/Input/styles.ts +1 -5
- package/Layout/GridSystem.tsx +1 -1
- package/Layout/ScreenContainer.tsx +5 -19
- package/Layout/ScreenSection.tsx +13 -0
- package/Layout/SectionItem.tsx +3 -0
- package/Layout/utils.ts +14 -0
- package/Navigation/Components.tsx +60 -12
- package/Navigation/ModalScreen.tsx +56 -43
- package/Navigation/Navigation.ts +8 -4
- package/Navigation/NavigationButton.tsx +5 -2
- package/Navigation/NavigationContainer.tsx +25 -58
- package/Navigation/StackScreen.tsx +12 -7
- package/Navigation/types.ts +20 -7
- package/Navigation/utils.tsx +77 -21
- package/Playground/index.tsx +249 -0
- package/Playground/styles.ts +16 -0
- package/Playground/types.ts +16 -0
- package/Popup/PopupNotify.tsx +210 -0
- package/Popup/PopupPromotion.tsx +62 -0
- package/Popup/index.tsx +4 -0
- package/Popup/types.ts +22 -0
- package/Radio/index.tsx +25 -9
- package/Radio/types.ts +5 -2
- package/Switch/index.tsx +8 -6
- package/Switch/types.ts +6 -3
- package/Text/index.tsx +9 -7
- package/Text/styles.ts +3 -3
- package/Text/types.ts +5 -14
- package/index.ts +6 -6
- package/package.json +4 -5
- package/publish.sh +6 -8
- package/ActivityIndicator.tsx +0 -244
- package/Button/types.ts +0 -27
- package/IconButton/types.ts +0 -16
- package/Input/types.ts +0 -23
|
@@ -0,0 +1,249 @@
|
|
|
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;
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import React, {useContext} from 'react';
|
|
2
|
+
import {StyleSheet, TouchableOpacity, View} from 'react-native';
|
|
3
|
+
import {PopupNotifyProps} from './types';
|
|
4
|
+
import {Radius, Spacing, Styles} from '../Consts';
|
|
5
|
+
import {Image} from '../Image';
|
|
6
|
+
import {Text} from '../Text';
|
|
7
|
+
import {ApplicationContext} from '../Navigation';
|
|
8
|
+
import {Button} from '../Button';
|
|
9
|
+
import {Icon} from '../Icon';
|
|
10
|
+
|
|
11
|
+
const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
12
|
+
image,
|
|
13
|
+
title,
|
|
14
|
+
description,
|
|
15
|
+
information,
|
|
16
|
+
secondary,
|
|
17
|
+
primary,
|
|
18
|
+
buttonDirection,
|
|
19
|
+
onIconClose,
|
|
20
|
+
}) => {
|
|
21
|
+
const {theme, navigator} = useContext(ApplicationContext);
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* on action popup
|
|
25
|
+
* @param callback
|
|
26
|
+
*/
|
|
27
|
+
const onAction = (callback?: () => void) => {
|
|
28
|
+
navigator?.pop();
|
|
29
|
+
callback?.();
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* build main action of popup
|
|
34
|
+
*/
|
|
35
|
+
const buildAction = () => {
|
|
36
|
+
const renderRow = () => {
|
|
37
|
+
return (
|
|
38
|
+
<View style={Styles.row}>
|
|
39
|
+
{secondary?.title && (
|
|
40
|
+
<>
|
|
41
|
+
<View style={Styles.flex}>
|
|
42
|
+
<Button
|
|
43
|
+
title={secondary.title}
|
|
44
|
+
type="text"
|
|
45
|
+
size="medium"
|
|
46
|
+
onPress={() => {
|
|
47
|
+
onAction(secondary?.onPress);
|
|
48
|
+
}}
|
|
49
|
+
/>
|
|
50
|
+
</View>
|
|
51
|
+
<View style={styles.buttonSpace} />
|
|
52
|
+
</>
|
|
53
|
+
)}
|
|
54
|
+
<View style={Styles.flex}>
|
|
55
|
+
<Button
|
|
56
|
+
title={primary.title}
|
|
57
|
+
size="medium"
|
|
58
|
+
onPress={() => {
|
|
59
|
+
onAction(primary.onPress);
|
|
60
|
+
}}
|
|
61
|
+
/>
|
|
62
|
+
</View>
|
|
63
|
+
</View>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
const renderColumn = () => {
|
|
67
|
+
return (
|
|
68
|
+
<View style={Styles.columnCenter}>
|
|
69
|
+
<Button
|
|
70
|
+
title={primary.title}
|
|
71
|
+
size="medium"
|
|
72
|
+
onPress={() => {
|
|
73
|
+
onAction(primary.onPress);
|
|
74
|
+
}}
|
|
75
|
+
/>
|
|
76
|
+
{secondary?.title && (
|
|
77
|
+
<>
|
|
78
|
+
<View style={styles.buttonSpace} />
|
|
79
|
+
<Button
|
|
80
|
+
title={secondary.title}
|
|
81
|
+
type="text"
|
|
82
|
+
size="medium"
|
|
83
|
+
onPress={() => {
|
|
84
|
+
onAction(secondary?.onPress);
|
|
85
|
+
}}
|
|
86
|
+
/>
|
|
87
|
+
</>
|
|
88
|
+
)}
|
|
89
|
+
</View>
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
if (buttonDirection == 'auto') {
|
|
94
|
+
if (
|
|
95
|
+
secondary?.title &&
|
|
96
|
+
(secondary.title.length > 12 || primary.title.length > 12)
|
|
97
|
+
) {
|
|
98
|
+
return renderColumn();
|
|
99
|
+
}
|
|
100
|
+
return renderRow();
|
|
101
|
+
}
|
|
102
|
+
if (buttonDirection == 'row') {
|
|
103
|
+
return renderRow();
|
|
104
|
+
}
|
|
105
|
+
return renderColumn();
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* build close action
|
|
110
|
+
*/
|
|
111
|
+
const buildCloseIcon = () => {
|
|
112
|
+
return (
|
|
113
|
+
<View style={styles.iconCloseContainer}>
|
|
114
|
+
<TouchableOpacity
|
|
115
|
+
onPress={() => onAction(onIconClose)}
|
|
116
|
+
style={[
|
|
117
|
+
styles.iconClose,
|
|
118
|
+
{
|
|
119
|
+
backgroundColor: theme.colors.text.default,
|
|
120
|
+
borderColor: theme.colors.background.surface,
|
|
121
|
+
},
|
|
122
|
+
]}>
|
|
123
|
+
<Icon
|
|
124
|
+
source="navigation_close"
|
|
125
|
+
color={theme.colors.background.surface}
|
|
126
|
+
size={14}
|
|
127
|
+
/>
|
|
128
|
+
</TouchableOpacity>
|
|
129
|
+
</View>
|
|
130
|
+
);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<View
|
|
135
|
+
style={[
|
|
136
|
+
styles.container,
|
|
137
|
+
{backgroundColor: theme.colors.background.surface},
|
|
138
|
+
]}>
|
|
139
|
+
{image && <Image source={{uri: image}} style={styles.image} />}
|
|
140
|
+
<View style={styles.content}>
|
|
141
|
+
<Text typography={'title_xs'} numberOfLines={1}>
|
|
142
|
+
{title}
|
|
143
|
+
</Text>
|
|
144
|
+
<View style={styles.description}>
|
|
145
|
+
<Text typography={'paragraph_default'} numberOfLines={3}>
|
|
146
|
+
{description}
|
|
147
|
+
</Text>
|
|
148
|
+
</View>
|
|
149
|
+
{information && (
|
|
150
|
+
<View style={styles.information}>
|
|
151
|
+
<Text typography={'description_xs'} numberOfLines={1}>
|
|
152
|
+
{information}
|
|
153
|
+
</Text>
|
|
154
|
+
</View>
|
|
155
|
+
)}
|
|
156
|
+
</View>
|
|
157
|
+
<View style={styles.contentAction}>{buildAction()}</View>
|
|
158
|
+
{buildCloseIcon()}
|
|
159
|
+
</View>
|
|
160
|
+
);
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const styles = StyleSheet.create({
|
|
164
|
+
container: {
|
|
165
|
+
borderRadius: Radius.L,
|
|
166
|
+
},
|
|
167
|
+
image: {
|
|
168
|
+
borderTopLeftRadius: Radius.L,
|
|
169
|
+
borderTopRightRadius: Radius.L,
|
|
170
|
+
aspectRatio: 1.7777,
|
|
171
|
+
},
|
|
172
|
+
content: {padding: Spacing.XL},
|
|
173
|
+
description: {
|
|
174
|
+
marginTop: Spacing.S,
|
|
175
|
+
},
|
|
176
|
+
information: {
|
|
177
|
+
marginTop: Spacing.S,
|
|
178
|
+
},
|
|
179
|
+
contentAction: {
|
|
180
|
+
paddingHorizontal: Spacing.XL,
|
|
181
|
+
paddingBottom: Spacing.L,
|
|
182
|
+
},
|
|
183
|
+
buttonSpace: {
|
|
184
|
+
width: Spacing.S,
|
|
185
|
+
height: Spacing.S,
|
|
186
|
+
},
|
|
187
|
+
iconCloseContainer: {
|
|
188
|
+
position: 'absolute',
|
|
189
|
+
top: -Spacing.S,
|
|
190
|
+
right: -Spacing.S,
|
|
191
|
+
},
|
|
192
|
+
iconClose: {
|
|
193
|
+
width: 20,
|
|
194
|
+
height: 20,
|
|
195
|
+
alignItems: 'center',
|
|
196
|
+
justifyContent: 'center',
|
|
197
|
+
borderRadius: Radius.M,
|
|
198
|
+
borderWidth: 2,
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
PopupNotify.defaultProps = {
|
|
203
|
+
title: 'Title',
|
|
204
|
+
primary: {
|
|
205
|
+
title: 'Primary',
|
|
206
|
+
onPress: () => {},
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
export default PopupNotify;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React, {useContext} from 'react';
|
|
2
|
+
import {StyleSheet, View} from 'react-native';
|
|
3
|
+
import {PopupPromotionProps} from './types';
|
|
4
|
+
import {ApplicationContext} from '../Navigation';
|
|
5
|
+
import {Image} from '../Image';
|
|
6
|
+
import {Button} from '../Button';
|
|
7
|
+
import {Spacing} from '../Consts';
|
|
8
|
+
|
|
9
|
+
const PopupPromotion: React.FC<PopupPromotionProps> = ({image, primary}) => {
|
|
10
|
+
const {theme, navigator} = useContext(ApplicationContext);
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* on action popup
|
|
14
|
+
* @param callback
|
|
15
|
+
*/
|
|
16
|
+
const onAction = (callback?: () => void) => {
|
|
17
|
+
navigator?.pop();
|
|
18
|
+
callback?.();
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<>
|
|
23
|
+
<Image
|
|
24
|
+
style={styles.container}
|
|
25
|
+
source={{
|
|
26
|
+
uri: image,
|
|
27
|
+
}}
|
|
28
|
+
/>
|
|
29
|
+
<View style={styles.actionContainer}>
|
|
30
|
+
<Button
|
|
31
|
+
title={primary?.title}
|
|
32
|
+
onPress={() => {
|
|
33
|
+
onAction(primary?.onPress);
|
|
34
|
+
}}
|
|
35
|
+
/>
|
|
36
|
+
</View>
|
|
37
|
+
</>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const styles = StyleSheet.create({
|
|
42
|
+
container: {
|
|
43
|
+
aspectRatio: 0.66,
|
|
44
|
+
},
|
|
45
|
+
actionContainer: {
|
|
46
|
+
position: 'absolute',
|
|
47
|
+
bottom: 0,
|
|
48
|
+
width: '100%',
|
|
49
|
+
paddingVertical: Spacing.XL,
|
|
50
|
+
paddingHorizontal: Spacing.L,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
PopupPromotion.defaultProps = {
|
|
55
|
+
image: 'https://google.com',
|
|
56
|
+
primary: {
|
|
57
|
+
title: 'Primary',
|
|
58
|
+
onPress: () => {},
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export default PopupPromotion;
|
package/Popup/index.tsx
ADDED
package/Popup/types.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type PopupNotifyProps = {
|
|
2
|
+
image?: string;
|
|
3
|
+
title: string;
|
|
4
|
+
description: string;
|
|
5
|
+
information?: string;
|
|
6
|
+
secondary?: PopupAction;
|
|
7
|
+
primary: PopupAction;
|
|
8
|
+
buttonDirection: PopupActionDirection;
|
|
9
|
+
onIconClose?: () => void;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type PopupPromotionProps = {
|
|
13
|
+
image: string;
|
|
14
|
+
primary: PopupAction;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type PopupAction = {
|
|
18
|
+
title: string;
|
|
19
|
+
onPress: () => void;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type PopupActionDirection = 'row' | 'column' | 'auto';
|
package/Radio/index.tsx
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import React, {FC, useContext} from 'react';
|
|
2
2
|
import {TouchableOpacity, View} from 'react-native';
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
import {RadioProps} from './types';
|
|
5
5
|
import {Text} from '../Text';
|
|
6
6
|
import styles from './styles';
|
|
7
|
+
import {ApplicationContext} from '../Navigation';
|
|
8
|
+
import {Spacing} from '../Consts';
|
|
7
9
|
|
|
8
|
-
const Radio: FC<RadioProps> =
|
|
10
|
+
const Radio: FC<RadioProps> = ({
|
|
11
|
+
value,
|
|
12
|
+
groupValue,
|
|
13
|
+
disabled,
|
|
14
|
+
onChange,
|
|
15
|
+
label,
|
|
16
|
+
style,
|
|
17
|
+
}) => {
|
|
9
18
|
const {theme} = useContext(ApplicationContext);
|
|
10
|
-
const {value, groupValue, disabled, onChange, label} = props;
|
|
11
|
-
|
|
12
19
|
const selected = value === groupValue;
|
|
13
20
|
const borderWidth = selected ? 6 : 2;
|
|
14
21
|
let borderColor = selected ? theme.colors.primary : theme.colors.text.default;
|
|
@@ -22,11 +29,20 @@ const Radio: FC<RadioProps> = props => {
|
|
|
22
29
|
<TouchableOpacity
|
|
23
30
|
onPress={onChange}
|
|
24
31
|
disabled={disabled}
|
|
25
|
-
style={
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
style={[
|
|
33
|
+
style,
|
|
34
|
+
{
|
|
35
|
+
flexDirection: 'row',
|
|
36
|
+
alignItems: 'center',
|
|
37
|
+
},
|
|
38
|
+
]}>
|
|
39
|
+
<View
|
|
40
|
+
style={[
|
|
41
|
+
styles.radio,
|
|
42
|
+
{borderWidth, borderColor, marginRight: !!label ? Spacing.XS : 0},
|
|
43
|
+
]}
|
|
44
|
+
/>
|
|
45
|
+
{!!label && <Text typography={'description_default'}>{label}</Text>}
|
|
30
46
|
</TouchableOpacity>
|
|
31
47
|
);
|
|
32
48
|
};
|
package/Radio/types.ts
CHANGED
package/Switch/index.tsx
CHANGED
|
@@ -7,22 +7,24 @@ import {Colors} from '../Consts';
|
|
|
7
7
|
|
|
8
8
|
const Switch: FC<SwitchProps> = props => {
|
|
9
9
|
const {theme} = useContext(ApplicationContext);
|
|
10
|
-
const {value, onChange, disabled} = props;
|
|
10
|
+
const {value, onChange, disabled, style} = props;
|
|
11
|
+
const circleBackgroundColor = value ? Colors.black_01 : Colors.black_03;
|
|
12
|
+
const circleAlign = value ? 'flex-end' : 'flex-start';
|
|
11
13
|
|
|
12
14
|
let backgroundColor = value ? theme.colors.primary : Colors.black_07;
|
|
13
|
-
|
|
14
|
-
const circleBackgroundColor = value ? Colors.black_01 : Colors.black_03;
|
|
15
15
|
if (disabled) {
|
|
16
16
|
backgroundColor = value ? theme.colors.background.tonal : Colors.black_05;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
const circleAlign = value ? 'flex-end' : 'flex-start';
|
|
20
|
-
|
|
21
19
|
return (
|
|
22
20
|
<TouchableOpacity
|
|
23
21
|
disabled={disabled}
|
|
24
22
|
onPress={() => onChange?.(!value)}
|
|
25
|
-
style={[
|
|
23
|
+
style={[
|
|
24
|
+
style,
|
|
25
|
+
styles.container,
|
|
26
|
+
{backgroundColor, alignItems: circleAlign},
|
|
27
|
+
]}>
|
|
26
28
|
<View style={[styles.circle, {backgroundColor: circleBackgroundColor}]}>
|
|
27
29
|
<View style={[styles.circleSmall, {backgroundColor}]} />
|
|
28
30
|
</View>
|
package/Switch/types.ts
CHANGED