@momo-kits/foundation 0.80.8-beta.13 → 0.80.8-beta.15
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 +6 -1
- package/Image/index.tsx +21 -11
- package/Layout/Screen.tsx +13 -11
- package/Layout/styles.ts +0 -2
- package/package.json +1 -1
|
@@ -431,6 +431,11 @@ const HeaderAnimated: React.FC<HeaderAnimatedProps> = ({
|
|
|
431
431
|
outputRange: [1, 0.5, 0],
|
|
432
432
|
extrapolate: 'clamp',
|
|
433
433
|
});
|
|
434
|
+
const translateY = animatedValue.interpolate({
|
|
435
|
+
inputRange: [-300, 0],
|
|
436
|
+
outputRange: [-160, -2],
|
|
437
|
+
extrapolate: 'clamp',
|
|
438
|
+
});
|
|
434
439
|
|
|
435
440
|
return (
|
|
436
441
|
<TouchableOpacity onPress={onPress}>
|
|
@@ -438,7 +443,7 @@ const HeaderAnimated: React.FC<HeaderAnimatedProps> = ({
|
|
|
438
443
|
style={{
|
|
439
444
|
aspectRatio: 1.75,
|
|
440
445
|
opacity: opacity,
|
|
441
|
-
transform: [{scale
|
|
446
|
+
transform: [{scale}, {translateY}],
|
|
442
447
|
}}>
|
|
443
448
|
<Image
|
|
444
449
|
source={{
|
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/Screen.tsx
CHANGED
|
@@ -69,14 +69,14 @@ export interface ScreenProps extends ViewProps {
|
|
|
69
69
|
footerComponent?: ReactNode;
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
|
-
* Optional.
|
|
72
|
+
* Optional. Background color of the screen.
|
|
73
73
|
*/
|
|
74
|
-
|
|
74
|
+
backgroundColor?: string;
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
|
-
* Optional.
|
|
77
|
+
* Optional. layout card offset overlap header banner.
|
|
78
78
|
*/
|
|
79
|
-
|
|
79
|
+
layoutOffset?: -8 | -24 | -56;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
const Screen = forwardRef(
|
|
@@ -86,12 +86,13 @@ const Screen = forwardRef(
|
|
|
86
86
|
enableKeyboardAvoidingView = false,
|
|
87
87
|
scrollable = false,
|
|
88
88
|
navigation,
|
|
89
|
-
|
|
89
|
+
|
|
90
90
|
useExtendedHeader,
|
|
91
91
|
animatedHeader,
|
|
92
92
|
scrollViewProps,
|
|
93
93
|
headerComponent: Header,
|
|
94
94
|
footerComponent: Footer,
|
|
95
|
+
layoutOffset = -56,
|
|
95
96
|
backgroundColor,
|
|
96
97
|
}: ScreenProps,
|
|
97
98
|
ref,
|
|
@@ -99,16 +100,13 @@ const Screen = forwardRef(
|
|
|
99
100
|
const animatedValue = useRef<Animated.Value | undefined>(undefined);
|
|
100
101
|
const {theme} = useContext(ApplicationContext);
|
|
101
102
|
const insets = useSafeAreaInsets();
|
|
103
|
+
const heightHeader = useHeaderHeight();
|
|
102
104
|
|
|
103
105
|
let handleScroll;
|
|
104
106
|
let headerBackground: string | undefined = undefined;
|
|
105
107
|
let Component: any = View;
|
|
106
108
|
animatedValue.current = undefined;
|
|
107
109
|
|
|
108
|
-
if (useExtendedHeader || animatedHeader) {
|
|
109
|
-
marginHeader = marginHeader ?? useHeaderHeight();
|
|
110
|
-
}
|
|
111
|
-
|
|
112
110
|
if (useExtendedHeader) {
|
|
113
111
|
headerBackground = theme.assets?.headerBackground;
|
|
114
112
|
}
|
|
@@ -239,9 +237,8 @@ const Screen = forwardRef(
|
|
|
239
237
|
<View
|
|
240
238
|
style={[Styles.flex, {backgroundColor}]}
|
|
241
239
|
accessibilityLabel={`ScreenContainer`}>
|
|
242
|
-
<View style={styles.screenBanner}>{renderHeader()}</View>
|
|
243
240
|
<KeyboardAvoidingView
|
|
244
|
-
style={
|
|
241
|
+
style={Styles.flex}
|
|
245
242
|
enabled={enableKeyboardAvoidingView}
|
|
246
243
|
behavior={Platform.select({
|
|
247
244
|
ios: 'padding',
|
|
@@ -251,9 +248,14 @@ const Screen = forwardRef(
|
|
|
251
248
|
<Component
|
|
252
249
|
{...scrollViewProps}
|
|
253
250
|
ref={ref}
|
|
251
|
+
heightHeader={heightHeader}
|
|
254
252
|
showsVerticalScrollIndicator={false}
|
|
255
253
|
onScroll={handleScroll}
|
|
256
254
|
style={Styles.flex}>
|
|
255
|
+
<View
|
|
256
|
+
style={[styles.screenBanner, {maxHeight: 215 + layoutOffset}]}>
|
|
257
|
+
{renderHeader()}
|
|
258
|
+
</View>
|
|
257
259
|
{renderContent()}
|
|
258
260
|
</Component>
|
|
259
261
|
{Footer && (
|
package/Layout/styles.ts
CHANGED