@momo-kits/foundation 0.76.1-beta.2 → 0.77.1-optimize.2
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/Application/BottomTab/BottomTabBar.tsx +478 -0
- package/Application/BottomTab/index.tsx +134 -0
- package/Application/Components.tsx +339 -161
- package/Application/ModalScreen.tsx +113 -99
- package/Application/Navigation.ts +22 -16
- package/Application/NavigationContainer.tsx +99 -48
- package/Application/Navigator.ts +110 -41
- package/Application/StackScreen.tsx +126 -8
- package/Application/index.ts +23 -4
- package/Application/types.ts +84 -33
- package/Application/utils.tsx +90 -50
- package/Assets/DotAnimation.json +256 -0
- package/Assets/SpinnerAnimation.json +1027 -0
- package/Assets/icon.json +83 -5
- package/Assets/icon_bank.json +506 -0
- package/Assets/language.json +202 -0
- package/Badge/Badge.tsx +56 -0
- package/Badge/BadgeDot.tsx +11 -0
- package/Badge/BadgeRibbon.tsx +125 -0
- package/Badge/Shape.tsx +29 -0
- package/Badge/index.tsx +7 -0
- package/Badge/styles.ts +58 -0
- package/Badge/types.ts +63 -0
- package/Button/index.tsx +90 -39
- package/Button/styles.ts +19 -0
- package/CheckBox/index.tsx +58 -43
- package/CheckBox/styles.ts +1 -1
- package/CheckBox/types.ts +6 -4
- package/Consts/colors+spacing+radius.ts +18 -0
- package/Consts/styles.ts +0 -26
- package/Consts/theme.ts +4 -0
- package/Divider/index.tsx +2 -0
- package/Icon/index.tsx +13 -9
- package/Icon/types.ts +4 -3
- package/IconButton/index.tsx +24 -15
- package/Image/index.tsx +60 -48
- package/Image/styles.ts +1 -9
- package/Image/types.ts +5 -1
- package/Input/Input.tsx +227 -116
- package/Input/InputDropDown.tsx +132 -0
- package/Input/InputMoney.tsx +174 -111
- package/Input/InputOTP.tsx +257 -0
- package/Input/InputSearch.tsx +160 -132
- package/Input/InputTextArea.tsx +150 -123
- package/Input/common.tsx +42 -17
- package/Input/index.tsx +204 -18
- package/Input/styles.ts +44 -7
- package/Input/utils.ts +2 -2
- package/Layout/Card.tsx +67 -29
- package/Layout/FloatingButton.tsx +128 -0
- package/Layout/GridSystem.tsx +31 -21
- package/Layout/Item.tsx +21 -25
- package/Layout/ItemList.tsx +55 -0
- package/Layout/ItemSectionList.tsx +39 -0
- package/Layout/Screen.tsx +348 -153
- package/Layout/Section.tsx +66 -34
- package/Layout/index.ts +13 -3
- package/Layout/styles.ts +101 -0
- package/Layout/types.ts +1 -39
- package/Layout/utils.ts +27 -52
- package/Loader/DotLoader.tsx +37 -0
- package/Loader/Loader.tsx +13 -0
- package/Loader/ProgressBar.tsx +44 -0
- package/Loader/Spinner.tsx +29 -0
- package/Loader/index.tsx +4 -0
- package/Loader/styles.ts +10 -0
- package/Loader/types.ts +35 -0
- package/Loader/utils.ts +25 -0
- package/Pagination/PaginationDot.tsx +7 -2
- package/Pagination/PaginationNumber.tsx +8 -6
- package/Pagination/PaginationScroll.tsx +0 -1
- package/Pagination/PaginationWhiteDot.tsx +8 -5
- package/Pagination/styles.ts +3 -0
- package/Pagination/types.ts +2 -0
- package/Popup/PopupNotify.tsx +102 -44
- package/Popup/PopupPromotion.tsx +63 -22
- package/Popup/types.ts +15 -4
- package/Radio/index.tsx +35 -21
- package/Radio/types.ts +7 -5
- package/Skeleton/index.tsx +1 -1
- package/Skeleton/types.ts +3 -0
- package/Switch/index.tsx +35 -24
- package/Switch/types.ts +5 -3
- package/Tag/index.tsx +2 -4
- package/Text/index.tsx +27 -22
- package/Text/styles.ts +38 -0
- package/Text/types.ts +25 -13
- package/Text/utils.ts +1 -1
- package/Title/index.tsx +186 -0
- package/Title/styles.ts +79 -0
- package/Title/types.ts +20 -0
- package/code-scanner.js +143 -0
- package/index.ts +8 -1
- package/migrate_typo.js +56 -0
- package/package.json +14 -9
- package/tsconfig.json +24 -0
- package/verify.js +47 -0
- package/Application/BottomTab.tsx +0 -52
- package/Application/NavigationButton.tsx +0 -54
- package/Assets/header-background.png +0 -0
package/Layout/Screen.tsx
CHANGED
|
@@ -1,188 +1,383 @@
|
|
|
1
|
+
import {useHeaderHeight} from '@react-navigation/stack';
|
|
2
|
+
import React, {
|
|
3
|
+
forwardRef,
|
|
4
|
+
Fragment,
|
|
5
|
+
ReactNode,
|
|
6
|
+
useContext,
|
|
7
|
+
useEffect,
|
|
8
|
+
useRef,
|
|
9
|
+
} from 'react';
|
|
1
10
|
import {
|
|
2
11
|
Animated,
|
|
3
12
|
KeyboardAvoidingView,
|
|
13
|
+
NativeScrollEvent,
|
|
14
|
+
NativeSyntheticEvent,
|
|
4
15
|
Platform,
|
|
5
|
-
|
|
16
|
+
ScrollViewProps,
|
|
6
17
|
View,
|
|
18
|
+
ViewProps,
|
|
7
19
|
} from 'react-native';
|
|
8
|
-
import {useHeaderHeight} from '@react-navigation/stack';
|
|
9
20
|
import {useSafeAreaInsets} from 'react-native-safe-area-context';
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
21
|
+
import {
|
|
22
|
+
ApplicationContext,
|
|
23
|
+
HeaderBackground,
|
|
24
|
+
HeaderTitle,
|
|
25
|
+
} from '../Application';
|
|
15
26
|
import Navigation from '../Application/Navigation';
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
marginHeader,
|
|
24
|
-
useAnimatedHeader = false,
|
|
25
|
-
useExtendedHeader = false,
|
|
26
|
-
headerBackground,
|
|
27
|
-
scrollViewProps,
|
|
28
|
-
footerComponent: Footer,
|
|
29
|
-
}) => {
|
|
30
|
-
const animatedValue = useRef<Animated.Value | undefined>(undefined);
|
|
31
|
-
const {theme} = useContext(ApplicationContext);
|
|
32
|
-
const insets = useSafeAreaInsets();
|
|
33
|
-
const headerTransparent = useAnimatedHeader || useExtendedHeader;
|
|
34
|
-
|
|
35
|
-
let handleScroll;
|
|
36
|
-
let imageAnimatedStyle = {};
|
|
37
|
-
let opacity;
|
|
38
|
-
let Component: any = View;
|
|
39
|
-
animatedValue.current = undefined;
|
|
27
|
+
import {AnimatedHeader, NavigationOptions} from '../Application/types';
|
|
28
|
+
import {Colors, Spacing, Styles} from '../Consts';
|
|
29
|
+
import {FloatingButton, FloatingButtonProps} from './FloatingButton';
|
|
30
|
+
import {Image} from '../Image';
|
|
31
|
+
import {Card, Section, validateChildren} from './index';
|
|
32
|
+
import styles from './styles';
|
|
33
|
+
import {HeaderType} from './types';
|
|
40
34
|
|
|
35
|
+
export interface ScreenProps extends ViewProps {
|
|
36
|
+
children: React.ReactNode;
|
|
41
37
|
/**
|
|
42
|
-
*
|
|
38
|
+
* Optional. Navigation object for handling navigation actions.
|
|
43
39
|
*/
|
|
44
|
-
|
|
45
|
-
animatedValue.current = new Animated.Value(0);
|
|
46
|
-
marginHeader = marginHeader ?? useHeaderHeight();
|
|
47
|
-
if (useExtendedHeader) {
|
|
48
|
-
headerBackground = theme.assets?.headerBackground;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
40
|
+
navigation?: Navigation;
|
|
51
41
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
navigation?.setOptions({
|
|
58
|
-
animatedValue: animatedValue.current,
|
|
59
|
-
headerTransparent,
|
|
60
|
-
...title,
|
|
61
|
-
});
|
|
62
|
-
}, [useExtendedHeader, useAnimatedHeader]);
|
|
42
|
+
/**
|
|
43
|
+
* Optional. If `true`, enable keyboard avoiding view for the screen.
|
|
44
|
+
*/
|
|
45
|
+
enableKeyboardAvoidingView?: boolean;
|
|
63
46
|
|
|
64
47
|
/**
|
|
65
|
-
*
|
|
48
|
+
* Optional. If `true`, the screen content is scrollable.
|
|
66
49
|
*/
|
|
67
|
-
|
|
68
|
-
const current: any = navigation;
|
|
69
|
-
if (headerTransparent) {
|
|
70
|
-
return current?.addListener?.('focus', () => {
|
|
71
|
-
const stackNavigation = new Navigation(current?.getParent(), theme);
|
|
72
|
-
stackNavigation?.setOptions({
|
|
73
|
-
animatedValue: animatedValue.current,
|
|
74
|
-
headerTransparent: true,
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
}, [useAnimatedHeader, useExtendedHeader, navigation]);
|
|
50
|
+
scrollable?: boolean;
|
|
79
51
|
|
|
80
52
|
/**
|
|
81
|
-
*
|
|
53
|
+
* Optional. Set type of header.
|
|
82
54
|
*/
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
55
|
+
headerType?: HeaderType;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Optional. Props for the animated component or bool used top navigation animated.
|
|
59
|
+
*/
|
|
60
|
+
animatedHeader?: AnimatedHeader;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Optional. Props for the underlying ScrollView component when `scrollable` is `true`.
|
|
64
|
+
*/
|
|
65
|
+
scrollViewProps?: ScrollViewProps;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Optional. ReactNode representing the header component of the screen.
|
|
69
|
+
*/
|
|
70
|
+
headerComponent?: ReactNode;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Optional. ReactNode representing the footer component of the screen.
|
|
74
|
+
*/
|
|
75
|
+
footerComponent?: ReactNode;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Optional. Background color of the screen.
|
|
79
|
+
*/
|
|
80
|
+
backgroundColor?: string;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Optional. layout card offset overlap header banner.
|
|
84
|
+
*/
|
|
85
|
+
layoutOffset?: -8 | -24 | -56;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Optional. Props for the floating action button.
|
|
89
|
+
*/
|
|
90
|
+
floatingButtonProps?: Omit<FloatingButtonProps, 'animatedValue' | 'bottom'>;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Optional. If `true`, the screen content is using grid layout by span.
|
|
94
|
+
*/
|
|
95
|
+
useGridLayout?: boolean;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const Screen = forwardRef(
|
|
99
|
+
(
|
|
100
|
+
{
|
|
101
|
+
children,
|
|
102
|
+
enableKeyboardAvoidingView = false,
|
|
103
|
+
scrollable = false,
|
|
104
|
+
navigation,
|
|
105
|
+
animatedHeader,
|
|
106
|
+
scrollViewProps,
|
|
107
|
+
headerComponent: Header,
|
|
108
|
+
footerComponent: Footer,
|
|
109
|
+
layoutOffset = -56,
|
|
110
|
+
backgroundColor,
|
|
111
|
+
headerType = 'default',
|
|
112
|
+
floatingButtonProps,
|
|
113
|
+
useGridLayout = true,
|
|
114
|
+
}: ScreenProps,
|
|
115
|
+
ref,
|
|
116
|
+
) => {
|
|
117
|
+
const animatedValue = useRef<Animated.Value | undefined>(undefined);
|
|
118
|
+
const {theme} = useContext(ApplicationContext);
|
|
119
|
+
const insets = useSafeAreaInsets();
|
|
120
|
+
const heightHeader = useHeaderHeight();
|
|
121
|
+
const currentTint = useRef(Colors.black_01);
|
|
122
|
+
const isTab = navigation?.instance?.getState?.()?.type == 'tab';
|
|
123
|
+
|
|
124
|
+
let styleAnimatedHeader: NavigationOptions;
|
|
125
|
+
let handleScroll;
|
|
126
|
+
let headerBackground: string | undefined = undefined;
|
|
127
|
+
let Component: any = View;
|
|
128
|
+
let keyboardVerticalOffset = heightHeader - 20;
|
|
129
|
+
|
|
130
|
+
if (headerType == 'extended' || animatedHeader) {
|
|
131
|
+
keyboardVerticalOffset = -20;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (headerType == 'extended') {
|
|
135
|
+
headerBackground = theme.assets?.headerBackground;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
if (animatedHeader) {
|
|
140
|
+
styleAnimatedHeader = {
|
|
141
|
+
headerTransparent: true,
|
|
142
|
+
headerBackground: (props: any) => (
|
|
143
|
+
<HeaderBackground
|
|
144
|
+
{...props}
|
|
145
|
+
animatedValue={animatedValue.current}
|
|
146
|
+
/>
|
|
147
|
+
),
|
|
148
|
+
headerTitle: (props: any) => (
|
|
149
|
+
<HeaderTitle {...props} animatedValue={animatedValue.current} />
|
|
150
|
+
),
|
|
151
|
+
};
|
|
152
|
+
if (animatedHeader.type == 'surface') {
|
|
153
|
+
styleAnimatedHeader = {
|
|
154
|
+
headerTransparent: true,
|
|
155
|
+
headerBackground: (props: any) => (
|
|
156
|
+
<HeaderBackground
|
|
157
|
+
{...props}
|
|
158
|
+
image={null}
|
|
159
|
+
backgroundColor={theme.colors.background.surface}
|
|
160
|
+
useBorder={true}
|
|
161
|
+
animatedValue={animatedValue.current}
|
|
162
|
+
/>
|
|
163
|
+
),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
navigation?.setOptions(styleAnimatedHeader);
|
|
167
|
+
}
|
|
168
|
+
}, [animatedHeader]);
|
|
169
|
+
|
|
170
|
+
useEffect(() => {
|
|
171
|
+
if (!animatedHeader) {
|
|
172
|
+
let headerOptions: NavigationOptions;
|
|
173
|
+
switch (headerType) {
|
|
174
|
+
case 'none':
|
|
175
|
+
headerOptions = {
|
|
176
|
+
headerTransparent: true,
|
|
177
|
+
headerBackground: () => null,
|
|
178
|
+
headerShown: false,
|
|
179
|
+
};
|
|
180
|
+
break;
|
|
181
|
+
|
|
182
|
+
case 'surface':
|
|
183
|
+
headerOptions = {
|
|
184
|
+
headerTransparent: false,
|
|
185
|
+
headerShown: true,
|
|
186
|
+
headerTintColor: theme.colors.text.default,
|
|
187
|
+
headerBackground: (props: any) => (
|
|
188
|
+
<HeaderBackground
|
|
189
|
+
{...props}
|
|
190
|
+
image={null}
|
|
191
|
+
backgroundColor={theme.colors.background.surface}
|
|
192
|
+
useBorder={true}
|
|
193
|
+
animatedValue={animatedValue.current}
|
|
194
|
+
/>
|
|
195
|
+
),
|
|
196
|
+
headerTitle: (props: any) => (
|
|
197
|
+
<HeaderTitle {...props} animatedValue={animatedValue.current} />
|
|
198
|
+
),
|
|
199
|
+
};
|
|
200
|
+
break;
|
|
201
|
+
|
|
202
|
+
case 'extended':
|
|
203
|
+
headerOptions = {
|
|
204
|
+
headerShown: true,
|
|
205
|
+
headerTransparent: true,
|
|
206
|
+
headerTintColor: Colors.black_01,
|
|
207
|
+
headerBackground: () => null,
|
|
208
|
+
headerTitle: (props: any) => <HeaderTitle {...props} />,
|
|
209
|
+
};
|
|
210
|
+
break;
|
|
211
|
+
|
|
212
|
+
default:
|
|
213
|
+
headerOptions = {
|
|
214
|
+
headerTransparent: false,
|
|
215
|
+
headerShown: true,
|
|
216
|
+
headerTintColor: Colors.black_01,
|
|
217
|
+
headerBackground: (props: any) => <HeaderBackground {...props} />,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
navigation?.setOptions(headerOptions);
|
|
221
|
+
}
|
|
222
|
+
}, [headerType]);
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* animated when use scroll && animated value
|
|
226
|
+
*/
|
|
227
|
+
if (scrollable) {
|
|
228
|
+
Component = Animated.ScrollView;
|
|
229
|
+
handleScroll = scrollViewProps?.onScroll;
|
|
230
|
+
if (animatedHeader || floatingButtonProps) {
|
|
231
|
+
animatedValue.current = new Animated.Value(0);
|
|
232
|
+
|
|
233
|
+
handleScroll = Animated.event(
|
|
234
|
+
[
|
|
235
|
+
{
|
|
236
|
+
nativeEvent: {
|
|
237
|
+
contentOffset: {y: animatedValue.current as Animated.Value},
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
],
|
|
104
241
|
{
|
|
105
|
-
|
|
106
|
-
|
|
242
|
+
useNativeDriver: false,
|
|
243
|
+
listener: (e: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
244
|
+
if (animatedHeader?.type == 'surface') {
|
|
245
|
+
const offsetY = e.nativeEvent.contentOffset.y;
|
|
246
|
+
let color = Colors.black_01;
|
|
247
|
+
if (offsetY > 50) {
|
|
248
|
+
color = theme.colors.text.default;
|
|
249
|
+
}
|
|
250
|
+
if (color != currentTint.current) {
|
|
251
|
+
currentTint.current = color;
|
|
252
|
+
navigation?.setOptions({
|
|
253
|
+
headerTintColor: color,
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
107
257
|
},
|
|
108
258
|
},
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
);
|
|
259
|
+
);
|
|
260
|
+
}
|
|
112
261
|
}
|
|
113
|
-
}
|
|
114
262
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
263
|
+
/**
|
|
264
|
+
* render top navigation banner
|
|
265
|
+
*/
|
|
266
|
+
const renderHeader = () => {
|
|
267
|
+
if (typeof animatedHeader?.component === 'function') {
|
|
268
|
+
return animatedHeader?.component({
|
|
269
|
+
animatedValue: animatedValue.current,
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* build content for screen
|
|
276
|
+
*/
|
|
277
|
+
const renderContent = (children: any): any => {
|
|
278
|
+
const results = validateChildren(children, [Section, Card, undefined]);
|
|
279
|
+
if (Array.isArray(results)) {
|
|
280
|
+
return results.map((item, index) => {
|
|
281
|
+
const space = item?.props?.useMargin === false ? 0 : Spacing.M;
|
|
282
|
+
if (item?.type == Fragment) {
|
|
283
|
+
return renderContent(item?.props?.children);
|
|
284
|
+
}
|
|
285
|
+
if (item) {
|
|
286
|
+
return (
|
|
287
|
+
<View
|
|
288
|
+
key={`ScreenItem${index}`}
|
|
289
|
+
style={{
|
|
290
|
+
marginTop: space,
|
|
291
|
+
flex: item.props?.expanded ? 1 : undefined,
|
|
292
|
+
}}>
|
|
293
|
+
{item}
|
|
294
|
+
</View>
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
} else {
|
|
299
|
+
const item: any = children;
|
|
300
|
+
const space = item?.props?.useMargin === false ? 0 : Spacing.M;
|
|
301
|
+
if (item?.type == Fragment) {
|
|
302
|
+
return renderContent(item?.props?.children);
|
|
303
|
+
}
|
|
123
304
|
return (
|
|
124
305
|
<View
|
|
125
|
-
key={`ScreenItem
|
|
306
|
+
key={`ScreenItem`}
|
|
126
307
|
style={{
|
|
127
308
|
marginTop: space,
|
|
128
|
-
flex: item
|
|
309
|
+
flex: item?.props?.expanded ? 1 : undefined,
|
|
129
310
|
}}>
|
|
130
|
-
{
|
|
311
|
+
{children}
|
|
131
312
|
</View>
|
|
132
313
|
);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return (
|
|
139
|
-
<View style={Styles.flex} accessibilityLabel={`ScreenContainer`}>
|
|
140
|
-
<View
|
|
141
|
-
style={{
|
|
142
|
-
position: 'absolute',
|
|
143
|
-
maxHeight: 215,
|
|
144
|
-
width: '100%',
|
|
145
|
-
overflow: 'hidden',
|
|
146
|
-
}}>
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
return (
|
|
318
|
+
<View style={[Styles.flex, {backgroundColor}]}>
|
|
147
319
|
{!!headerBackground && (
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
/>
|
|
320
|
+
<>
|
|
321
|
+
<Image
|
|
322
|
+
source={{
|
|
323
|
+
uri: headerBackground,
|
|
324
|
+
}}
|
|
325
|
+
style={styles.extendedHeader}
|
|
326
|
+
/>
|
|
327
|
+
<View style={{height: heightHeader}} />
|
|
328
|
+
</>
|
|
158
329
|
)}
|
|
330
|
+
<KeyboardAvoidingView
|
|
331
|
+
style={Styles.flex}
|
|
332
|
+
enabled={enableKeyboardAvoidingView}
|
|
333
|
+
keyboardVerticalOffset={keyboardVerticalOffset}
|
|
334
|
+
behavior={Platform.select({
|
|
335
|
+
ios: 'padding',
|
|
336
|
+
android: undefined,
|
|
337
|
+
})}>
|
|
338
|
+
{Header}
|
|
339
|
+
|
|
340
|
+
<Component
|
|
341
|
+
{...scrollViewProps}
|
|
342
|
+
ref={ref}
|
|
343
|
+
showsVerticalScrollIndicator={false}
|
|
344
|
+
onScroll={handleScroll}
|
|
345
|
+
style={Styles.flex}>
|
|
346
|
+
<View
|
|
347
|
+
style={[styles.screenBanner, {maxHeight: 210 + layoutOffset}]}>
|
|
348
|
+
{renderHeader()}
|
|
349
|
+
</View>
|
|
350
|
+
{useGridLayout ? renderContent(children) : children}
|
|
351
|
+
</Component>
|
|
352
|
+
|
|
353
|
+
{floatingButtonProps && (
|
|
354
|
+
<View>
|
|
355
|
+
<FloatingButton
|
|
356
|
+
{...floatingButtonProps}
|
|
357
|
+
animatedValue={animatedValue.current}
|
|
358
|
+
bottom={
|
|
359
|
+
Footer || isTab ? 12 : Math.min(insets.bottom, 21) + Spacing.S
|
|
360
|
+
}
|
|
361
|
+
/>
|
|
362
|
+
</View>
|
|
363
|
+
)}
|
|
364
|
+
|
|
365
|
+
{Footer && (
|
|
366
|
+
<View
|
|
367
|
+
style={[
|
|
368
|
+
styles.shadow,
|
|
369
|
+
{
|
|
370
|
+
paddingBottom: Math.min(insets.bottom, 21) + Spacing.S,
|
|
371
|
+
backgroundColor: theme.colors.background.surface,
|
|
372
|
+
},
|
|
373
|
+
]}>
|
|
374
|
+
<Section>{Footer}</Section>
|
|
375
|
+
</View>
|
|
376
|
+
)}
|
|
377
|
+
</KeyboardAvoidingView>
|
|
159
378
|
</View>
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
behavior={Platform.select({
|
|
164
|
-
ios: 'padding',
|
|
165
|
-
android: undefined,
|
|
166
|
-
})}>
|
|
167
|
-
<Component
|
|
168
|
-
{...scrollViewProps}
|
|
169
|
-
onScroll={handleScroll}
|
|
170
|
-
style={[Styles.flex, {marginTop: marginHeader}]}>
|
|
171
|
-
{renderContent()}
|
|
172
|
-
</Component>
|
|
173
|
-
{Footer && (
|
|
174
|
-
<View
|
|
175
|
-
style={{
|
|
176
|
-
paddingTop: Spacing.S,
|
|
177
|
-
paddingBottom: insets.bottom + Spacing.S,
|
|
178
|
-
backgroundColor: theme.colors.background.surface,
|
|
179
|
-
}}>
|
|
180
|
-
<Section>{Footer}</Section>
|
|
181
|
-
</View>
|
|
182
|
-
)}
|
|
183
|
-
</KeyboardAvoidingView>
|
|
184
|
-
</View>
|
|
185
|
-
);
|
|
186
|
-
};
|
|
379
|
+
);
|
|
380
|
+
},
|
|
381
|
+
);
|
|
187
382
|
|
|
188
383
|
export default Screen;
|
package/Layout/Section.tsx
CHANGED
|
@@ -1,16 +1,41 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {Dimensions, View} from 'react-native';
|
|
1
|
+
import React, {Fragment, useContext} from 'react';
|
|
2
|
+
import {Dimensions, View, ViewProps} from 'react-native';
|
|
3
3
|
import {useGridSystem, validateChildren} from './utils';
|
|
4
|
-
import {GridContextProps
|
|
4
|
+
import {GridContextProps} from './types';
|
|
5
5
|
import {GridContext} from './index';
|
|
6
|
-
import {GRIDVIEW} from '../Consts';
|
|
7
6
|
import Item from './Item';
|
|
7
|
+
import {ApplicationContext} from '../Application';
|
|
8
|
+
import styles from './styles';
|
|
9
|
+
import {Image} from '../Image';
|
|
10
|
+
import ItemList from './ItemList';
|
|
11
|
+
|
|
12
|
+
export interface SectionProps extends ViewProps {
|
|
13
|
+
/**
|
|
14
|
+
* Optional. If `true`, the Section component will be displayed in an expanded state.
|
|
15
|
+
* Defaults to `false` if not provided.
|
|
16
|
+
*/
|
|
17
|
+
expanded?: boolean;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Optional. If `true`, margin will be applied to the Section component.
|
|
21
|
+
* Defaults to `false` if not provided.
|
|
22
|
+
*/
|
|
23
|
+
useMargin?: boolean;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Optional. Background image for the Section component.
|
|
27
|
+
*/
|
|
28
|
+
backgroundImage?: string;
|
|
29
|
+
}
|
|
8
30
|
|
|
9
31
|
const Section: React.FC<SectionProps> = ({
|
|
10
32
|
children,
|
|
11
33
|
useMargin = true,
|
|
12
|
-
|
|
34
|
+
backgroundImage,
|
|
35
|
+
style,
|
|
36
|
+
...props
|
|
13
37
|
}) => {
|
|
38
|
+
const {showGrid} = useContext(ApplicationContext);
|
|
14
39
|
const {numberOfColumns} = useGridSystem();
|
|
15
40
|
|
|
16
41
|
const gutterSize = 12;
|
|
@@ -26,7 +51,6 @@ const Section: React.FC<SectionProps> = ({
|
|
|
26
51
|
const gridContext: GridContextProps = {
|
|
27
52
|
numberOfColumns,
|
|
28
53
|
gutterSize,
|
|
29
|
-
margin,
|
|
30
54
|
sizePerSpan,
|
|
31
55
|
getSizeSpan: span => {
|
|
32
56
|
return span * sizePerSpan + (span - 1) * gutterSize;
|
|
@@ -37,20 +61,7 @@ const Section: React.FC<SectionProps> = ({
|
|
|
37
61
|
* render overlay only dev mode
|
|
38
62
|
*/
|
|
39
63
|
const renderOverlay = () => {
|
|
40
|
-
return
|
|
41
|
-
<View
|
|
42
|
-
pointerEvents={'none'}
|
|
43
|
-
style={{
|
|
44
|
-
position: 'absolute',
|
|
45
|
-
top: 0,
|
|
46
|
-
bottom: 0,
|
|
47
|
-
left: 0,
|
|
48
|
-
right: 0,
|
|
49
|
-
borderColor: 'red',
|
|
50
|
-
borderWidth: 1,
|
|
51
|
-
}}
|
|
52
|
-
/>
|
|
53
|
-
);
|
|
64
|
+
return <View pointerEvents={'none'} style={styles.boxGridSection} />;
|
|
54
65
|
};
|
|
55
66
|
|
|
56
67
|
/**
|
|
@@ -96,8 +107,9 @@ const Section: React.FC<SectionProps> = ({
|
|
|
96
107
|
if (Array.isArray(children)) {
|
|
97
108
|
let cursor = 0;
|
|
98
109
|
let rows: any[] = [];
|
|
99
|
-
|
|
100
|
-
|
|
110
|
+
const arrayChild = children.filter(item => !!item);
|
|
111
|
+
for (let i = 0; i < arrayChild.length; ++i) {
|
|
112
|
+
const item = arrayChild[i];
|
|
101
113
|
const totalSpan = rows
|
|
102
114
|
.concat([item])
|
|
103
115
|
.map(i => i.props?.widthSpan)
|
|
@@ -113,30 +125,50 @@ const Section: React.FC<SectionProps> = ({
|
|
|
113
125
|
rows = [item];
|
|
114
126
|
}
|
|
115
127
|
|
|
116
|
-
if (i ==
|
|
128
|
+
if (i == arrayChild.length - 1) {
|
|
117
129
|
cursor += 1;
|
|
118
130
|
element.push(addRowView(rows, cursor, true));
|
|
119
131
|
}
|
|
120
132
|
}
|
|
121
133
|
} else {
|
|
122
134
|
element.push(children);
|
|
135
|
+
if (children?.type == Fragment) {
|
|
136
|
+
return renderView(children?.props.children);
|
|
137
|
+
}
|
|
123
138
|
}
|
|
124
139
|
return element;
|
|
125
140
|
};
|
|
126
141
|
|
|
127
142
|
return (
|
|
128
|
-
<GridContext.Provider
|
|
143
|
+
<GridContext.Provider
|
|
144
|
+
value={{
|
|
145
|
+
numberOfColumns,
|
|
146
|
+
gutterSize,
|
|
147
|
+
sizePerSpan,
|
|
148
|
+
getSizeSpan: span => {
|
|
149
|
+
return span * sizePerSpan + (span - 1) * gutterSize;
|
|
150
|
+
},
|
|
151
|
+
}}>
|
|
129
152
|
<View
|
|
130
|
-
|
|
131
|
-
style={
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
153
|
+
{...props}
|
|
154
|
+
style={[
|
|
155
|
+
style,
|
|
156
|
+
styles.protectedStyle,
|
|
157
|
+
{
|
|
158
|
+
width: widthSection,
|
|
159
|
+
marginHorizontal: margin,
|
|
160
|
+
flexDirection: 'row',
|
|
161
|
+
flexWrap: 'wrap',
|
|
162
|
+
},
|
|
163
|
+
]}>
|
|
164
|
+
{!!backgroundImage && (
|
|
165
|
+
<Image
|
|
166
|
+
source={{uri: backgroundImage}}
|
|
167
|
+
style={styles.imageBackground}
|
|
168
|
+
/>
|
|
169
|
+
)}
|
|
170
|
+
{renderView(validateChildren(children, [Item, ItemList]))}
|
|
171
|
+
{showGrid && renderOverlay()}
|
|
140
172
|
</View>
|
|
141
173
|
</GridContext.Provider>
|
|
142
174
|
);
|