@momo-kits/foundation 0.75.1-beta.8 → 0.75.2-beta.0

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.
Files changed (112) hide show
  1. package/Application/BottomTab/BottomTabBar.tsx +478 -0
  2. package/Application/BottomTab/index.tsx +134 -0
  3. package/Application/Components.tsx +552 -0
  4. package/Application/ModalScreen.tsx +244 -0
  5. package/Application/Navigation.ts +50 -0
  6. package/Application/NavigationContainer.tsx +128 -0
  7. package/Application/Navigator.ts +151 -0
  8. package/Application/StackScreen.tsx +146 -0
  9. package/Application/index.ts +37 -0
  10. package/{Navigation → Application}/types.ts +96 -27
  11. package/Application/utils.tsx +175 -0
  12. package/Assets/DotAnimation.json +256 -0
  13. package/Assets/SpinnerAnimation.json +1027 -0
  14. package/Assets/icon.json +89 -5
  15. package/Assets/icon_bank.json +506 -0
  16. package/Assets/language.json +202 -0
  17. package/Badge/Badge.tsx +56 -0
  18. package/Badge/BadgeDot.tsx +11 -0
  19. package/Badge/BadgeRibbon.tsx +125 -0
  20. package/Badge/Shape.tsx +29 -0
  21. package/Badge/index.tsx +7 -0
  22. package/Badge/styles.ts +58 -0
  23. package/Badge/types.ts +63 -0
  24. package/Button/index.tsx +90 -39
  25. package/Button/styles.ts +19 -0
  26. package/CheckBox/index.tsx +58 -43
  27. package/CheckBox/styles.ts +1 -1
  28. package/CheckBox/types.ts +6 -4
  29. package/Consts/colors+spacing+radius.ts +18 -0
  30. package/Consts/styles.ts +0 -26
  31. package/Consts/theme.ts +5 -1
  32. package/Divider/index.tsx +3 -1
  33. package/Icon/index.tsx +14 -10
  34. package/Icon/types.ts +4 -3
  35. package/IconButton/index.tsx +24 -15
  36. package/Image/index.tsx +63 -45
  37. package/Image/styles.ts +1 -9
  38. package/Image/types.ts +5 -1
  39. package/Input/Input.tsx +227 -115
  40. package/Input/InputDropDown.tsx +132 -0
  41. package/Input/InputMoney.tsx +174 -110
  42. package/Input/InputOTP.tsx +257 -0
  43. package/Input/InputSearch.tsx +160 -130
  44. package/Input/InputTextArea.tsx +149 -121
  45. package/Input/common.tsx +43 -18
  46. package/Input/index.tsx +205 -17
  47. package/Input/styles.ts +44 -7
  48. package/Input/utils.ts +2 -2
  49. package/Layout/Card.tsx +154 -62
  50. package/Layout/FloatingButton.tsx +128 -0
  51. package/Layout/GridSystem.tsx +35 -23
  52. package/Layout/Item.tsx +56 -0
  53. package/Layout/ItemList.tsx +55 -0
  54. package/Layout/ItemSectionList.tsx +39 -0
  55. package/Layout/Screen.tsx +378 -0
  56. package/Layout/Section.tsx +74 -39
  57. package/Layout/index.ts +14 -3
  58. package/Layout/styles.ts +101 -0
  59. package/Layout/types.ts +1 -39
  60. package/Layout/utils.ts +42 -37
  61. package/Loader/DotLoader.tsx +37 -0
  62. package/Loader/Loader.tsx +13 -0
  63. package/Loader/ProgressBar.tsx +44 -0
  64. package/Loader/Spinner.tsx +29 -0
  65. package/Loader/index.tsx +4 -0
  66. package/Loader/styles.ts +10 -0
  67. package/Loader/types.ts +35 -0
  68. package/Loader/utils.ts +25 -0
  69. package/Pagination/Dot.tsx +1 -1
  70. package/Pagination/PaginationDot.tsx +8 -3
  71. package/Pagination/PaginationNumber.tsx +8 -7
  72. package/Pagination/PaginationScroll.tsx +1 -1
  73. package/Pagination/PaginationWhiteDot.tsx +8 -5
  74. package/Pagination/styles.ts +3 -0
  75. package/Pagination/types.ts +2 -0
  76. package/Popup/PopupNotify.tsx +102 -44
  77. package/Popup/PopupPromotion.tsx +63 -22
  78. package/Popup/types.ts +15 -4
  79. package/Radio/index.tsx +35 -21
  80. package/Radio/types.ts +7 -5
  81. package/Skeleton/index.tsx +1 -1
  82. package/Skeleton/types.ts +3 -0
  83. package/Switch/index.tsx +35 -24
  84. package/Switch/types.ts +5 -3
  85. package/Tag/index.tsx +1 -1
  86. package/Text/index.tsx +32 -26
  87. package/Text/styles.ts +38 -0
  88. package/Text/types.ts +25 -13
  89. package/Text/utils.ts +14 -0
  90. package/Title/index.tsx +186 -0
  91. package/Title/styles.ts +79 -0
  92. package/Title/types.ts +20 -0
  93. package/code-scanner.js +143 -0
  94. package/index.ts +17 -3
  95. package/migrate_typo.js +56 -0
  96. package/package.json +44 -39
  97. package/publish.sh +2 -5
  98. package/tsconfig.json +24 -0
  99. package/verify.js +47 -0
  100. package/Assets/header-background.png +0 -0
  101. package/Layout/ScreenContainer.tsx +0 -122
  102. package/Navigation/BottomTab.tsx +0 -39
  103. package/Navigation/Components.tsx +0 -365
  104. package/Navigation/ModalScreen.tsx +0 -226
  105. package/Navigation/Navigation.ts +0 -44
  106. package/Navigation/NavigationButton.tsx +0 -54
  107. package/Navigation/NavigationContainer.tsx +0 -77
  108. package/Navigation/Navigator.ts +0 -82
  109. package/Navigation/Observer.ts +0 -79
  110. package/Navigation/StackScreen.tsx +0 -27
  111. package/Navigation/index.ts +0 -14
  112. package/Navigation/utils.tsx +0 -137
