@momo-kits/foundation 0.81.1 → 0.81.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/Components.tsx +1 -1
- package/Consts/colors+spacing+radius.ts +4 -0
- package/Layout/Card.tsx +5 -1
- package/Layout/ItemList.tsx +63 -0
- package/Layout/Section.tsx +2 -1
- package/Layout/index.ts +10 -1
- package/Layout/types.ts +2 -0
- package/package.json +1 -1
package/Layout/Card.tsx
CHANGED
|
@@ -8,6 +8,7 @@ import {Image} from '../Image';
|
|
|
8
8
|
import {ApplicationContext} from '../Application';
|
|
9
9
|
import styles from './styles';
|
|
10
10
|
import {Colors, Shadow, Spacing} from '../Consts';
|
|
11
|
+
import ItemList from './ItemList';
|
|
11
12
|
|
|
12
13
|
export interface CardProps extends ViewProps {
|
|
13
14
|
/**
|
|
@@ -15,6 +16,9 @@ export interface CardProps extends ViewProps {
|
|
|
15
16
|
*/
|
|
16
17
|
backgroundImage?: string;
|
|
17
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Optional. Use shadow for the card.
|
|
21
|
+
*/
|
|
18
22
|
useShadow?: boolean;
|
|
19
23
|
}
|
|
20
24
|
|
|
@@ -155,7 +159,7 @@ const Card: React.FC<CardProps> = ({
|
|
|
155
159
|
style={styles.imageBackground}
|
|
156
160
|
/>
|
|
157
161
|
)}
|
|
158
|
-
{renderView(validateChildren(children, [Item]))}
|
|
162
|
+
{renderView(validateChildren(children, [Item, ItemList]))}
|
|
159
163
|
{showGrid && renderOverlay()}
|
|
160
164
|
</View>
|
|
161
165
|
</GridContext.Provider>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React, {FC, ReactElement, useContext} from 'react';
|
|
2
|
+
import {FlatList, FlatListProps, View} from 'react-native';
|
|
3
|
+
import Item from './Item';
|
|
4
|
+
import {GridContext} from './index';
|
|
5
|
+
|
|
6
|
+
const ItemList: FC<FlatListProps<any>> = ({
|
|
7
|
+
renderItem,
|
|
8
|
+
numColumns = 1,
|
|
9
|
+
style,
|
|
10
|
+
...props
|
|
11
|
+
}) => {
|
|
12
|
+
const {gutterSize} = useContext(GridContext);
|
|
13
|
+
|
|
14
|
+
const _renderItem = (info: any) => {
|
|
15
|
+
const {item, index, separators} = info;
|
|
16
|
+
|
|
17
|
+
const children = renderItem?.({
|
|
18
|
+
item,
|
|
19
|
+
index,
|
|
20
|
+
separators,
|
|
21
|
+
}) as ReactElement;
|
|
22
|
+
|
|
23
|
+
if (children?.type !== Item) {
|
|
24
|
+
console.warn('Wrong children type for this component, expected are Item');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const spacingStyle =
|
|
28
|
+
numColumns > 1
|
|
29
|
+
? {
|
|
30
|
+
marginRight: gutterSize,
|
|
31
|
+
}
|
|
32
|
+
: {};
|
|
33
|
+
|
|
34
|
+
return <View style={spacingStyle}>{children}</View>;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<FlatList
|
|
39
|
+
{...props}
|
|
40
|
+
numColumns={numColumns}
|
|
41
|
+
renderItem={_renderItem}
|
|
42
|
+
horizontal={false}
|
|
43
|
+
ItemSeparatorComponent={() => <View style={{height: gutterSize}} />}
|
|
44
|
+
style={[
|
|
45
|
+
style,
|
|
46
|
+
{
|
|
47
|
+
marginTop: undefined,
|
|
48
|
+
marginBottom: undefined,
|
|
49
|
+
marginLeft: undefined,
|
|
50
|
+
marginRight: undefined,
|
|
51
|
+
paddingTop: undefined,
|
|
52
|
+
paddingBottom: undefined,
|
|
53
|
+
paddingLeft: undefined,
|
|
54
|
+
paddingRight: undefined,
|
|
55
|
+
padding: undefined,
|
|
56
|
+
margin: undefined,
|
|
57
|
+
},
|
|
58
|
+
]}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export default ItemList;
|
package/Layout/Section.tsx
CHANGED
|
@@ -7,6 +7,7 @@ import Item from './Item';
|
|
|
7
7
|
import {ApplicationContext} from '../Application';
|
|
8
8
|
import styles from './styles';
|
|
9
9
|
import {Image} from '../Image';
|
|
10
|
+
import ItemList from './ItemList';
|
|
10
11
|
|
|
11
12
|
export interface SectionProps extends ViewProps {
|
|
12
13
|
/**
|
|
@@ -168,7 +169,7 @@ const Section: React.FC<SectionProps> = ({
|
|
|
168
169
|
style={styles.imageBackground}
|
|
169
170
|
/>
|
|
170
171
|
)}
|
|
171
|
-
{renderView(validateChildren(children, [Item]))}
|
|
172
|
+
{renderView(validateChildren(children, [Item, ItemList]))}
|
|
172
173
|
{showGrid && renderOverlay()}
|
|
173
174
|
</View>
|
|
174
175
|
</GridContext.Provider>
|
package/Layout/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {validateChildren} from './utils';
|
|
|
5
5
|
import {createContext} from 'react';
|
|
6
6
|
import {GridContextProps} from './types';
|
|
7
7
|
import Item from './Item';
|
|
8
|
+
import ItemList from './ItemList';
|
|
8
9
|
|
|
9
10
|
const GridContext = createContext<GridContextProps>({
|
|
10
11
|
numberOfColumns: 12,
|
|
@@ -14,4 +15,12 @@ const GridContext = createContext<GridContextProps>({
|
|
|
14
15
|
getSizeSpan: () => 0,
|
|
15
16
|
});
|
|
16
17
|
|
|
17
|
-
export {
|
|
18
|
+
export {
|
|
19
|
+
GridContext,
|
|
20
|
+
Card,
|
|
21
|
+
Section,
|
|
22
|
+
GridSystem,
|
|
23
|
+
validateChildren,
|
|
24
|
+
Item,
|
|
25
|
+
ItemList,
|
|
26
|
+
};
|
package/Layout/types.ts
CHANGED