@momo-kits/foundation 0.80.8-beta.12 → 0.80.8-beta.14
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 +2 -3
- package/Image/index.tsx +21 -11
- package/Layout/Card.tsx +2 -5
- package/Layout/Screen.tsx +2 -8
- package/Layout/styles.ts +7 -1
- package/Layout/utils.ts +2 -4
- package/package.json +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, {Fragment, useContext, useEffect, useState} from 'react';
|
|
2
2
|
import {
|
|
3
|
-
Alert,
|
|
4
3
|
Animated,
|
|
5
4
|
DeviceEventEmitter,
|
|
6
5
|
Platform,
|
|
@@ -24,6 +23,7 @@ import {
|
|
|
24
23
|
import {scaleSize, Text} from '../Text';
|
|
25
24
|
import {Icon} from '../Icon';
|
|
26
25
|
import {PopupNotify} from '../Popup';
|
|
26
|
+
import Carousel from '@momo-kits/carousel';
|
|
27
27
|
|
|
28
28
|
const Touchable =
|
|
29
29
|
Platform.OS === 'android' ? TouchableGesture : TouchableOpacity;
|
|
@@ -276,8 +276,7 @@ const HeaderRightAction: React.FC<any> = ({children, ...restProps}) => {
|
|
|
276
276
|
const validateType = (child: React.ReactElement) => {
|
|
277
277
|
const valid = child?.type === NavigationButton || child?.type == Fragment;
|
|
278
278
|
if (__DEV__ && !valid) {
|
|
279
|
-
|
|
280
|
-
'Rule',
|
|
279
|
+
console.warn(
|
|
281
280
|
'HeaderRightAction contains element type of NavigationButton, Please check again.',
|
|
282
281
|
);
|
|
283
282
|
}
|
package/Image/index.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {useContext, useState} from 'react';
|
|
1
|
+
import React, {useContext, useRef, useState} from 'react';
|
|
2
2
|
import {StyleProp, StyleSheet, View, ViewStyle} from 'react-native';
|
|
3
3
|
import FastImage from 'react-native-fast-image';
|
|
4
4
|
import styles from './styles';
|
|
@@ -14,6 +14,8 @@ export interface ImageProps extends FastImagePropsWithoutStyle {
|
|
|
14
14
|
accessibilityLabel?: string;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
type Status = 'success' | 'loading' | 'error';
|
|
18
|
+
|
|
17
19
|
const Image: React.FC<ImageProps> = ({
|
|
18
20
|
style,
|
|
19
21
|
source,
|
|
@@ -21,19 +23,20 @@ const Image: React.FC<ImageProps> = ({
|
|
|
21
23
|
...rest
|
|
22
24
|
}) => {
|
|
23
25
|
const {theme} = useContext(ApplicationContext);
|
|
24
|
-
const
|
|
25
|
-
const [
|
|
26
|
+
const error = useRef(false);
|
|
27
|
+
const [status, setStatus] = useState<Status>(
|
|
28
|
+
rest.loading ? 'loading' : 'success',
|
|
29
|
+
);
|
|
26
30
|
|
|
27
31
|
/**
|
|
28
32
|
* render content loading | fail | rendered
|
|
29
|
-
* @returns {JSX.Element}
|
|
30
33
|
*/
|
|
31
34
|
const renderContent = () => {
|
|
32
|
-
if (loading ||
|
|
35
|
+
if (status == 'loading' || status == 'error') {
|
|
33
36
|
let content = (
|
|
34
37
|
<Skeleton style={[StyleSheet.absoluteFill, styles.image]} />
|
|
35
38
|
);
|
|
36
|
-
if (
|
|
39
|
+
if (status == 'error') {
|
|
37
40
|
content = (
|
|
38
41
|
<View style={Styles.flexCenter}>
|
|
39
42
|
<Icon source="media_fail" color={theme.colors.text.disable} />
|
|
@@ -63,12 +66,19 @@ const Image: React.FC<ImageProps> = ({
|
|
|
63
66
|
{...rest}
|
|
64
67
|
source={source}
|
|
65
68
|
style={styles.image}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
onLoadStart={() => {
|
|
70
|
+
error.current = false;
|
|
71
|
+
}}
|
|
72
|
+
onLoadEnd={() => {
|
|
73
|
+
if (error.current) {
|
|
74
|
+
setStatus('error');
|
|
75
|
+
} else {
|
|
76
|
+
setStatus('success');
|
|
77
|
+
}
|
|
78
|
+
}}
|
|
79
|
+
onError={() => {
|
|
80
|
+
error.current = true;
|
|
69
81
|
}}
|
|
70
|
-
onLoadEnd={() => setLoading(false)}
|
|
71
|
-
onError={() => setFail(true)}
|
|
72
82
|
/>
|
|
73
83
|
{renderContent()}
|
|
74
84
|
</View>
|
package/Layout/Card.tsx
CHANGED
|
@@ -7,7 +7,7 @@ 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,
|
|
10
|
+
import {Colors, Shadow, Spacing} from '../Consts';
|
|
11
11
|
|
|
12
12
|
export interface CardProps extends ViewProps {
|
|
13
13
|
/**
|
|
@@ -140,15 +140,12 @@ const Card: React.FC<CardProps> = ({
|
|
|
140
140
|
<View
|
|
141
141
|
accessibilityLabel={`Card`}
|
|
142
142
|
style={[
|
|
143
|
-
{
|
|
144
|
-
backgroundColor: theme.colors.background.surface,
|
|
145
|
-
borderRadius: Radius.M,
|
|
146
|
-
},
|
|
147
143
|
style,
|
|
148
144
|
styles.card,
|
|
149
145
|
{
|
|
150
146
|
width: widthSection,
|
|
151
147
|
marginHorizontal: gridContext.margin,
|
|
148
|
+
backgroundColor: theme.colors.background.surface,
|
|
152
149
|
},
|
|
153
150
|
useShadow && Shadow.Light,
|
|
154
151
|
]}>
|
package/Layout/Screen.tsx
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
HeaderTitle,
|
|
25
25
|
} from '../Application';
|
|
26
26
|
import Navigation from '../Application/Navigation';
|
|
27
|
+
import styles from './styles';
|
|
27
28
|
|
|
28
29
|
export interface ScreenProps extends ViewProps {
|
|
29
30
|
children: React.ReactNode;
|
|
@@ -238,14 +239,7 @@ const Screen = forwardRef(
|
|
|
238
239
|
<View
|
|
239
240
|
style={[Styles.flex, {backgroundColor}]}
|
|
240
241
|
accessibilityLabel={`ScreenContainer`}>
|
|
241
|
-
<View
|
|
242
|
-
style={{
|
|
243
|
-
position: 'absolute',
|
|
244
|
-
width: '100%',
|
|
245
|
-
maxHeight: 215,
|
|
246
|
-
}}>
|
|
247
|
-
{renderHeader()}
|
|
248
|
-
</View>
|
|
242
|
+
<View style={styles.screenBanner}>{renderHeader()}</View>
|
|
249
243
|
<KeyboardAvoidingView
|
|
250
244
|
style={[Styles.flex, {paddingTop: marginHeader}]}
|
|
251
245
|
enabled={enableKeyboardAvoidingView}
|
package/Layout/styles.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import {StyleSheet} from 'react-native';
|
|
2
|
-
import {Spacing} from '../Consts';
|
|
2
|
+
import {Radius, Spacing} from '../Consts';
|
|
3
3
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
|
+
screenBanner: {
|
|
6
|
+
position: 'absolute',
|
|
7
|
+
width: '100%',
|
|
8
|
+
maxHeight: 215,
|
|
9
|
+
},
|
|
5
10
|
boxGrid: {
|
|
6
11
|
position: 'absolute',
|
|
7
12
|
top: 0,
|
|
@@ -35,6 +40,7 @@ export default StyleSheet.create({
|
|
|
35
40
|
card: {
|
|
36
41
|
flexDirection: 'row',
|
|
37
42
|
flexWrap: 'wrap',
|
|
43
|
+
borderRadius: Radius.M,
|
|
38
44
|
paddingTop: undefined,
|
|
39
45
|
paddingBottom: undefined,
|
|
40
46
|
paddingLeft: undefined,
|
package/Layout/utils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {Dimensions} from 'react-native';
|
|
2
2
|
import React, {Fragment, ReactElement, useEffect, useState} from 'react';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -17,14 +17,12 @@ const validateChildren = (
|
|
|
17
17
|
childrenType => child?.type === childrenType || child?.type == Fragment,
|
|
18
18
|
);
|
|
19
19
|
if (!valid) {
|
|
20
|
-
|
|
21
|
-
'Component Kits',
|
|
20
|
+
console.warn(
|
|
22
21
|
`Wrong children type for this component, expected are ${childrenTypes
|
|
23
22
|
.map(type => type.displayName)
|
|
24
23
|
.join(', ')}.`,
|
|
25
24
|
);
|
|
26
25
|
}
|
|
27
|
-
return valid;
|
|
28
26
|
};
|
|
29
27
|
|
|
30
28
|
if (Array.isArray(children)) {
|