@momo-kits/foundation 0.81.42 → 0.81.43-api.1
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.tsx +26 -10
- package/Application/types.ts +1 -0
- package/Layout/Card.tsx +8 -8
- package/Layout/ItemList.tsx +39 -33
- package/Layout/Section.tsx +4 -3
- package/package.json +1 -1
- package/verify.js +3 -2
|
@@ -3,29 +3,45 @@ import {Platform} from 'react-native';
|
|
|
3
3
|
import {BottomTabProps, NavigationScreenProps} from './types';
|
|
4
4
|
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
|
|
5
5
|
import {createStackNavigator} from '@react-navigation/stack';
|
|
6
|
+
import {useSafeAreaInsets} from 'react-native-safe-area-context';
|
|
7
|
+
import {NavigationContainer} from '@react-navigation/native';
|
|
6
8
|
import {Icon} from '../Icon';
|
|
7
9
|
import {Text} from '../Text';
|
|
8
10
|
import {ApplicationContext} from './index';
|
|
9
11
|
import {getStackOptions} from './utils';
|
|
10
12
|
import StackScreen from './StackScreen';
|
|
11
|
-
import {useSafeAreaInsets} from 'react-native-safe-area-context';
|
|
12
13
|
|
|
13
14
|
const Tab = createBottomTabNavigator();
|
|
14
15
|
const Stack = createStackNavigator();
|
|
15
16
|
|
|
16
17
|
const TabScreen: React.FC<NavigationScreenProps> = ({route}) => {
|
|
18
|
+
if (route.params?.nested) {
|
|
19
|
+
return (
|
|
20
|
+
<Stack.Navigator>
|
|
21
|
+
<Stack.Screen
|
|
22
|
+
name="Stack"
|
|
23
|
+
component={StackScreen}
|
|
24
|
+
initialParams={{screen: route.params?.screen}}
|
|
25
|
+
options={{...getStackOptions(), ...route.params?.options}}
|
|
26
|
+
/>
|
|
27
|
+
</Stack.Navigator>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
17
30
|
return (
|
|
18
|
-
<
|
|
19
|
-
<Stack.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
31
|
+
<NavigationContainer independent={true}>
|
|
32
|
+
<Stack.Navigator>
|
|
33
|
+
<Stack.Screen
|
|
34
|
+
name="Stack"
|
|
35
|
+
component={StackScreen}
|
|
36
|
+
initialParams={{screen: route.params?.screen}}
|
|
37
|
+
options={{...getStackOptions(), ...route.params?.options}}
|
|
38
|
+
/>
|
|
39
|
+
</Stack.Navigator>
|
|
40
|
+
</NavigationContainer>
|
|
26
41
|
);
|
|
27
42
|
};
|
|
28
43
|
const BottomTab: React.FC<BottomTabProps> = ({
|
|
44
|
+
nested,
|
|
29
45
|
tabs,
|
|
30
46
|
listeners,
|
|
31
47
|
navigation,
|
|
@@ -61,7 +77,7 @@ const BottomTab: React.FC<BottomTabProps> = ({
|
|
|
61
77
|
key={item.name}
|
|
62
78
|
name={item.name}
|
|
63
79
|
component={TabScreen}
|
|
64
|
-
initialParams={item}
|
|
80
|
+
initialParams={{...item, nested}}
|
|
65
81
|
listeners={listeners}
|
|
66
82
|
options={{
|
|
67
83
|
tabBarLabel: ({color, focused}) => {
|
package/Application/types.ts
CHANGED
package/Layout/Card.tsx
CHANGED
|
@@ -29,7 +29,7 @@ const Card: React.FC<CardProps> = ({
|
|
|
29
29
|
useShadow = false,
|
|
30
30
|
...props
|
|
31
31
|
}) => {
|
|
32
|
-
const {showGrid} = useContext(ApplicationContext);
|
|
32
|
+
const {showGrid, theme} = useContext(ApplicationContext);
|
|
33
33
|
const {numberOfColumns} = useGridSystem();
|
|
34
34
|
|
|
35
35
|
const gutterSize = 8;
|
|
@@ -47,6 +47,7 @@ const Card: React.FC<CardProps> = ({
|
|
|
47
47
|
return span * sizePerSpan + (span - 1) * gutterSize;
|
|
48
48
|
},
|
|
49
49
|
};
|
|
50
|
+
|
|
50
51
|
/**
|
|
51
52
|
* render overlay only dev mode
|
|
52
53
|
*/
|
|
@@ -107,8 +108,9 @@ const Card: React.FC<CardProps> = ({
|
|
|
107
108
|
if (Array.isArray(children)) {
|
|
108
109
|
let cursor = 0;
|
|
109
110
|
let rows: any[] = [];
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
const arrayChild = children.filter(item => !!item);
|
|
112
|
+
for (let i = 0; i < arrayChild.length; ++i) {
|
|
113
|
+
const item = arrayChild[i];
|
|
112
114
|
const totalSpan = rows
|
|
113
115
|
.concat([item])
|
|
114
116
|
.map(i => i.props?.widthSpan)
|
|
@@ -124,7 +126,7 @@ const Card: React.FC<CardProps> = ({
|
|
|
124
126
|
rows = [item];
|
|
125
127
|
}
|
|
126
128
|
|
|
127
|
-
if (i ==
|
|
129
|
+
if (i == arrayChild.length - 1) {
|
|
128
130
|
cursor += 1;
|
|
129
131
|
element.push(addRowView(rows, cursor, true));
|
|
130
132
|
}
|
|
@@ -138,23 +140,21 @@ const Card: React.FC<CardProps> = ({
|
|
|
138
140
|
return element;
|
|
139
141
|
};
|
|
140
142
|
|
|
141
|
-
const {theme} = useContext(ApplicationContext);
|
|
142
143
|
return (
|
|
143
144
|
<GridContext.Provider value={gridContext}>
|
|
144
145
|
<View
|
|
145
146
|
{...props}
|
|
146
147
|
accessibilityLabel={`Card`}
|
|
147
148
|
style={[
|
|
149
|
+
{backgroundColor: theme.colors.background.surface},
|
|
148
150
|
style,
|
|
149
151
|
styles.protectedStyle,
|
|
150
152
|
styles.card,
|
|
151
153
|
{
|
|
152
154
|
width: widthSection,
|
|
153
155
|
marginHorizontal: margin,
|
|
154
|
-
backgroundColor: backgroundImage
|
|
155
|
-
? undefined
|
|
156
|
-
: theme.colors.background.surface,
|
|
157
156
|
},
|
|
157
|
+
!!backgroundImage && {backgroundColor: undefined},
|
|
158
158
|
useShadow && Shadow.Light,
|
|
159
159
|
]}>
|
|
160
160
|
{!!backgroundImage && (
|
package/Layout/ItemList.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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';
|
|
@@ -11,39 +11,45 @@ export interface ItemListProps extends FlatListProps<any> {
|
|
|
11
11
|
widthSpan?: SpanNumber;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const ItemList
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
+
|
|
29
40
|
return (
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
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
|
+
/>
|
|
33
51
|
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<FlatList
|
|
38
|
-
{...props}
|
|
39
|
-
numColumns={numColumns}
|
|
40
|
-
renderItem={_renderItem}
|
|
41
|
-
horizontal={false}
|
|
42
|
-
ItemSeparatorComponent={() => <View style={{height: gutterSize}} />}
|
|
43
|
-
style={[style, styles.protectedStyle]}
|
|
44
|
-
contentContainerStyle={[contentContainerStyle, styles.protectedStyle]}
|
|
45
|
-
/>
|
|
46
|
-
);
|
|
47
|
-
};
|
|
52
|
+
},
|
|
53
|
+
);
|
|
48
54
|
|
|
49
55
|
export default ItemList;
|
package/Layout/Section.tsx
CHANGED
|
@@ -107,8 +107,9 @@ const Section: React.FC<SectionProps> = ({
|
|
|
107
107
|
if (Array.isArray(children)) {
|
|
108
108
|
let cursor = 0;
|
|
109
109
|
let rows: any[] = [];
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
const arrayChild = children.filter(item => !!item);
|
|
111
|
+
for (let i = 0; i < arrayChild.length; ++i) {
|
|
112
|
+
const item = arrayChild[i];
|
|
112
113
|
const totalSpan = rows
|
|
113
114
|
.concat([item])
|
|
114
115
|
.map(i => i.props?.widthSpan)
|
|
@@ -124,7 +125,7 @@ const Section: React.FC<SectionProps> = ({
|
|
|
124
125
|
rows = [item];
|
|
125
126
|
}
|
|
126
127
|
|
|
127
|
-
if (i ==
|
|
128
|
+
if (i == arrayChild.length - 1) {
|
|
128
129
|
cursor += 1;
|
|
129
130
|
element.push(addRowView(rows, cursor, true));
|
|
130
131
|
}
|
package/package.json
CHANGED
package/verify.js
CHANGED
|
@@ -27,8 +27,9 @@ try {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
if (
|
|
30
|
-
miniInfo?.
|
|
31
|
-
miniInfo?.
|
|
30
|
+
miniInfo?.dependencies?.['@momo-platform/momo-core'] &&
|
|
31
|
+
miniInfo?.dependencies?.['@momo-platform/momo-core'] !==
|
|
32
|
+
packageInfo?.version
|
|
32
33
|
) {
|
|
33
34
|
console.error(
|
|
34
35
|
`Package ${packageInfo.name} version: ${packageInfo.version} require install resolutions @momo-platform/momo-core ${packageInfo.version}`,
|