@fto-consult/expo-ui 8.13.0 → 8.13.2

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.0",
3
+ "version": "8.13.2",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "scripts": {
6
6
  "clear-npx-cache": "npx clear-npx-cache",
@@ -15,6 +15,7 @@ import {set as setSession,get as getSession} from "$session";
15
15
  import { showConfirm } from "$ecomponents/Dialog";
16
16
  import {close as closePreloader, isVisible as isPreloaderVisible} from "$epreloader";
17
17
  import SplashScreen from "$ecomponents/SplashScreen";
18
+ import {useAppComponent} from "$econtext/hooks";
18
19
  import {decycle} from "$cutils/json";
19
20
  import { setIsInitialized} from "$capp/utils";
20
21
  import {isObj,defaultObj,defaultStr} from "$cutils";
@@ -60,6 +61,7 @@ const NAVIGATION_PERSISTENCE_KEY = 'NAVIGATION_STATE';
60
61
  */
61
62
  function App({init:initApp,initialRouteName:appInitialRouteName,children}) {
62
63
  AppStateService.init();
64
+ const SplashScreenComponent = useAppComponent("SplashScreen");
63
65
  const {FontsIconsFilter,beforeExit,AppWrapper,preferences:appPreferences,navigation,getStartedRouteName,components:{MainProvider}} = useContext();
64
66
  const {containerProps} = navigation;
65
67
  const [initialState, setInitialState] = React.useState(undefined);
@@ -284,7 +286,7 @@ function App({init:initApp,initialRouteName:appInitialRouteName,children}) {
284
286
  <DropdownAlert ref={notificationRef}/>
285
287
  <ErrorBoundary>
286
288
  <StatusBar/>
287
- <SplashScreen isLoaded={isLoaded}>
289
+ <SplashScreen Component={SplashScreenComponent} isLoaded={isLoaded}>
288
290
  <PreferencesContext.Provider value={preferences}>
289
291
  {React.isValidElement(content) && content || child}
290
292
  </PreferencesContext.Provider>
@@ -1,98 +1,138 @@
1
+ //@see : https://www.npmjs.com/package/react-native-animated-splash-screen
2
+
1
3
  /* @flow */
2
- /*** fork of https://www.npmjs.com/package/react-native-animated-splash-screen */
3
4
  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";
5
+ import * as React from "react"
6
+ import { Animated, StatusBar, StyleSheet } from "react-native"
12
7
  import styles, {
13
- _solidBackground,
14
8
  _staticBackground,
15
9
  _dynamicLogoStyle,
16
10
  _dynamicCustomComponentStyle,
17
11
  _dynamicImageBackground,
18
12
  _dynamicBackgroundOpacity,
19
- } from "./styles"
20
- import {useAppComponent} from "$econtext/hooks";
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";
21
20
 
22
- const SplashScreenComponent = ({isLoaded,children , duration, delay,logoWidth,logoHeight,backgroundColor,imageBackgroundSource,imageBackgroundResizeMode,
23
- testID})=>{
24
- const [state,setState] = React.useState({
21
+ class AnimatedSplash extends React.Component {
22
+ static defaultProps = {
23
+ isLoaded: false,
24
+ }
25
+
26
+ state = {
25
27
  animationDone: false,
26
28
  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){
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) {
33
36
  Animated.timing(loadingProgress, {
34
- toValue: 100,
35
- duration: duration || 100,
36
- delay: delay || 0,
37
- useNativeDriver: isNativeMobile(),
37
+ toValue: 100,
38
+ duration: duration || 1000,
39
+ delay: delay || 0,
40
+ useNativeDriver: isNativeMobile(),
38
41
  }).start(() => {
39
- setState({
40
- ...state,
41
- animationDone:true,
42
- })
42
+ this.setState({
43
+ animationDone: true,
44
+ })
43
45
  })
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
46
  }
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
47
  }
69
48
 
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;
49
+ renderChildren() {
50
+ const { children, preload, isLoaded } = this.props
51
+ if (isLoaded) {
52
+ return children
53
+ }
54
+ return null
79
55
  }
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]}>
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]}>
94
134
  <Animated.View
95
- testID={testID+"_Logo"}
135
+ testID={testID+"_LogoProgressContainer"}
96
136
  style={_dynamicCustomComponentStyle(
97
137
  logoScale,
98
138
  logoOpacity,
@@ -101,32 +141,27 @@ const SplashScreenComponent = ({isLoaded,children , duration, delay,logoWidth,lo
101
141
  )}>
102
142
  {<LogoProgress />}
103
143
  </Animated.View>
104
- </View>
105
- )}
144
+ </View>}
106
145
  </View>
107
- </View>
108
- </Portal> : null}
109
- </>
146
+ )}
147
+ </View>
148
+ </View>
149
+ )
150
+ }
110
151
  }
