@fto-consult/expo-ui 8.13.4 → 8.14.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "8.13.4",
3
+ "version": "8.14.1",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "scripts": {
6
6
  "clear-npx-cache": "npx clear-npx-cache",
package/src/App.js CHANGED
@@ -13,8 +13,8 @@ import App from "./AppEntry";
13
13
  * }
14
14
  */
15
15
 
16
- export default function ExpoUIAppEntryProvider({children,init,...rest}){
16
+ export default function ExpoUIAppEntryProvider({children,withSplashScreen,init,...rest}){
17
17
  return <Provider {...rest}>
18
- <App init={init} children={children}/>
18
+ <App withSplashScreen = {withSplashScreen} init={init} children={children}/>
19
19
  </Provider>
20
20
  }
@@ -59,7 +59,7 @@ const NAVIGATION_PERSISTENCE_KEY = 'NAVIGATION_STATE';
59
59
  * initialRouteName : la route initiale par défaut
60
60
  * getStartedRouteName : la route par défaut de getStarted lorsque l'application est en mode getStarted, c'est à dire lorsque la fonction init renvoie une erreur (reject)
61
61
  */
62
- function App({init:initApp,initialRouteName:appInitialRouteName,children}) {
62
+ function App({init:initApp,initialRouteName:appInitialRouteName,children,withSplashScreen}) {
63
63
  AppStateService.init();
64
64
  const SplashScreenComponent = useAppComponent("SplashScreen");
65
65
  const {FontsIconsFilter,beforeExit,AppWrapper,preferences:appPreferences,navigation,getStartedRouteName,components:{MainProvider}} = useContext();
@@ -266,6 +266,8 @@ function App({init:initApp,initialRouteName:appInitialRouteName,children}) {
266
266
  />
267
267
  </NavigationContainer> : null;
268
268
  const content = isLoaded ? typeof children == 'function'? children({children:child,appConfig,config:appConfig}) : child : null;
269
+ const SplashComponent = withSplashScreen === false ? React.Fragment : SplashScreen;
270
+ const splashProps = withSplashScreen === false ? {} : {isLoaded,Component:SplashScreenComponent};
269
271
  return <SafeAreaProvider>
270
272
  <AppEntryRootView MainProvider={MainProvider} isInitialized={state.hasCallInitApp} isLoading={isLoading} hasGetStarted={hasGetStarted} isLoaded={isLoaded}>
271
273
  <PaperProvider
@@ -286,11 +288,11 @@ function App({init:initApp,initialRouteName:appInitialRouteName,children}) {
286
288
  <DropdownAlert ref={notificationRef}/>
287
289
  <ErrorBoundary>
288
290
  <StatusBar/>
289
- <SplashScreen Component={SplashScreenComponent} isLoaded={isLoaded}>
291
+ <SplashComponent {...splashProps}>
290
292
  <PreferencesContext.Provider value={preferences}>
291
- {React.isValidElement(content) && content || child}
293
+ {isLoaded ? React.isValidElement(content) && content || child : null}
292
294
  </PreferencesContext.Provider>
293
- </SplashScreen>
295
+ </SplashComponent>
294
296
  </ErrorBoundary>
295
297
  </Portal.Host>
296
298
  </PaperProvider>
@@ -1,12 +1,14 @@
1
1
  /* @flow */
2
2
  /*** fork of https://www.npmjs.com/package/react-native-animated-splash-screen */
3
3
  import PropTypes from "prop-types"
4
- import * as React from "react"
4
+ import React from "$react"
5
5
  import {Animated, StyleSheet } from "react-native";
6
6
  import View from "$ecomponents/View";
7
- import {isNativeMobile} from "$platform";
8
- import {defaultDecimal} from "$utils";
7
+ import {isNativeMobile} from "$cplatform";
8
+ import {defaultDecimal} from "$cutils";
9
9
  import {LogoProgress} from "$ecomponents/Logo";
10
+ import { Portal } from "react-native-paper";
11
+ import {defaultStr} from "$cutils";
10
12
  import styles, {
11
13
  _solidBackground,
12
14
  _staticBackground,
@@ -14,165 +16,101 @@ import styles, {
14
16
  _dynamicCustomComponentStyle,
15
17
  _dynamicImageBackground,
16
18
  _dynamicBackgroundOpacity,
17
- } from "./AnimatedSplash.style"
18
- const isNative = isNativeMobile();
19
- const Component = isNative? Animated.View : View;
19
+ } from "./styles"
20
+ import {useAppComponent} from "$econtext/hooks";
20
21
 
21
- class AnimatedSplash extends React.Component {
22
- static defaultProps = {
23
- isLoaded: false,
24
- }
25
-
26
- state = {
22
+ const SplashScreenComponent = ({isLoaded,children , duration, delay,logoWidth,logoHeight,backgroundColor,imageBackgroundSource,imageBackgroundResizeMode,
23
+ testID})=>{
24
+ const [state,setState] = React.useState({
27
25
  animationDone: false,
28
- loadingProgress: new Animated.Value(0)
29
- }
30
-
31
- componentDidUpdate(prevProps) {
32
- const { isLoaded , duration, delay } = this.props
33
- const { loadingProgress } = this.state
34
-
35
- if (isLoaded && !prevProps.isLoaded) {
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
- })
48
- })
49
- }
50
- }
51
- }
52
-
53
- renderChildren() {
54
- const { children, preload, isLoaded } = this.props
55
- if (preload || preload == null) {
56
- return children
57
- } else {
58
- if (isLoaded) {
59
- return children
60
- }
26
+ loadingProgress: new Animated.Value(0),
27
+ });
28
+ const { loadingProgress, animationDone} = state;
29
+ const prevIsLoaded = React.usePrevious(isLoaded);
30
+ const timerRef = React.useRef(null);
31
+ React.useEffect(()=>{
32
+ if(isLoaded && !prevIsLoaded){
33
+ Animated.timing(loadingProgress, {
34
+ toValue: 100,
35
+ duration: duration || 100,
36
+ delay: delay || 0,
37
+ useNativeDriver: isNativeMobile(),
38
+ }).start(() => {
39
+ setState({
40
+ ...state,
41
+ animationDone:true,
42
+ })
43
+ })
44
+ } else if(isLoaded){
45
+ clearTimeout(timerRef.current);
46
+ timerRef.current = setTimeout(()=>{
47
+ if(isLoaded && !animationDone){
48
+ setState({...state,animationDone:true});
49
+ }
50
+ clearTimeout(timerRef.current);
51
+ },delay|2000);
61
52
  }
53
+ },[isLoaded,prevIsLoaded,animationDone]);
54
+ testID = defaultStr(testID,"RN_SplashscreenComponent")
55
+ logoWidth = defaultDecimal(logoWidth,150);
56
+ logoHeight = defaultDecimal(logoHeight,250);
57
+ const Component = useAppComponent("SplashScreen");
62
58
 
63
- return null
59
+ const logoScale = {
60
+ transform: [
61
+ {
62
+ scale: loadingProgress.interpolate({
63
+ inputRange: [0, 10, 100],
64
+ outputRange: [1, 0.8, 10],
65
+ }),
66
+ },
67
+ ],
64
68
  }
65
69
 
66
- render() {
67
- const { loadingProgress, animationDone } = this.state
68
- let {
69
- logoWidth,
70
- logoHeight,
71
- backgroundColor,
72
- imageBackgroundSource,
73
- imageBackgroundResizeMode,
74
- disableAppScale,
75
- disableImageBackgroundAnimation,
76
- } = this.props
77
- logoWidth = defaultDecimal(logoWidth,150);
78
- logoHeight = defaultDecimal(logoHeight,150);
79
- const opacityClearToVisible = {
80
- opacity: loadingProgress.interpolate({
81
- inputRange: [0, 15, 30],
82
- outputRange: [0, 0, 1],
83
- extrapolate: "clamp",
84
- }),
85
- }
86
-
87
- const imageScale = {
88
- transform: [
89
- {
90
- scale: loadingProgress.interpolate({
91
- inputRange: [0, 10, 100],
92
- outputRange: [1, 1, 65],
93
- }),
94
- },
95
- ],
96
- }
97
-
98
- const logoScale = {
99
- transform: [
100
- {
101
- scale: loadingProgress.interpolate({
102
- inputRange: [0, 10, 100],
103
- outputRange: [1, 0.8, 10],
104
- }),
105
- },
106
- ],
107
- }
108
-
109
- const logoOpacity = {
110
- opacity: loadingProgress.interpolate({
111
- inputRange: [0, 20, 100],
112
- outputRange: [1, 0, 0],
113
- extrapolate: "clamp",
114
- }),
115
- }
116
-
117
- const appScale = {
118
- transform: [
119
- {
120
- scale: loadingProgress.interpolate({
121
- inputRange: [0, 7, 100],
122
- outputRange: [1.1, 1.05, 1],
123
- }),
124
- },
125
- ],
126
- }
127
-
128
- return (
129
- <View style={[styles.container]}>
130
- {!animationDone && <View style={StyleSheet.absoluteFill} />}
131
- <View style={styles.containerGlue}>
132
- {!animationDone && (
133
- <Animated.View
134
- style={_staticBackground(logoOpacity, backgroundColor)}
135
- />
136
- )}
137
- {(animationDone || isNative) && <Component style={[!disableAppScale && appScale, opacityClearToVisible, styles.flex]}>
138
- {this.renderChildren()}
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]}>
70
+ const logoOpacity = {
71
+ opacity: loadingProgress.interpolate({
72
+ inputRange: [0, 20, 100],
73
+ outputRange: [1, 0, 0],
74
+ extrapolate: "clamp",
75
+ }),
76
+ }
77
+ if(isLoaded && animationDone){
78
+ return React.isValidElement(children)?children:null;
79
+ }
80
+ return <>
81
+ {!animationDone || !isLoaded ? <Portal>
82
+ <View style={[styles.container,{backgroundColor}]} testID={testID} id={testID}>
83
+ {<View style={[StyleSheet.absoluteFill,{backgroundColor}]} testID={testID+"_Animation"}/>}
84
+ <View style={styles.containerGlue} testID={testID+"_ContainerGlue"}>
156
85
  {(
157
86
  <Animated.View
158
- style={_dynamicCustomComponentStyle(
159
- logoScale,
160
- logoOpacity,
161
- logoWidth,
162
- logoHeight
163
- )}>
164
- {<LogoProgress/>}
165
- </Animated.View>
87
+ style={_staticBackground(logoOpacity, backgroundColor)}
88
+ testID={testID+"_AnimationDone"}
89
+ />
90
+ )}
91
+ {(
92
+ React.isComponent(Component)? <Component testID={testID+"_CustomSplashComponent"}/> :
93
+ <View testID={testID+"_LogoContainer"} style={[StyleSheet.absoluteFill,{backgroundColor}, styles.logoStyle]}>
94
+ <Animated.View
95
+ testID={testID+"_Logo"}
96
+ style={_dynamicCustomComponentStyle(
97
+ logoScale,
98
+ logoOpacity,
99
+ logoWidth,
100
+ logoHeight
101
+ )}>
102
+ {<LogoProgress />}
103
+ </Animated.View>
104
+ </View>
166
105
  )}
167
106
  </View>
168
- )}
169
- </View>
170
- </View>
171
- )
172
- }
107
+ </View>
108
+ </Portal> : null}
109
+ </>
173
110
  }