@@ -1,365 +0,0 @@
1
- import React, {useContext, useEffect, useState} from 'react';
2
- import {
3
- Animated,
4
- DeviceEventEmitter,
5
- StatusBar,
6
- StyleSheet,
7
- TouchableOpacity,
8
- View,
9
- } from 'react-native';
10
- import {ApplicationContext, NavigationButton} from './index';
11
- import {Colors, Radius, Spacing, Styles} from '../Consts';
12
- import {Image} from '../Image';
13
- import {
14
- HeaderBackgroundProps,
15
- HeaderBackProps,
16
- HeaderToolkitProps,
17
- TitleCustomProps,
18
- } from './types';
19
- import {Text} from '../Text';
20
- import {Icon} from '../Icon';
21
- import Observer from './Observer';
22
- import {PopupNotify} from '../Popup';
23
-
24
- const styles = StyleSheet.create({
25
- headerBackground: {
26
- width: '100%',
27
- height: undefined,
28
- position: 'absolute',
29
- aspectRatio: 375 / 154,
30
- },
31
- headerTitleContainer: {
32
- alignItems: 'center',
33
- justifyContent: 'center',
34
- width: '100%',
35
- },
36
- circle: {width: 36, height: 36, borderRadius: 18},
37
- square: {width: 36, height: 36, borderRadius: Radius.XS},
38
- dotAvatar: {
39
- position: 'absolute',
40
- width: 12,
41
- height: 12,
42
- borderRadius: 6,
43
- bottom: 0,
44
- right: 0,
45
- borderWidth: 1,
46
- borderColor: Colors.black_01,
47
- },
48
- headerRightButton: {
49
- flexDirection: 'row',
50
- overflow: 'hidden',
51
- justifyContent: 'center',
52
- alignItems: 'center',
53
- paddingRight: Spacing.M,
54
- },
55
- toolkitContainer: {
56
- marginLeft: Spacing.S,
57
- padding: Spacing.XS,
58
- height: 28,
59
- borderRadius: 14,
60
- borderColor: '#00000066',
61
- justifyContent: 'center',
62
- alignItems: 'center',
63
- flexDirection: 'row',
64
- },
65
- divider: {
66
- width: 1,
67
- height: 12,
68
- marginHorizontal: 4,
69
- },
70
- headerLeft: {
71
- marginLeft: 12,
72
- },
73
- title: {fontSize: 15, lineHeight: 22, fontWeight: 'bold'},
74
- });
75
-
76
- const HeaderTitle: React.FC<any> = props => {
77
- const {theme} = useContext(ApplicationContext);
78
- const opacity = props.animatedValue?.interpolate({
79
- inputRange: [0, 200],
80
- outputRange: [0, 1],
81
- extrapolate: 'clamp',
82
- });
83
- return (
84
- <Animated.Text
85
- {...props}
86
- accessibilityLabel={`HeaderTitle/${props.children}`}
87
- style={[
88
- styles.title,
89
- {fontFamily: `${theme.font}-Bold`, opacity, color: props.tintColor},
90
- ]}
91
- />
92
- );
93
- };
94
-
95
- const HeaderLeft: React.FC<HeaderBackProps> = ({
96
- tintColor,
97
- preventBack,
98
- useBorder,
99
- backgroundColor,
100
- }) => {
101
- const {navigator} = useContext(ApplicationContext);
102
- const goBack = () => {
103
- const canGoBack = navigator?.ref.current?.canGoBack();
104
- if (canGoBack) {
105
- if (preventBack) {
106
- navigator?.showModal({
107
- screen: () => (
108
- <PopupNotify
109
- {...preventBack}
110
- primary={{
111
- title: preventBack.primary.title,
112
- onPress: () => {
113
- preventBack?.primary.onPress();
114
- navigator?.ref.current?.goBack();
115
- },
116
- }}
117
- />
118
- ),
119
- });
120
- } else {
121
- navigator?.ref.current?.goBack();
122
- }
123
- } else {
124
- const currentTime = new Date().getTime();
125
- const requestId = `navigationBackPress#${currentTime}`;
126
- DeviceEventEmitter.emit('dismiss', {requestId});
127
- }
128
- };
129
-
130
- return (
131
- <View style={styles.headerLeft}>
132
- <NavigationButton
133
- icon="ic_back"
134
- tintColor={tintColor}
135
- onPress={goBack}
136
- accessibilityLabel={'Back'}
137
- useBorder={useBorder}
138
- backgroundColor={backgroundColor}
139
- />
140
- </View>
141
- );
142
- };
143
-
144
- const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
145
- image,
146
- backgroundColor,
147
- animatedValue,
148
- }) => {
149
- const {theme} = useContext(ApplicationContext);
150
- let headerImage = theme.assets?.headerBackground;
151
- if (image === null) {
152
- headerImage = undefined;
153
- }
154
- const opacity = animatedValue?.interpolate({
155
- inputRange: [0, 200],
156
- outputRange: [0, 1],
157
- extrapolate: 'clamp',
158
- });
159
-
160
- return (
161
- <Animated.View
162
- style={[
163
- Styles.flex,
164
- {
165
- backgroundColor: backgroundColor ?? theme.colors.background.default,
166
- overflow: 'hidden',
167
- borderBottomWidth: headerImage ? 0 : 1,
168
- borderColor: theme.colors.border.default,
169
- opacity,
170
- },
171
- ]}>
172
- <StatusBar
173
- barStyle={headerImage || theme.dark ? 'light-content' : 'dark-content'}
174
- />
175
- {!!headerImage && (
176
- <Image style={styles.headerBackground} source={{uri: headerImage}} />
177
- )}
178
- </Animated.View>
179
- );
180
- };
181
-
182
- const HeaderCustom: React.FC<TitleCustomProps> = ({
183
- title,
184
- subTitle,
185
- image,
186
- imageShape = 'circle',
187
- content,
188
- tintColor,
189
- dotColor,
190
- }) => {
191
- const avatarStyle = imageShape == 'circle' ? styles.circle : styles.square;
192
- const header = (
193
- <View style={Styles.row}>
194
- <View>
195
- <Image source={{uri: image}} style={avatarStyle} />
196
- {!!dotColor && (
197
- <View style={[styles.dotAvatar, {backgroundColor: dotColor}]} />
198
- )}
199
- </View>
200
- <View style={[Styles.flex, Styles.paddingHorizontal8]}>
201
- <Text typography="title_xs" color={tintColor}>
202
- {title}
203
- </Text>
204
- <Text typography="description_s" color={tintColor}>
205
- {subTitle}
206
- </Text>
207
- </View>
208
- </View>
209
- );
210
- return <View style={styles.headerTitleContainer}>{content ?? header}</View>;
211
- };
212
-
213
- const HeaderRightAction: React.FC<any> = ({children, ...restProps}) => {
214
- const validType = (item: any) => {
215
- if (item.type !== NavigationButton) {
216
- console.warn(
217
- 'element type of NavigationButton, Please migrate to use NavigationButton of kits.',
218
- );
219
- return <View />;
220
- }
221
- };
222
- const renderAction = () => {
223
- if (Array.isArray(children)) {
224
- return children.map((child, index) => {
225
- if (__DEV__) {
226
- validType(child);
227
- }
228
- return (
229
- <React.Fragment key={index}>
230
- {React.cloneElement(child, {...restProps})}
231
- </React.Fragment>
232
- );
233
- });
234
- }
235
-
236
- validType(children);
237
- return React.cloneElement(children, {...restProps});
238
- };
239
- return <View style={styles.headerRightButton}>{renderAction()}</View>;
240
- };
241
-
242
- const HeaderToolkitAction: React.FC<any> = ({tintColor}) => {
243
- const {theme, navigator} = useContext(ApplicationContext);
244
- const [toolConfig, setToolConfig] = useState<HeaderToolkitProps>();
245
- const {appCode, hidden, type, onAction} = toolConfig ?? {};
246
-
247
- let backgroundColor;
248
- if (tintColor != Colors.black_01) {
249
- backgroundColor = theme.colors.background.surface;
250
- }
251
-
252
- useEffect(() => {
253
- navigator?.getToolkit().then(toolConfig => {
254
- setToolConfig(toolConfig);
255
- });
256
- }, []);
257
-
258
- useEffect(() => {
259
- let addFavorite: any;
260
- let removeFavorite: any;
261
- if (appCode) {
262
- const addSchema = `observerToolkit_addFavorite_${appCode}`;
263
- const removeSchema = `observerToolkit_removeFavorite_${appCode}`;
264
- addFavorite = navigator?.requestApi(
265
- 'observer',
266
- [addSchema],
267
- (data: any) => {
268
- if (data?.status) {
269
- setToolConfig({
270
- ...(toolConfig as HeaderToolkitProps),
271
- hidden: true,
272
- });
273
- }
274
- },
275
- );
276
- addFavorite = navigator?.requestApi(
277
- 'observer',
278
- [removeSchema],
279
- (data: any) => {
280
- if (data?.status) {
281
- setToolConfig({
282
- ...(toolConfig as HeaderToolkitProps),
283
- hidden: false,
284
- });
285
- }
286
- },
287
- );
288
- }
289
-
290
- return () => {
291
- addFavorite?.();
292
- removeFavorite?.();
293
- };
294
- }, [appCode]);
295
-
296
- const onUtilityTool = () => {
297
- onAction?.('onUtilityTool');
298
- navigator?.requestApi(type, undefined, undefined);
299
- };
300
-
301
- const onMore = () => {
302
- onAction?.('onMore');
303
- navigator?.requestApi('showToolkit', [toolConfig], undefined);
304
- };
305
-
306
- const onClose = () => {
307
- onAction?.('onClose');
308
- navigator?.requestApi('dismiss', undefined, undefined);
309
- };
310
-
311
- const renderUtilityTool = () => {
312
- if (toolConfig?.hidden === false) {
313
- return (
314
- <NavigationButton
315
- icon={type as string}
316
- tintColor={tintColor}
317
- onPress={onUtilityTool}
318
- />
319
- );
320
- }
321
- };
322
-
323
- if (toolConfig) {
324
- return (
325
- <View style={styles.headerRightButton}>
326
- {renderUtilityTool()}
327
- <View
328
- style={[
329
- styles.toolkitContainer,
330
- {
331
- backgroundColor: backgroundColor ?? '#00000066',
332
- borderWidth: backgroundColor ? 0.5 : 0,
333
- },
334
- ]}>
335
- <TouchableOpacity
336
- accessibilityLabel={'Toolkit/More'}
337
- onPress={onMore}>
338
- <Icon color={tintColor} source="navigation_more_horiz" size={20} />
339
- </TouchableOpacity>
340
- <View style={[styles.divider, {backgroundColor: tintColor}]} />
341
- <TouchableOpacity
342
- accessibilityLabel={'Toolkit/Close'}
343
- onPress={onClose}>
344
- <Icon
345
- color={tintColor}
346
- source="16_navigation_close_circle"
347
- size={20}
348
- />
349
- </TouchableOpacity>
350
- </View>
351
- </View>
352
- );
353
- }
354
-
355
- return <View />;
356
- };
357
-
358
- export {
359
- HeaderTitle,
360
- HeaderLeft,
361
- HeaderBackground,
362
- HeaderRightAction,
363
- HeaderToolkitAction,
364
- HeaderCustom,
365
- };
@@ -1,226 +0,0 @@
1
- import React, {useContext, useEffect, useMemo, useRef} from 'react';
2
- import {
3
- KeyboardAvoidingView,
4
- Platform,
5
- Pressable,
6
- StyleSheet,
7
- View,
8
- } from 'react-native';
9
- import {SafeAreaView, useSafeAreaInsets} from 'react-native-safe-area-context';
10
- import {BottomSheetBackdrop, BottomSheetModal} from '@gorhom/bottom-sheet';
11
- import {BottomSheetModalMethods} from '@gorhom/bottom-sheet/lib/typescript/types';
12
- import Navigation from './Navigation';
13
- import {BottomSheetParams, ModalParams} from './types';
14
- import {Radius, Spacing, Styles} from '../Consts';
15
- import {
16
- ApplicationContext,
17
- HeaderRightAction,
18
- NavigationButton,
19
- NavigationContainer,
20
- } from './index';
21
- import {HeaderBackground, HeaderLeft} from './Components';
22
-
23
- const ModalScreen: React.FC<any> = props => {
24
- useEffect(() => {
25
- return () => {
26
- props.route.params?.onDismiss?.();
27
- };
28
- }, []);
29
-
30
- if (props.route?.params?.isBottomSheet) {
31
- return <BottomSheet {...props} />;
32
- }
33
- return <Modal {...props} />;
34
- };
35
-
36
- const Modal: React.FC<ModalParams> = ({navigation, route}) => {
37
- const {theme} = useContext(ApplicationContext);
38
- const {screen, barrierDismissible}: ModalParams = route.params;
39
- const Component = useRef(screen).current;
40
- const params = {
41
- ...route.params,
42
- navigation: new Navigation(navigation, theme),
43
- };
44
- delete params.screen;
45
-
46
- const onDismiss = (pop = true) => {
47
- if (barrierDismissible) {
48
- return;
49
- }
50
- navigation.pop();
51
- };
52
-
53
- return (
54
- <KeyboardAvoidingView
55
- style={Styles.flex}
56
- behavior={Platform.OS === 'ios' ? 'padding' : 'height'}>
57
- <View style={styles.container}>
58
- <Pressable
59
- style={styles.modalSpaceHorizontal}
60
- onPress={() => onDismiss()}
61
- />
62
- <View style={styles.modalCenterStage}>
63
- <Pressable
64
- style={styles.modalSpaceVertical}
65
- onPress={() => onDismiss()}
66
- />
67
- <View style={styles.modalContent} accessibilityLabel={'Modal'}>
68
- <Component {...params} />
69
- </View>
70
- <Pressable
71
- style={styles.modalSpaceVertical}
72
- onPress={() => onDismiss()}
73
- />
74
- </View>
75
- <Pressable
76
- style={styles.modalSpaceHorizontal}
77
- onPress={() => onDismiss()}
78
- />
79
- </View>
80
- </KeyboardAvoidingView>
81
- );
82
- };
83
-
84
- const BottomSheet: React.FC<BottomSheetParams> = ({navigation, route}) => {
85
- const {theme} = useContext(ApplicationContext);
86
- const {screen, options}: BottomSheetParams = route.params;
87
- const Component = useRef(screen).current;
88
- const params = {
89
- ...route.params,
90
- navigation: new Navigation(navigation, theme),
91
- };
92
- delete params.screen;
93
-
94
- const snapPoints = useMemo(() => ['50%', '90%'], []);
95
- const {bottom} = useSafeAreaInsets();
96
- const bottomSheetRef = useRef<BottomSheetModalMethods>(null);
97
- const mountedRef = useRef(true);
98
-
99
- useEffect(() => {
100
- bottomSheetRef.current?.present();
101
- return () => {
102
- mountedRef.current = false;
103
- };
104
- }, []);
105
-
106
- const backdropComponent = (backdropProps: any) => (
107
- <BottomSheetBackdrop
108
- disappearsOnIndex={-1}
109
- appearsOnIndex={0}
110
- {...backdropProps}
111
- />
112
- );
113
-
114
- let backgroundColor = theme.colors.background.default;
115
- if (options?.surface) {
116
- backgroundColor = theme.colors.background.surface;
117
- }
118
-
119
- return (
120
- <SafeAreaView style={Styles.flex}>
121
- <BottomSheetModal
122
- ref={bottomSheetRef}
123
- snapPoints={snapPoints}
124
- onDismiss={() => {
125
- if (mountedRef.current) {
126
- navigation.pop();
127
- }
128
- }}
129
- handleComponent={null}
130
- backdropComponent={backdropComponent}>
131
- <View
132
- style={{paddingBottom: bottom}}
133
- accessibilityLabel={'BottomSheet'}>
134
- <View style={[styles.sheetContainer, {backgroundColor}]}>
135
- <View style={styles.indicatorContainer}>
136
- <View
137
- style={[
138
- styles.indicator,
139
- {backgroundColor: theme.colors.text.disable},
140
- ]}
141
- />
142
- </View>
143
- <NavigationContainer
144
- theme={{
145
- ...theme,
146
- assets: {...theme.assets, headerBackground: undefined},
147
- }}
148
- screen={props => <Component {...props} {...params} />}
149
- options={{
150
- ...options,
151
- ...{
152
- headerLeft: (props: any) => {
153
- if (props.canGoBack) {
154
- return (
155
- <HeaderLeft
156
- {...props}
157
- useBorder={false}
158
- backgroundColor="transparent"
159
- />
160
- );
161
- }
162
- },
163
- headerBackground: () => (
164
- <HeaderBackground backgroundColor={backgroundColor} />
165
- ),
166
- headerTransparent: false,
167
- },
168
- headerTitleAlign: 'center',
169
- headerRight: props => (
170
- <HeaderRightAction>
171
- <NavigationButton
172
- {...props}
173
- icon="24_navigation_close"
174
- backgroundColor="transparent"
175
- useBorder={false}
176
- onPress={bottomSheetRef.current?.dismiss}
177
- />
178
- </HeaderRightAction>
179
- ),
180
- }}
181
- />
182
- </View>
183
- </View>
184
- </BottomSheetModal>
185
- </SafeAreaView>
186
- );
187
- };
188
-
189
- const styles = StyleSheet.create({
190
- container: {flex: 1, flexDirection: 'row'},
191
- modalContent: {
192
- maxWidth: '100%',
193
- maxHeight: '80%',
194
- },
195
- modalCenterStage: {
196
- maxWidth: '90%',
197
- },
198
- modalSpaceHorizontal: {
199
- flex: 1,
200
- minWidth: '5%',
201
- },
202
- modalSpaceVertical: {
203
- flex: 1,
204
- minHeight: '10%',
205
- },
206
- sheetContainer: {
207
- height: '100%',
208
- width: '100%',
209
- borderTopLeftRadius: Radius.M,
210
- borderTopRightRadius: Radius.M,
211
- overflow: 'hidden',
212
- },
213
- indicatorContainer: {
214
- width: '100%',
215
- paddingTop: Spacing.S,
216
- alignItems: 'center',
217
- justifyContent: 'center',
218
- },
219
- indicator: {
220
- width: 64,
221
- height: 4,
222
- borderRadius: Radius.S,
223
- },
224
- });
225
-
226
- export default ModalScreen;
@@ -1,44 +0,0 @@
1
- import {NavigationProp} from '@react-navigation/native';
2
- import {NavigationOptions, Theme} from './types';
3
- import {HeaderRightAction} from './index';
4
- import {getOptions} from './utils';
5
- import {HeaderToolkitAction} from './Components';
6
-
7
- class Navigation {
8
- instance: NavigationProp<any>;
9
- theme: Theme;
10
-
11
- constructor(instance: any, theme: Theme) {
12
- this.instance = instance;
13
- this.theme = theme;
14
- }
15
-
16
- verifyParams = (params: NavigationOptions) => {
17
- if (params.headerRight) {
18
- const headerRight = params.headerRight?.();
19
- if (
20
- headerRight?.type !== HeaderRightAction &&
21
- headerRight?.type !== HeaderToolkitAction
22
- ) {
23
- console.warn(
24
- 'headerRight not return element type of HeaderRightAction | HeaderToolkitAction, Please migrate to use of kits.',
25
- );
26
- }
27
- }
28
- return params;
29
- };
30
-
31
- filterParams = (params: NavigationOptions) => {
32
- return params;
33
- };
34
-
35
- setOptions = (params: NavigationOptions) => {
36
- if (__DEV__) {
37
- params = this.verifyParams(params);
38
- }
39
- params = getOptions(params, this.theme);
40
- this.instance.setOptions(params);
41
- };
42
- }
43
-
44
- export default Navigation;
@@ -1,54 +0,0 @@
1
- import {Platform, StyleSheet, TouchableOpacity as TouchRN} from 'react-native';
2
- import {TouchableOpacity as TouchGesture} from 'react-native-gesture-handler';
3
- import React, {useContext} from 'react';
4
- import {NavigationButtonProps} from './types';
5
- import {ApplicationContext} from './index';
6
- import {Icon} from '../Icon';
7
- import {Colors} from '../Consts';
8
-
9
- const TouchableOpacity = Platform.OS === 'ios' ? TouchRN : TouchGesture;
10
- const NavigationButton: React.FC<NavigationButtonProps> = ({
11
- icon,
12
- tintColor,
13
- onPress,
14
- backgroundColor,
15
- useBorder = true,
16
- accessibilityLabel,
17
- }) => {
18
- const {theme} = useContext(ApplicationContext);
19
- if (!backgroundColor && tintColor != Colors.black_01) {
20
- backgroundColor = theme.colors.background.surface;
21
- }
22
-
23
- return (
24
- <TouchableOpacity
25
- accessibilityLabel={`NavigationButton/${accessibilityLabel}`}
26
- style={[
27
- styles.container,
28
- {
29
- backgroundColor: backgroundColor ?? '#00000066',
30
- borderWidth: useBorder && backgroundColor ? 0.5 : 0,
31
- },
32
- ]}
33
- onPress={onPress}>
34
- <Icon
35
- source={icon}
36
- color={tintColor ?? theme.colors.text.default}
37
- size={20}
38
- />
39
- </TouchableOpacity>
40
- );
41
- };
42
-
43
- const styles = StyleSheet.create({
44
- container: {
45
- height: 28,
46
- width: 28,
47
- borderRadius: 14,
48
- borderColor: '#00000066',
49
- justifyContent: 'center',
50
- alignItems: 'center',
51
- },
52
- });
53
-
54
- export default NavigationButton;