@momo-kits/foundation 0.80.9 → 0.81.1-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.
- package/Application/BottomSheet.tsx +212 -0
- package/Application/BottomTab/BottomTabBar.tsx +278 -0
- package/Application/BottomTab/index.tsx +143 -0
- package/Application/Components.tsx +379 -209
- package/Application/ModalScreen.tsx +14 -178
- package/Application/Navigation.ts +15 -19
- package/Application/NavigationContainer.tsx +66 -63
- package/Application/Navigator.ts +106 -53
- package/Application/StackScreen.tsx +123 -9
- package/Application/index.ts +19 -6
- package/Application/types.ts +83 -26
- package/Application/utils.tsx +38 -49
- 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 +64 -28
- package/Button/styles.ts +19 -0
- package/CheckBox/index.tsx +37 -27
- package/CheckBox/types.ts +5 -3
- package/Consts/colors+spacing+radius.ts +18 -0
- package/Icon/index.tsx +14 -9
- package/Icon/types.ts +4 -3
- package/IconButton/index.tsx +24 -15
- package/Image/index.tsx +62 -47
- package/Image/styles.ts +1 -9
- package/Image/types.ts +5 -1
- package/Input/Input.tsx +104 -25
- package/Input/InputDropDown.tsx +35 -23
- package/Input/InputMoney.tsx +79 -18
- package/Input/InputOTP.tsx +190 -149
- package/Input/InputSearch.tsx +96 -44
- package/Input/InputTextArea.tsx +33 -17
- package/Input/common.tsx +26 -17
- package/Input/index.tsx +69 -24
- package/Input/styles.ts +5 -7
- package/Input/utils.ts +1 -1
- package/Layout/AnimatedInputSearch.tsx +44 -0
- package/Layout/Card.tsx +37 -13
- package/Layout/FloatingButton.tsx +168 -0
- package/Layout/GridSystem.tsx +2 -3
- package/Layout/Item.tsx +1 -2
- package/Layout/ItemList.tsx +55 -0
- package/Layout/ItemSectionList.tsx +39 -0
- package/Layout/Screen.tsx +404 -181
- package/Layout/Section.tsx +22 -22
- package/Layout/TextTyping.tsx +114 -0
- package/Layout/index.ts +12 -2
- package/Layout/styles.ts +46 -13
- package/Layout/types.ts +13 -5
- package/Layout/utils.ts +7 -12
- package/Loader/index.tsx +2 -0
- package/Pagination/PaginationDot.tsx +6 -1
- package/Pagination/PaginationNumber.tsx +7 -4
- package/Pagination/PaginationScroll.tsx +0 -1
- package/Pagination/PaginationWhiteDot.tsx +6 -1
- package/Pagination/styles.ts +3 -0
- package/Pagination/types.ts +2 -0
- package/Popup/PopupNotify.tsx +108 -40
- package/Popup/PopupPromotion.tsx +45 -10
- package/Popup/types.ts +13 -10
- package/Radio/index.tsx +35 -21
- package/Radio/types.ts +7 -5
- 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 +177 -63
- package/Title/styles.ts +48 -15
- package/Title/types.ts +16 -47
- package/code-scanner.js +125 -16
- package/index.ts +9 -0
- package/migrate_typo.js +56 -0
- package/package.json +9 -8
- package/publish.sh +21 -16
- package/tsconfig.json +1 -2
- package/verify.js +24 -6
- package/Application/BottomTab.tsx +0 -65
package/Layout/Card.tsx
CHANGED
|
@@ -7,17 +7,29 @@ import Item from './Item';
|
|
|
7
7
|
import {Image} from '../Image';
|
|
8
8
|
import {ApplicationContext} from '../Application';
|
|
9
9
|
import styles from './styles';
|
|
10
|
-
import {Colors, Spacing} from '../Consts';
|
|
10
|
+
import {Colors, Radius, Shadow, Spacing} from '../Consts';
|
|
11
|
+
import ItemList from './ItemList';
|
|
11
12
|
|
|
12
13
|
export interface CardProps extends ViewProps {
|
|
13
14
|
/**
|
|
14
15
|
* Optional. Background image for the card.
|
|
15
16
|
*/
|
|
16
17
|
backgroundImage?: string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Optional. Use shadow for the card.
|
|
21
|
+
*/
|
|
22
|
+
useShadow?: boolean;
|
|
17
23
|
}
|
|
18
24
|
|
|
19
|
-
const Card: React.FC<CardProps> = ({
|
|
20
|
-
|
|
25
|
+
const Card: React.FC<CardProps> = ({
|
|
26
|
+
children,
|
|
27
|
+
style,
|
|
28
|
+
backgroundImage,
|
|
29
|
+
useShadow = false,
|
|
30
|
+
...props
|
|
31
|
+
}) => {
|
|
32
|
+
const {showGrid, theme} = useContext(ApplicationContext);
|
|
21
33
|
const {numberOfColumns} = useGridSystem();
|
|
22
34
|
|
|
23
35
|
const gutterSize = 8;
|
|
@@ -30,12 +42,12 @@ const Card: React.FC<CardProps> = ({children, style, backgroundImage}) => {
|
|
|
30
42
|
const gridContext: GridContextProps = {
|
|
31
43
|
numberOfColumns,
|
|
32
44
|
gutterSize,
|
|
33
|
-
margin,
|
|
34
45
|
sizePerSpan,
|
|
35
46
|
getSizeSpan: span => {
|
|
36
47
|
return span * sizePerSpan + (span - 1) * gutterSize;
|
|
37
48
|
},
|
|
38
49
|
};
|
|
50
|
+
|
|
39
51
|
/**
|
|
40
52
|
* render overlay only dev mode
|
|
41
53
|
*/
|
|
@@ -74,7 +86,7 @@ const Card: React.FC<CardProps> = ({children, style, backgroundImage}) => {
|
|
|
74
86
|
{rows.map((i: React.ReactElement, index: number) => {
|
|
75
87
|
return (
|
|
76
88
|
<View key={`Item${cursor}${index}`} style={{flexDirection: 'row'}}>
|
|
77
|
-
{index
|
|
89
|
+
{index !== 0 && (
|
|
78
90
|
<View style={{width: gridContext.gutterSize}}></View>
|
|
79
91
|
)}
|
|
80
92
|
{i}
|
|
@@ -96,8 +108,9 @@ const Card: React.FC<CardProps> = ({children, style, backgroundImage}) => {
|
|
|
96
108
|
if (Array.isArray(children)) {
|
|
97
109
|
let cursor = 0;
|
|
98
110
|
let rows: any[] = [];
|
|
99
|
-
|
|
100
|
-
|
|
111
|
+
const arrayChild = children.filter(item => !!item);
|
|
112
|
+
for (let i = 0; i < arrayChild.length; ++i) {
|
|
113
|
+
const item = arrayChild[i];
|
|
101
114
|
const totalSpan = rows
|
|
102
115
|
.concat([item])
|
|
103
116
|
.map(i => i.props?.widthSpan)
|
|
@@ -113,14 +126,14 @@ const Card: React.FC<CardProps> = ({children, style, backgroundImage}) => {
|
|
|
113
126
|
rows = [item];
|
|
114
127
|
}
|
|
115
128
|
|
|
116
|
-
if (i
|
|
129
|
+
if (i === arrayChild.length - 1) {
|
|
117
130
|
cursor += 1;
|
|
118
131
|
element.push(addRowView(rows, cursor, true));
|
|
119
132
|
}
|
|
120
133
|
}
|
|
121
134
|
} else {
|
|
122
135
|
element.push(children);
|
|
123
|
-
if (children?.type
|
|
136
|
+
if (children?.type === Fragment) {
|
|
124
137
|
return renderView(children?.props.children);
|
|
125
138
|
}
|
|
126
139
|
}
|
|
@@ -130,22 +143,33 @@ const Card: React.FC<CardProps> = ({children, style, backgroundImage}) => {
|
|
|
130
143
|
return (
|
|
131
144
|
<GridContext.Provider value={gridContext}>
|
|
132
145
|
<View
|
|
133
|
-
|
|
146
|
+
{...props}
|
|
147
|
+
onLayout={undefined}
|
|
134
148
|
style={[
|
|
149
|
+
{backgroundColor: theme.colors.background.surface},
|
|
135
150
|
style,
|
|
151
|
+
styles.protectedStyle,
|
|
136
152
|
styles.card,
|
|
137
153
|
{
|
|
138
154
|
width: widthSection,
|
|
139
|
-
marginHorizontal:
|
|
155
|
+
marginHorizontal: margin,
|
|
140
156
|
},
|
|
157
|
+
!!backgroundImage && {backgroundColor: undefined},
|
|
158
|
+
useShadow && Shadow.Light,
|
|
141
159
|
]}>
|
|
142
160
|
{!!backgroundImage && (
|
|
143
161
|
<Image
|
|
144
162
|
source={{uri: backgroundImage}}
|
|
145
|
-
style={[
|
|
163
|
+
style={[
|
|
164
|
+
styles.imageBackground,
|
|
165
|
+
{
|
|
166
|
+
width: widthSection,
|
|
167
|
+
borderRadius: Radius.M,
|
|
168
|
+
},
|
|
169
|
+
]}
|
|
146
170
|
/>
|
|
147
171
|
)}
|
|
148
|
-
{renderView(validateChildren(children, [Item]))}
|
|
172
|
+
{renderView(validateChildren(children, [Item, ItemList]))}
|
|
149
173
|
{showGrid && renderOverlay()}
|
|
150
174
|
</View>
|
|
151
175
|
</GridContext.Provider>
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import {default as React, useContext, useEffect, useRef, useState} from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Animated,
|
|
4
|
+
LayoutChangeEvent,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
View,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
import {ApplicationContext} from '../Application';
|
|
10
|
+
import {Icon} from '../Icon';
|
|
11
|
+
|
|
12
|
+
export interface FloatingButtonProps {
|
|
13
|
+
label?: string;
|
|
14
|
+
onPress?: () => void;
|
|
15
|
+
position?: 'center' | 'right';
|
|
16
|
+
icon?: string;
|
|
17
|
+
iconColor?: string;
|
|
18
|
+
size?: 'small' | 'large';
|
|
19
|
+
animatedValue?: Animated.Value;
|
|
20
|
+
bottom?: number;
|
|
21
|
+
renderComponent?: () => React.ReactNode;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
25
|
+
renderComponent,
|
|
26
|
+
label = '',
|
|
27
|
+
onPress = () => {},
|
|
28
|
+
position = 'right',
|
|
29
|
+
icon = '',
|
|
30
|
+
iconColor = '',
|
|
31
|
+
size = 'small',
|
|
32
|
+
animatedValue,
|
|
33
|
+
bottom = 12,
|
|
34
|
+
}: FloatingButtonProps) => {
|
|
35
|
+
const {theme} = useContext(ApplicationContext);
|
|
36
|
+
const maxWidth = useRef(0);
|
|
37
|
+
const minWidth = size === 'small' ? 36 : 48;
|
|
38
|
+
const [opacityAnimated] = useState(new Animated.Value(0)); // Initial opacity set to 0
|
|
39
|
+
const [widthAnimated, setWidthAnimated] = useState<Animated.Value>();
|
|
40
|
+
const lastOffset = useRef(0);
|
|
41
|
+
const lastDirection = useRef<string>();
|
|
42
|
+
const [showText, setShowText] = React.useState(true);
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (!label) return;
|
|
46
|
+
|
|
47
|
+
Animated.timing(opacityAnimated, {
|
|
48
|
+
toValue: 1,
|
|
49
|
+
duration: 100,
|
|
50
|
+
useNativeDriver: true,
|
|
51
|
+
}).start();
|
|
52
|
+
|
|
53
|
+
const listener = animatedValue?.addListener(({value}) => {
|
|
54
|
+
if (value !== lastOffset.current && value > 0) {
|
|
55
|
+
const direction = value > lastOffset.current ? 'down' : 'up';
|
|
56
|
+
lastOffset.current = value;
|
|
57
|
+
if (lastDirection.current !== direction) {
|
|
58
|
+
lastDirection.current = direction;
|
|
59
|
+
if (direction === 'down') {
|
|
60
|
+
Animated.timing(opacityAnimated, {
|
|
61
|
+
toValue: 0,
|
|
62
|
+
duration: 100,
|
|
63
|
+
useNativeDriver: true,
|
|
64
|
+
}).start();
|
|
65
|
+
Animated.timing(widthAnimated!, {
|
|
66
|
+
toValue: minWidth,
|
|
67
|
+
duration: 100,
|
|
68
|
+
useNativeDriver: false,
|
|
69
|
+
}).start(() => setShowText(false));
|
|
70
|
+
} else {
|
|
71
|
+
Animated.timing(opacityAnimated, {
|
|
72
|
+
toValue: 1,
|
|
73
|
+
duration: 100,
|
|
74
|
+
useNativeDriver: true,
|
|
75
|
+
}).start();
|
|
76
|
+
Animated.timing(widthAnimated!, {
|
|
77
|
+
toValue: maxWidth.current,
|
|
78
|
+
duration: 100,
|
|
79
|
+
useNativeDriver: false,
|
|
80
|
+
}).start(() => setShowText(true));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
return () => {
|
|
87
|
+
if (listener !== null) {
|
|
88
|
+
animatedValue?.removeListener(listener);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}, [label, widthAnimated]);
|
|
92
|
+
|
|
93
|
+
const handleLayout = (event: LayoutChangeEvent) => {
|
|
94
|
+
const layout = event.nativeEvent.layout;
|
|
95
|
+
if (widthAnimated) return;
|
|
96
|
+
maxWidth.current = layout.width;
|
|
97
|
+
setWidthAnimated(new Animated.Value(layout.width));
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
if (renderComponent) {
|
|
101
|
+
return (
|
|
102
|
+
<View
|
|
103
|
+
onLayout={handleLayout}
|
|
104
|
+
style={[
|
|
105
|
+
styles.container,
|
|
106
|
+
{
|
|
107
|
+
right: position === 'right' ? 12 : undefined,
|
|
108
|
+
alignSelf: position === 'center' ? 'center' : 'flex-end',
|
|
109
|
+
bottom,
|
|
110
|
+
},
|
|
111
|
+
]}>
|
|
112
|
+
{renderComponent()}
|
|
113
|
+
</View>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<Animated.View
|
|
119
|
+
onLayout={handleLayout}
|
|
120
|
+
style={[
|
|
121
|
+
styles.container,
|
|
122
|
+
{
|
|
123
|
+
right: position === 'right' ? 12 : undefined,
|
|
124
|
+
alignSelf: position === 'center' ? 'center' : 'flex-end',
|
|
125
|
+
width: widthAnimated,
|
|
126
|
+
height: size === 'small' ? 36 : 48,
|
|
127
|
+
backgroundColor: theme.colors.primary,
|
|
128
|
+
bottom,
|
|
129
|
+
},
|
|
130
|
+
]}>
|
|
131
|
+
<TouchableOpacity
|
|
132
|
+
style={{flexDirection: 'row', alignItems: 'center'}}
|
|
133
|
+
onPress={onPress}>
|
|
134
|
+
<Icon
|
|
135
|
+
source={icon}
|
|
136
|
+
size={size === 'small' ? 12 : 24}
|
|
137
|
+
color={iconColor}
|
|
138
|
+
/>
|
|
139
|
+
{showText && !!label && (
|
|
140
|
+
<Animated.Text
|
|
141
|
+
style={[styles.label, {opacity: opacityAnimated, color: 'white'}]}
|
|
142
|
+
numberOfLines={1}>
|
|
143
|
+
{label}
|
|
144
|
+
</Animated.Text>
|
|
145
|
+
)}
|
|
146
|
+
</TouchableOpacity>
|
|
147
|
+
</Animated.View>
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const styles = StyleSheet.create({
|
|
152
|
+
container: {
|
|
153
|
+
flexDirection: 'row',
|
|
154
|
+
alignContent: 'center',
|
|
155
|
+
alignItems: 'center',
|
|
156
|
+
position: 'absolute',
|
|
157
|
+
borderRadius: 100,
|
|
158
|
+
paddingHorizontal: 12,
|
|
159
|
+
flexWrap: 'wrap',
|
|
160
|
+
alignSelf: 'flex-end',
|
|
161
|
+
},
|
|
162
|
+
label: {
|
|
163
|
+
marginLeft: 8,
|
|
164
|
+
fontSize: 16,
|
|
165
|
+
lineHeight: 22,
|
|
166
|
+
fontWeight: '700',
|
|
167
|
+
},
|
|
168
|
+
});
|
package/Layout/GridSystem.tsx
CHANGED
|
@@ -24,7 +24,6 @@ const GridSystem: React.FC<any> = ({
|
|
|
24
24
|
const grid: GridContextProps = {
|
|
25
25
|
numberOfColumns,
|
|
26
26
|
gutterSize,
|
|
27
|
-
margin,
|
|
28
27
|
sizePerSpan,
|
|
29
28
|
getSizeSpan: span => {
|
|
30
29
|
return span * sizePerSpan + (span - 1) * gutterSize;
|
|
@@ -46,7 +45,7 @@ const GridSystem: React.FC<any> = ({
|
|
|
46
45
|
screenGrid && insets,
|
|
47
46
|
{
|
|
48
47
|
borderColor: theme.colors.error.primary,
|
|
49
|
-
marginHorizontal:
|
|
48
|
+
marginHorizontal: margin,
|
|
50
49
|
top: Spacing.M,
|
|
51
50
|
bottom: Spacing.M,
|
|
52
51
|
},
|
|
@@ -54,7 +53,7 @@ const GridSystem: React.FC<any> = ({
|
|
|
54
53
|
{list.map((_, index) => {
|
|
55
54
|
return (
|
|
56
55
|
<View style={{flexDirection: 'row'}} key={index.toString()}>
|
|
57
|
-
{index
|
|
56
|
+
{index !== -0 && <View style={{width: grid.gutterSize}} />}
|
|
58
57
|
<View
|
|
59
58
|
key={`Grid${index.toString()}`}
|
|
60
59
|
pointerEvents="none"
|
package/Layout/Item.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import {GridContext} from './index';
|
|
|
5
5
|
import {ApplicationContext} from '../Application';
|
|
6
6
|
import styles from './styles';
|
|
7
7
|
|
|
8
|
-
type SpanNumber = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
|
8
|
+
export type SpanNumber = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
|
9
9
|
|
|
10
10
|
export interface ItemProps extends ViewProps {
|
|
11
11
|
/**
|
|
@@ -37,7 +37,6 @@ const Item: React.FC<ItemProps> = ({
|
|
|
37
37
|
|
|
38
38
|
return (
|
|
39
39
|
<View
|
|
40
|
-
accessibilityLabel={`Item`}
|
|
41
40
|
style={[
|
|
42
41
|
style,
|
|
43
42
|
styles.item,
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React, {forwardRef, useContext} from 'react';
|
|
2
|
+
import {FlatList, FlatListProps, View} from 'react-native';
|
|
3
|
+
import Item, {SpanNumber} from './Item';
|
|
4
|
+
import {GridContext} from './index';
|
|
5
|
+
import styles from './styles';
|
|
6
|
+
|
|
7
|
+
export interface ItemListProps extends FlatListProps<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 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
|
+
|
|
40
|
+
return (
|
|
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
|
+
/>
|
|
51
|
+
);
|
|
52
|
+
},
|
|
53
|
+
);
|
|
54
|
+
|
|
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;
|