174
111
 
175
- AnimatedSplash.propTypes = {
112
+
113
+ SplashScreenComponent.propTypes = {
176
114
  preload: PropTypes.bool,
177
115
  logoWidth: PropTypes.number,
178
116
  children: PropTypes.element,
@@ -190,4 +128,5 @@ AnimatedSplash.propTypes = {
190
128
  delay: PropTypes.number,
191
129
  }
192
130
 
193
- export default AnimatedSplash
131
+ SplashScreenComponent.displayName = "SplashScreenComponent";
132
+ export default SplashScreenComponent;
@@ -0,0 +1,193 @@
1
+ /* @flow */
2
+ /*** fork of https://www.npmjs.com/package/react-native-animated-splash-screen */
3
+ import PropTypes from "prop-types"
4
+ import * as React from "react"
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";
10
+ import styles, {
11
+ _solidBackground,
12
+ _staticBackground,
13
+ _dynamicLogoStyle,
14
+ _dynamicCustomComponentStyle,
15
+ _dynamicImageBackground,
16
+ _dynamicBackgroundOpacity,
17
+ } from "./AnimatedSplash.style"
18
+ const isNative = isNativeMobile();
19
+ const Component = isNative? Animated.View : View;
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
+ }
30
+
31
+ componentDidUpdate(prevProps) {
32
+ const { isLoaded , duration, delay } = this.props
33
+ const { loadingProgress } = this.state
34
+
35
+ if (isLoaded && !prevProps.isLoaded) {
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
+ })
48
+ })
49
+ }
50
+ }
51
+ }
52
+
53
+ renderChildren() {
54
+ const { children, preload, isLoaded } = this.props
55
+ if (preload || preload == null) {
56
+ return children
57
+ } else {
58
+ if (isLoaded) {
59
+ return children
60
+ }
61
+ }
62
+
63
+ return null
64
+ }
65
+
66
+ render() {
67
+ const { loadingProgress, animationDone } = this.state
68
+ let {
69
+ logoWidth,
70
+ logoHeight,
71
+ backgroundColor,
72
+ imageBackgroundSource,
73
+ imageBackgroundResizeMode,
74
+ disableAppScale,
75
+ disableImageBackgroundAnimation,
76
+ } = this.props
77
+ logoWidth = defaultDecimal(logoWidth,150);
78
+ logoHeight = defaultDecimal(logoHeight,150);
79
+ const opacityClearToVisible = {
80
+ opacity: loadingProgress.interpolate({
81
+ inputRange: [0, 15, 30],
82
+ outputRange: [0, 0, 1],
83
+ extrapolate: "clamp",
84
+ }),
85
+ }
86
+
87
+ const imageScale = {
88
+ transform: [
89
+ {
90
+ scale: loadingProgress.interpolate({
91
+ inputRange: [0, 10, 100],
92
+ outputRange: [1, 1, 65],
93
+ }),
94
+ },
95
+ ],
96
+ }
97
+
98
+ const logoScale = {
99
+ transform: [
100
+ {
101
+ scale: loadingProgress.interpolate({
102
+ inputRange: [0, 10, 100],
103
+ outputRange: [1, 0.8, 10],
104
+ }),
105
+ },
106
+ ],
107
+ }
108
+
109
+ const logoOpacity = {
110
+ opacity: loadingProgress.interpolate({
111
+ inputRange: [0, 20, 100],
112
+ outputRange: [1, 0, 0],
113
+ extrapolate: "clamp",
114
+ }),
115
+ }
116
+
117
+ const appScale = {
118
+ transform: [
119
+ {
120
+ scale: loadingProgress.interpolate({
121
+ inputRange: [0, 7, 100],
122
+ outputRange: [1.1, 1.05, 1],
123
+ }),
124
+ },
125
+ ],
126
+ }
127
+
128
+ return (
129
+ <View style={[styles.container]}>
130
+ {!animationDone && <View style={StyleSheet.absoluteFill} />}
131
+ <View style={styles.containerGlue}>
132
+ {!animationDone && (
133
+ <Animated.View
134
+ style={_staticBackground(logoOpacity, backgroundColor)}
135
+ />
136
+ )}
137
+ {(animationDone || isNative) && <Component style={[!disableAppScale && appScale, opacityClearToVisible, styles.flex]}>
138
+ {this.renderChildren()}
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
+ )}
167
+ </View>
168
+ )}
169
+ </View>
170
+ </View>
171
+ )
172
+ }
173
+ }
174
+
175
+ AnimatedSplash.propTypes = {
176
+ preload: PropTypes.bool,
177
+ logoWidth: PropTypes.number,
178
+ children: PropTypes.element,
179
+ logoHeight: PropTypes.number,
180
+ backgroundColor: PropTypes.string,
181
+ isLoaded: PropTypes.bool.isRequired,
182
+ disableBackgroundImage: PropTypes.bool,
183
+ logoImage: PropTypes.oneOfType([
184
+ PropTypes.string,
185
+ PropTypes.number,
186
+ PropTypes.object,
187
+ ]),
188
+ disableAppScale: PropTypes.bool,
189
+ duration: PropTypes.number,
190
+ delay: PropTypes.number,
191
+ }
192
+
193
+ export default AnimatedSplash
@@ -1,132 +0,0 @@
1
- /* @flow */
2
- /*** fork of https://www.npmjs.com/package/react-native-animated-splash-screen */
3
- import PropTypes from "prop-types"
4
- import React from "$react"
5
- import {Animated, StyleSheet } from "react-native";
6
- import View from "$ecomponents/View";
7
- import {isNativeMobile} from "$cplatform";
8
- import {defaultDecimal} from "$cutils";
9
- import {LogoProgress} from "$ecomponents/Logo";
10
- import { Portal } from "react-native-paper";
11
- import {defaultStr} from "$cutils";
12
- import styles, {
13
- _solidBackground,
14
- _staticBackground,
15
- _dynamicLogoStyle,
16
- _dynamicCustomComponentStyle,
17
- _dynamicImageBackground,
18
- _dynamicBackgroundOpacity,
19
- } from "./styles"
20
- import {useAppComponent} from "$econtext/hooks";
21
-
22
- const SplashScreenComponent = ({isLoaded,children , duration, delay,logoWidth,logoHeight,backgroundColor,imageBackgroundSource,imageBackgroundResizeMode,
23
- testID})=>{
24
- const [state,setState] = React.useState({
25
- animationDone: false,
26
- loadingProgress: new Animated.Value(0),
27
- });
28
- const { loadingProgress, animationDone} = state;
29
- const prevIsLoaded = React.usePrevious(isLoaded);
30
- const timerRef = React.useRef(null);
31
- React.useEffect(()=>{
32
- if(isLoaded && !prevIsLoaded){
33
- Animated.timing(loadingProgress, {
34
- toValue: 100,
35
- duration: duration || 100,
36
- delay: delay || 0,
37
- useNativeDriver: isNativeMobile(),
38
- }).start(() => {
39
- setState({
40
- ...state,
41
- animationDone:true,
42
- })
43
- })
44
- } else if(isLoaded){
45
- clearTimeout(timerRef.current);
46
- timerRef.current = setTimeout(()=>{
47
- if(isLoaded && !animationDone){
48
- setState({...state,animationDone:true});
49
- }
50
- clearTimeout(timerRef.current);
51
- },delay|2000);
52
- }
53
- },[isLoaded,prevIsLoaded,animationDone]);
54
- testID = defaultStr(testID,"RN_SplashscreenComponent")
55
- logoWidth = defaultDecimal(logoWidth,150);
56
- logoHeight = defaultDecimal(logoHeight,250);
57
- const Component = useAppComponent("SplashScreen");
58
-
59
- const logoScale = {
60
- transform: [
61
- {
62
- scale: loadingProgress.interpolate({
63
- inputRange: [0, 10, 100],
64
- outputRange: [1, 0.8, 10],
65
- }),
66
- },
67
- ],
68
- }
69
-
70
- const logoOpacity = {
71
- opacity: loadingProgress.interpolate({
72
- inputRange: [0, 20, 100],
73
- outputRange: [1, 0, 0],
74
- extrapolate: "clamp",
75
- }),
76
- }
77
- if(isLoaded && animationDone){
78
- return React.isValidElement(children)?children:null;
79
- }
80
- return <>
81
- {!animationDone || !isLoaded ? <Portal>
82
- <View style={[styles.container,{backgroundColor}]} testID={testID} id={testID}>
83
- {<View style={[StyleSheet.absoluteFill,{backgroundColor}]} testID={testID+"_Animation"}/>}
84
- <View style={styles.containerGlue} testID={testID+"_ContainerGlue"}>
85
- {(
86
- <Animated.View
87
- style={_staticBackground(logoOpacity, backgroundColor)}
88
- testID={testID+"_AnimationDone"}
89
- />
90
- )}
91
- {(
92
- React.isComponent(Component)? <Component testID={testID+"_CustomSplashComponent"}/> :
93
- <View testID={testID+"_LogoContainer"} style={[StyleSheet.absoluteFill,{backgroundColor}, styles.logoStyle]}>
94
- <Animated.View
95
- testID={testID+"_Logo"}
96
- style={_dynamicCustomComponentStyle(
97
- logoScale,
98
- logoOpacity,
99
- logoWidth,
100
- logoHeight
101
- )}>
102
- {<LogoProgress />}
103
- </Animated.View>
104
- </View>
105
- )}
106
- </View>
107
- </View>
108
- </Portal> : null}
109
- </>
110
- }
111
-
112
-
113
- SplashScreenComponent.propTypes = {
114
- preload: PropTypes.bool,
115
- logoWidth: PropTypes.number,
116
- children: PropTypes.element,
117
- logoHeight: PropTypes.number,
118
- backgroundColor: PropTypes.string,
119
- isLoaded: PropTypes.bool.isRequired,
120
- disableBackgroundImage: PropTypes.bool,
121
- logoImage: PropTypes.oneOfType([
122
- PropTypes.string,
123
- PropTypes.number,
124
- PropTypes.object,
125
- ]),
126
- disableAppScale: PropTypes.bool,
127
- duration: PropTypes.number,
128
- delay: PropTypes.number,
129
- }
130
-
131
- SplashScreenComponent.displayName = "SplashScreenComponent";
132
- export default SplashScreenComponent;