111
152
 
112
-
113
- SplashScreenComponent.propTypes = {
153
+ AnimatedSplash.propTypes = {
114
154
  preload: PropTypes.bool,
115
155
  logoWidth: PropTypes.number,
116
156
  children: PropTypes.element,
117
157
  logoHeight: PropTypes.number,
118
158
  backgroundColor: PropTypes.string,
119
159
  isLoaded: PropTypes.bool.isRequired,
120
- disableBackgroundImage: PropTypes.bool,
121
- logoImage: PropTypes.oneOfType([
122
- PropTypes.string,
123
- PropTypes.number,
124
- PropTypes.object,
125
- ]),
160
+ translucent: PropTypes.bool,
161
+ customComponent: PropTypes.element,
126
162
  disableAppScale: PropTypes.bool,
127
163
  duration: PropTypes.number,
128
164
  delay: PropTypes.number,
129
165
  }
130
166
 
131
- SplashScreenComponent.displayName = "SplashScreenComponent";
132
- export default SplashScreenComponent;
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 { Animated, StatusBar, StyleSheet } from "react-native"
5
+ import {Animated, StyleSheet } from "react-native";
6
+ import View from "$components/View";
7
+ import {isNativeMobile} from "$platform";
8
+ import {defaultDecimal} from "$utils";
9
+ import {LogoProgress} from "$components/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
- 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";
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
- 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,
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 (isLoaded) {
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
- const {
60
- logoImage,
68
+ let {
61
69
  logoWidth,
62
70
  logoHeight,
63
71
  backgroundColor,
64
- customComponent,
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,9 +124,9 @@ class AnimatedSplash extends React.Component {
113
124
  },
114
125
  ],
115
126
  }
116
- const testID = defaultStr(testID,"RN_MainSplashScreen")
127
+
117
128
  return (
118
- <View testID={testID} style={[styles.container]}>
129
+ <View style={[styles.container]}>
119
130
  {!animationDone && <View style={StyleSheet.absoluteFill} />}
120
131
  <View style={styles.containerGlue}>
121
132
  {!animationDone && (
@@ -123,23 +134,36 @@ class AnimatedSplash extends React.Component {
123
134
  style={_staticBackground(logoOpacity, backgroundColor)}
124
135
  />
125
136
  )}
126
- <Animated.View style={[!disableAppScale && appScale, opacityClearToVisible, styles.flex]}>
137
+ {(animationDone || isNative) && <Component style={[!disableAppScale && appScale, opacityClearToVisible, styles.flex]}>
127
138
  {this.renderChildren()}
128
- </Animated.View>
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
+ )}
129
154
  {!animationDone && (
130
155
  <View style={[StyleSheet.absoluteFill, styles.logoStyle]}>
131
- {<View testID={testID+"_LogoContainer"} style={[StyleSheet.absoluteFill,{backgroundColor}, styles.logoStyle]}>
132
- <Animated.View
133
- testID={testID+"_Logo"}
134
- style={_dynamicCustomComponentStyle(
135
- logoScale,
136
- logoOpacity,
137
- logoWidth,
138
- logoHeight
139
- )}>
140
- {<LogoProgress />}
141
- </Animated.View>
142
- </View>}
156
+ {(
157
+ <Animated.View
158
+ style={_dynamicCustomComponentStyle(
159
+ logoScale,
160
+ logoOpacity,
161
+ logoWidth,
162
+ logoHeight
163
+ )}>
164
+ {<LogoProgress/>}
165
+ </Animated.View>
166
+ )}
143
167
  </View>
144
168
  )}
145
169
  </View>
@@ -155,8 +179,12 @@ AnimatedSplash.propTypes = {
155
179
  logoHeight: PropTypes.number,
156
180
  backgroundColor: PropTypes.string,
157
181
  isLoaded: PropTypes.bool.isRequired,
158
- translucent: PropTypes.bool,
159
- customComponent: PropTypes.element,
182
+ disableBackgroundImage: PropTypes.bool,
183
+ logoImage: PropTypes.oneOfType([
184
+ PropTypes.string,
185
+ PropTypes.number,
186
+ PropTypes.object,
187
+ ]),
160
188
  disableAppScale: PropTypes.bool,
161
189
  duration: PropTypes.number,
162
190
  delay: PropTypes.number,
@@ -0,0 +1,132 @@
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;