@fto-consult/expo-ui 8.13.1 → 8.13.3
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/package.json
CHANGED
@@ -0,0 +1,167 @@
|
|
1
|
+
//@see : https://www.npmjs.com/package/react-native-animated-splash-screen
|
2
|
+
|
3
|
+
/* @flow */
|
4
|
+
import PropTypes from "prop-types"
|
5
|
+
import * as React from "react"
|
6
|
+
import { Animated, StatusBar, StyleSheet } from "react-native"
|
7
|
+
import styles, {
|
8
|
+
_staticBackground,
|
9
|
+
_dynamicLogoStyle,
|
10
|
+
_dynamicCustomComponentStyle,
|
11
|
+
_dynamicImageBackground,
|
12
|
+
_dynamicBackgroundOpacity,
|
13
|
+
} from "./AnimatedSplash.style";
|
14
|
+
import View from "$ecomponents/View";
|
15
|
+
import {isNativeMobile} from "$cplatform";
|
16
|
+
import {defaultDecimal} from "$cutils";
|
17
|
+
import {LogoProgress} from "$ecomponents/Logo";
|
18
|
+
import { Portal } from "react-native-paper";
|
19
|
+
import {defaultStr} from "$cutils";
|
20
|
+
|
21
|
+
class AnimatedSplash extends React.Component {
|
22
|
+
static defaultProps = {
|
23
|
+
isLoaded: false,
|
24
|
+
}
|
25
|
+
|
26
|
+
state = {
|
27
|
+
animationDone: false,
|
28
|
+
loadingProgress: new Animated.Value(0),
|
29
|
+
showStatusBar: true,
|
30
|
+
}
|
31
|
+
|
32
|
+
componentDidUpdate(prevProps) {
|
33
|
+
const { isLoaded , duration, delay } = this.props
|
34
|
+
const { loadingProgress } = this.state
|
35
|
+
if (isLoaded && !prevProps.isLoaded) {
|
36
|
+
Animated.timing(loadingProgress, {
|
37
|
+
toValue: 100,
|
38
|
+
duration: duration || 1000,
|
39
|
+
delay: delay || 0,
|
40
|
+
useNativeDriver: isNativeMobile(),
|
41
|
+
}).start(() => {
|
42
|
+
this.setState({
|
43
|
+
animationDone: true,
|
44
|
+
})
|
45
|
+
})
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
renderChildren() {
|
50
|
+
const { children, preload, isLoaded } = this.props
|
51
|
+
if (isLoaded) {
|
52
|
+
return children
|
53
|
+
}
|
54
|
+
return null
|
55
|
+
}
|
56
|
+
|
57
|
+
render() {
|
58
|
+
const { loadingProgress, animationDone } = this.state
|
59
|
+
const {
|
60
|
+
logoImage,
|
61
|
+
logoWidth,
|
62
|
+
logoHeight,
|
63
|
+
backgroundColor,
|
64
|
+
customComponent,
|
65
|
+
disableAppScale,
|
66
|
+
} = this.props
|
67
|
+
|
68
|
+
const opacityClearToVisible = {
|
69
|
+
opacity: loadingProgress.interpolate({
|
70
|
+
inputRange: [0, 15, 30],
|
71
|
+
outputRange: [0, 0, 1],
|
72
|
+
extrapolate: "clamp",
|
73
|
+
}),
|
74
|
+
}
|
75
|
+
|
76
|
+
const imageScale = {
|
77
|
+
transform: [
|
78
|
+
{
|
79
|
+
scale: loadingProgress.interpolate({
|
80
|
+
inputRange: [0, 10, 100],
|
81
|
+
outputRange: [1, 1, 65],
|
82
|
+
}),
|
83
|
+
},
|
84
|
+
],
|
85
|
+
}
|
86
|
+
|
87
|
+
const logoScale = {
|
88
|
+
transform: [
|
89
|
+
{
|
90
|
+
scale: loadingProgress.interpolate({
|
91
|
+
inputRange: [0, 10, 100],
|
92
|
+
outputRange: [1, 0.8, 10],
|
93
|
+
}),
|
94
|
+
},
|
95
|
+
],
|
96
|
+
}
|
97
|
+
|
98
|
+
const logoOpacity = {
|
99
|
+
opacity: loadingProgress.interpolate({
|
100
|
+
inputRange: [0, 20, 100],
|
101
|
+
outputRange: [1, 0, 0],
|
102
|
+
extrapolate: "clamp",
|
103
|
+
}),
|
104
|
+
}
|
105
|
+
|
106
|
+
const appScale = {
|
107
|
+
transform: [
|
108
|
+
{
|
109
|
+
scale: loadingProgress.interpolate({
|
110
|
+
inputRange: [0, 7, 100],
|
111
|
+
outputRange: [1.1, 1.05, 1],
|
112
|
+
}),
|
113
|
+
},
|
114
|
+
],
|
115
|
+
}
|
116
|
+
const testID = defaultStr(testID,"RN_MainSplashScreen");
|
117
|
+
const {Component} = this.props;
|
118
|
+
return (
|
119
|
+
<View testID={testID} style={[styles.container]}>
|
120
|
+
{!animationDone && <View style={StyleSheet.absoluteFill} testID={`${testID}_AbsoluteFill`} />}
|
121
|
+
<View style={styles.containerGlue} testID={`${testID}_ContainerGlue`}>
|
122
|
+
{!animationDone && (
|
123
|
+
<Animated.View
|
124
|
+
testID={`${testID}_StaticBackground`}
|
125
|
+
style={_staticBackground(logoOpacity, backgroundColor)}
|
126
|
+
/>
|
127
|
+
)}
|
128
|
+
<Animated.View testID={`${testID}_ChildrenContainer`} style={[!disableAppScale && appScale, opacityClearToVisible, styles.flex]}>
|
129
|
+
{this.renderChildren()}
|
130
|
+
</Animated.View>
|
131
|
+
{!animationDone && (React.isComponent(Component)? <Component testID={testID+"_CustomSplashComponent"}/> :
|
132
|
+
<View testID={`${testID}_AbsoluteFillContainer`} style={[StyleSheet.absoluteFill, styles.logoStyle]}>
|
133
|
+
{<View testID={testID+"_LogoContainer"} style={[StyleSheet.absoluteFill,{backgroundColor}, styles.logoStyle]}>
|
134
|
+
<Animated.View
|
135
|
+
testID={testID+"_LogoProgressContainer"}
|
136
|
+
style={_dynamicCustomComponentStyle(
|
137
|
+
logoScale,
|
138
|
+
logoOpacity,
|
139
|
+
logoWidth,
|
140
|
+
logoHeight
|
141
|
+
)}>
|
142
|
+
{<LogoProgress />}
|
143
|
+
</Animated.View>
|
144
|
+
</View>}
|
145
|
+
</View>
|
146
|
+
)}
|
147
|
+
</View>
|
148
|
+
</View>
|
149
|
+
)
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
153
|
+
AnimatedSplash.propTypes = {
|
154
|
+
preload: PropTypes.bool,
|
155
|
+
logoWidth: PropTypes.number,
|
156
|
+
children: PropTypes.element,
|
157
|
+
logoHeight: PropTypes.number,
|
158
|
+
backgroundColor: PropTypes.string,
|
159
|
+
isLoaded: PropTypes.bool.isRequired,
|
160
|
+
translucent: PropTypes.bool,
|
161
|
+
customComponent: PropTypes.element,
|
162
|
+
disableAppScale: PropTypes.bool,
|
163
|
+
duration: PropTypes.number,
|
164
|
+
delay: PropTypes.number,
|
165
|
+
}
|
166
|
+
|
167
|
+
export default AnimatedSplash
|
@@ -1,22 +1,22 @@
|
|
1
|
-
//@see : https://www.npmjs.com/package/react-native-animated-splash-screen
|
2
|
-
|
3
1
|
/* @flow */
|
2
|
+
/*** fork of https://www.npmjs.com/package/react-native-animated-splash-screen */
|
4
3
|
import PropTypes from "prop-types"
|
5
4
|
import * as React from "react"
|
6
|
-
import {
|
5
|
+
import {Animated, StyleSheet } from "react-native";
|
6
|
+
import View from "$ecomponents/View";
|
7
|
+
import {isNativeMobile} from "$platform";
|
8
|
+
import {defaultDecimal} from "$utils";
|
9
|
+
import {LogoProgress} from "$ecomponents/Logo";
|
7
10
|
import styles, {
|
11
|
+
_solidBackground,
|
8
12
|
_staticBackground,
|
9
13
|
_dynamicLogoStyle,
|
10
14
|
_dynamicCustomComponentStyle,
|
11
15
|
_dynamicImageBackground,
|
12
16
|
_dynamicBackgroundOpacity,
|
13
|
-
} from "./AnimatedSplash.style"
|
14
|
-
|
15
|
-
|
16
|
-
import {defaultDecimal} from "$cutils";
|
17
|
-
import {LogoProgress} from "$ecomponents/Logo";
|
18
|
-
import { Portal } from "react-native-paper";
|
19
|
-
import {defaultStr} from "$cutils";
|
17
|
+
} from "./AnimatedSplash.style"
|
18
|
+
const isNative = isNativeMobile();
|
19
|
+
const Component = isNative? Animated.View : View;
|
20
20
|
|
21
21
|
class AnimatedSplash extends React.Component {
|
22
22
|
static defaultProps = {
|
@@ -25,46 +25,57 @@ class AnimatedSplash extends React.Component {
|
|
25
25
|
|
26
26
|
state = {
|
27
27
|
animationDone: false,
|
28
|
-
loadingProgress: new Animated.Value(0)
|
29
|
-
showStatusBar: true,
|
28
|
+
loadingProgress: new Animated.Value(0)
|
30
29
|
}
|
31
30
|
|
32
31
|
componentDidUpdate(prevProps) {
|
33
32
|
const { isLoaded , duration, delay } = this.props
|
34
33
|
const { loadingProgress } = this.state
|
34
|
+
|
35
35
|
if (isLoaded && !prevProps.isLoaded) {
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
36
|
+
if(!isNativeMobile()){
|
37
|
+
this.setState({animationDone:true});
|
38
|
+
} else {
|
39
|
+
Animated.timing(loadingProgress, {
|
40
|
+
toValue: 100,
|
41
|
+
duration: duration || 1000,
|
42
|
+
delay: delay || 0,
|
43
|
+
useNativeDriver: true,
|
44
|
+
}).start(() => {
|
45
|
+
this.setState({
|
46
|
+
animationDone: true,
|
47
|
+
})
|
44
48
|
})
|
45
|
-
}
|
49
|
+
}
|
46
50
|
}
|
47
51
|
}
|
48
52
|
|
49
53
|
renderChildren() {
|
50
54
|
const { children, preload, isLoaded } = this.props
|
51
|
-
if (
|
55
|
+
if (preload || preload == null) {
|
56
|
+
return children
|
57
|
+
} else {
|
58
|
+
if (isLoaded) {
|
52
59
|
return children
|
60
|
+
}
|
53
61
|
}
|
62
|
+
|
54
63
|
return null
|
55
64
|
}
|
56
65
|
|
57
66
|
render() {
|
58
67
|
const { loadingProgress, animationDone } = this.state
|
59
|
-
|
60
|
-
logoImage,
|
68
|
+
let {
|
61
69
|
logoWidth,
|
62
70
|
logoHeight,
|
63
71
|
backgroundColor,
|
64
|
-
|
72
|
+
imageBackgroundSource,
|
73
|
+
imageBackgroundResizeMode,
|
65
74
|
disableAppScale,
|
75
|
+
disableImageBackgroundAnimation,
|
66
76
|
} = this.props
|
67
|
-
|
77
|
+
logoWidth = defaultDecimal(logoWidth,150);
|
78
|
+
logoHeight = defaultDecimal(logoHeight,150);
|
68
79
|
const opacityClearToVisible = {
|
69
80
|
opacity: loadingProgress.interpolate({
|
70
81
|
inputRange: [0, 15, 30],
|
@@ -113,35 +124,46 @@ class AnimatedSplash extends React.Component {
|
|
113
124
|
},
|
114
125
|
],
|
115
126
|
}
|
116
|
-
|
117
|
-
const {Component} = this.props;
|
127
|
+
|
118
128
|
return (
|
119
|
-
<View
|
120
|
-
{!animationDone && <View style={StyleSheet.absoluteFill}
|
121
|
-
<View style={styles.containerGlue}
|
129
|
+
<View style={[styles.container]}>
|
130
|
+
{!animationDone && <View style={StyleSheet.absoluteFill} />}
|
131
|
+
<View style={styles.containerGlue}>
|
122
132
|
{!animationDone && (
|
123
133
|
<Animated.View
|
124
|
-
testID={`${testID}_StaticBackground`}
|
125
134
|
style={_staticBackground(logoOpacity, backgroundColor)}
|
126
135
|
/>
|
127
136
|
)}
|
128
|
-
<
|
137
|
+
{(animationDone || isNative) && <Component style={[!disableAppScale && appScale, opacityClearToVisible, styles.flex]}>
|
129
138
|
{this.renderChildren()}
|
130
|
-
</
|
131
|
-
{!animationDone && (
|
132
|
-
<
|
133
|
-
{
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
139
|
+
</Component>}
|
140
|
+
{!animationDone && (
|
141
|
+
<Animated.Image
|
142
|
+
resizeMode={imageBackgroundResizeMode || "cover"}
|
143
|
+
source={imageBackgroundSource}
|
144
|
+
style={[disableImageBackgroundAnimation && _staticBackground(
|
145
|
+
logoOpacity,
|
146
|
+
backgroundColor
|
147
|
+
), disableImageBackgroundAnimation && _dynamicImageBackground(
|
148
|
+
imageScale,
|
149
|
+
logoOpacity,
|
150
|
+
backgroundColor
|
151
|
+
)]}
|
152
|
+
/>
|
153
|
+
)}
|
154
|
+
{!animationDone && (
|
155
|
+
<View style={[StyleSheet.absoluteFill, styles.logoStyle]}>
|
156
|
+
{(
|
157
|
+
<Animated.View
|
158
|
+
style={_dynamicCustomComponentStyle(
|
159
|
+
logoScale,
|
160
|
+
logoOpacity,
|
161
|
+
logoWidth,
|
162
|
+
logoHeight
|
163
|
+
)}>
|
164
|
+
{<LogoProgress/>}
|
165
|
+
</Animated.View>
|
166
|
+
)}
|
145
167
|
</View>
|
146
168
|
)}
|
147
169
|
</View>
|
@@ -157,8 +179,12 @@ AnimatedSplash.propTypes = {
|
|
157
179
|
logoHeight: PropTypes.number,
|
158
180
|
backgroundColor: PropTypes.string,
|
159
181
|
isLoaded: PropTypes.bool.isRequired,
|
160
|
-
|
161
|
-
|
182
|
+
disableBackgroundImage: PropTypes.bool,
|
183
|
+
logoImage: PropTypes.oneOfType([
|
184
|
+
PropTypes.string,
|
185
|
+
PropTypes.number,
|
186
|
+
PropTypes.object,
|
187
|
+
]),
|
162
188
|
disableAppScale: PropTypes.bool,
|
163
189
|
duration: PropTypes.number,
|
164
190
|
delay: PropTypes.number,
|