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