@momo-kits/foundation 0.81.1-beta.3 → 0.81.1-beta.4

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.
@@ -160,7 +160,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
160
160
  navigator?.pop();
161
161
  }
162
162
  }}
163
- bottomInset={bottomInset}
163
+ bottomInset={Platform.OS === 'ios' ? bottomInset : 0}
164
164
  handleComponent={null}
165
165
  backdropComponent={backdropComponent}>
166
166
  <BottomSheetView accessibilityLabel={'BottomSheet'}>
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
  /**
@@ -1,39 +1,40 @@
1
- import React, {FC, ReactElement, useContext} from 'react';
1
+ import React, {FC, useContext} from 'react';
2
2
  import {FlatList, FlatListProps, View} from 'react-native';
3
- import Item from './Item';
3
+ import Item, {SpanNumber} from './Item';
4
4
  import {GridContext} from './index';
5
5
  import styles from './styles';
6
6
 
7
- const ItemList: FC<FlatListProps<any>> = ({
7
+ export interface ItemListProps extends FlatListProps<any> {
8
+ /**
9
+ * Require key support number columns change grid system
10
+ */
11
+
12
+ key: string;
13
+ /**
14
+ * Represents the width of the Card component in terms of span numbers (1-12).
15
+ */
16
+ widthSpan?: SpanNumber;
17
+ }
18
+
19
+ const ItemList: FC<ItemListProps> = ({
20
+ key,
8
21
  renderItem,
9
- numColumns = 1,
22
+ widthSpan,
10
23
  style,
11
24
  contentContainerStyle,
12
25
  ...props
13
26
  }) => {
14
- const {gutterSize} = useContext(GridContext);
15
-
16
- const _renderItem = (info: any) => {
17
- const {item, index, separators} = info;
18
-
19
- const children = renderItem?.({
20
- item,
21
- index,
22
- separators,
23
- }) as ReactElement;
24
-
25
- if (children?.type !== Item) {
26
- console.warn('Wrong children type for this component, expected are Item');
27
+ const {gutterSize, numberOfColumns} = useContext(GridContext);
28
+ const widthItem = (widthSpan ?? numberOfColumns) as SpanNumber;
29
+ const numColumns = Math.floor(numberOfColumns / widthItem);
30
+ const indexBegin = props?.data?.map((_i, index) => index * numColumns);
31
+ const _renderItem = (item: any) => {
32
+ if (indexBegin?.includes(item?.index)) {
33
+ return <Item widthSpan={widthItem}>{renderItem?.(item)}</Item>;
27
34
  }
28
-
29
35
  return (
30
- <View
31
- style={
32
- numColumns > 1 && {
33
- marginRight: gutterSize,
34
- }
35
- }>
36
- {children}
36
+ <View style={{paddingLeft: gutterSize}}>
37
+ <Item widthSpan={widthItem}>{renderItem?.(item)}</Item>
37
38
  </View>
38
39
  );
39
40
  };
@@ -41,6 +42,7 @@ const ItemList: FC<FlatListProps<any>> = ({
41
42
  return (
42
43
  <FlatList
43
44
  {...props}
45
+ key={`${key ?? 'ItemList'}${numColumns}}`}
44
46
  numColumns={numColumns}
45
47
  renderItem={_renderItem}
46
48
  horizontal={false}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.81.1-beta.3",
3
+ "version": "0.81.1-beta.4",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {