| 
									
										
										
										
											2023-04-21 06:23:36 +00:00
										 |  |  | /* eslint-disable react-native/no-inline-styles */ | 
					
						
							| 
									
										
										
										
											2022-05-16 15:01:45 +00:00
										 |  |  | import React, {Component} from 'react'; | 
					
						
							| 
									
										
										
										
											2023-04-21 06:23:36 +00:00
										 |  |  | import { | 
					
						
							|  |  |  |   Image, | 
					
						
							|  |  |  |   PermissionsAndroid, | 
					
						
							|  |  |  |   StatusBar, | 
					
						
							|  |  |  |   StyleSheet, | 
					
						
							|  |  |  |   View, | 
					
						
							|  |  |  | } from 'react-native'; | 
					
						
							|  |  |  | import { | 
					
						
							|  |  |  |   responsiveFontSize, | 
					
						
							|  |  |  |   responsiveHeight, | 
					
						
							|  |  |  |   responsiveWidth, | 
					
						
							|  |  |  | } from 'react-native-responsive-dimensions'; | 
					
						
							|  |  |  | import I18n from 'react-native-i18n'; | 
					
						
							|  |  |  | import { | 
					
						
							|  |  |  |   getPasObject, | 
					
						
							|  |  |  |   getPubActiveObject, | 
					
						
							|  |  |  |   readUser, | 
					
						
							|  |  |  | } from '../../webservice/AuthApi'; | 
					
						
							|  |  |  | import Configuration from '../../webservice/persistences/Configuration'; | 
					
						
							|  |  |  | import '../ads/InterticielAds'; | 
					
						
							| 
									
										
										
										
											2019-06-16 13:09:54 +00:00
										 |  |  | import * as Animatable from 'react-native-animatable'; | 
					
						
							|  |  |  | import DeviceInfo from 'react-native-device-info'; | 
					
						
							| 
									
										
										
										
											2023-04-21 06:23:36 +00:00
										 |  |  | import {bindActionCreators} from 'redux'; | 
					
						
							|  |  |  | import getAuthApiKey from '../../webservice/AuthKeyApi'; | 
					
						
							|  |  |  | import {connect} from 'react-redux'; | 
					
						
							| 
									
										
										
										
											2022-05-16 15:01:45 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | const theme = require('./../../utils/theme.json'); | 
					
						
							|  |  |  | const route = require('./../../route.json'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class SplashScreen extends Component { | 
					
						
							| 
									
										
										
										
											2023-04-21 06:23:36 +00:00
										 |  |  |   static navigatorStyle = { | 
					
						
							|  |  |  |     drawUnderNavBar: true, | 
					
						
							|  |  |  |     navBarHidden: true, | 
					
						
							|  |  |  |     drawUnderStatusBar: false, | 
					
						
							|  |  |  |     statusBarHidden: false, | 
					
						
							|  |  |  |     statusBarTextColorScheme: 'light', | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  |   static options(passProps) { | 
					
						
							|  |  |  |     return { | 
					
						
							|  |  |  |       statusBar: { | 
					
						
							|  |  |  |         visible: false, | 
					
						
							|  |  |  |         style: 'light' | 'dark', | 
					
						
							|  |  |  |         drawBehind: true, | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       topBar: { | 
					
						
							|  |  |  |         title: { | 
					
						
							|  |  |  |           text: 'My Screen', | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         drawBehind: true, | 
					
						
							|  |  |  |         visible: false, | 
					
						
							|  |  |  |         animate: false, | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2021-10-26 18:19:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-21 06:23:36 +00:00
										 |  |  |   //
 | 
					
						
							|  |  |  |   constructor(props) { | 
					
						
							|  |  |  |     super(props); | 
					
						
							|  |  |  |     this.state = {}; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   workUserResult(result) { | 
					
						
							|  |  |  |     console.log('SPLASHSCREEN PROPS', this.props); | 
					
						
							|  |  |  |     if (typeof this.props.navigation.state.params !== 'undefined') { | 
					
						
							|  |  |  |       if (result === null || result === undefined) { | 
					
						
							|  |  |  |         this.props.navigation.navigate('Auth'); | 
					
						
							|  |  |  |       } else { | 
					
						
							|  |  |  |         switch (this.props.navigation.state.params.routeName) { | 
					
						
							|  |  |  |           case 'historyItemDetails': | 
					
						
							|  |  |  |             this.props.navigation.navigate( | 
					
						
							|  |  |  |               this.props.navigation.state.params.routeName, | 
					
						
							|  |  |  |               { | 
					
						
							|  |  |  |                 item: this.props.navigation.state.params.params, | 
					
						
							|  |  |  |               }, | 
					
						
							|  |  |  |             ); | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
										
										
											2021-10-26 18:19:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-21 06:23:36 +00:00
										 |  |  |           default: | 
					
						
							|  |  |  |             this.props.navigation.navigate( | 
					
						
							|  |  |  |               this.props.navigation.state.params.routeName, | 
					
						
							|  |  |  |               { | 
					
						
							|  |  |  |                 id: this.props.navigation.state.params.params.id, | 
					
						
							|  |  |  |               }, | 
					
						
							|  |  |  |             ); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       var way = ''; | 
					
						
							|  |  |  |       var way2 = ''; | 
					
						
							|  |  |  |       if (result === null || result === undefined) { | 
					
						
							|  |  |  |         way = 'Auth'; | 
					
						
							|  |  |  |         way2 = route.first; | 
					
						
							|  |  |  |       } else { | 
					
						
							|  |  |  |         if (!result.category) { | 
					
						
							|  |  |  |           way = 'App'; | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |           switch (result.category) { | 
					
						
							|  |  |  |             case 'geolocated': | 
					
						
							|  |  |  |               way = 'AgentApp'; | 
					
						
							|  |  |  |               break; | 
					
						
							|  |  |  |             case 'super': | 
					
						
							|  |  |  |               way = 'adminApp'; | 
					
						
							|  |  |  |               break; | 
					
						
							|  |  |  |             default: | 
					
						
							|  |  |  |               way = 'supAdminApp'; | 
					
						
							| 
									
										
										
										
											2021-10-26 18:19:13 +00:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2023-04-21 06:23:36 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |         way2 = route.login; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       this.props.navigation.navigate(way); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-10-26 18:19:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-21 06:23:36 +00:00
										 |  |  |     /*  Navigation.setStackRoot(route.stackRoot, | 
					
						
							| 
									
										
										
										
											2021-10-26 18:19:13 +00:00
										 |  |  |                                 {        component: { | 
					
						
							|  |  |  |                                             name: way, | 
					
						
							|  |  |  |                                         } | 
					
						
							| 
									
										
										
										
											2023-04-21 06:23:36 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-20 18:28:22 +00:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2021-10-26 18:19:13 +00:00
										 |  |  |             ); | 
					
						
							|  |  |  |            Navigation.showOverlay({ | 
					
						
							|  |  |  |                 component: { | 
					
						
							|  |  |  |                     name: route.intersticielAds, | 
					
						
							|  |  |  |                     id:"interticiel", | 
					
						
							|  |  |  |                     options: { | 
					
						
							|  |  |  |                         overlay: { | 
					
						
							|  |  |  |                             interceptTouchOutside: false | 
					
						
							|  |  |  |                         } | 
					
						
							| 
									
										
										
										
											2020-03-20 18:28:22 +00:00
										 |  |  |                     } | 
					
						
							| 
									
										
										
										
											2021-10-26 18:19:13 +00:00
										 |  |  |                 } | 
					
						
							|  |  |  |             });*/ | 
					
						
							| 
									
										
										
										
											2023-04-21 06:23:36 +00:00
										 |  |  |   } | 
					
						
							|  |  |  |   componentDidMount() { | 
					
						
							|  |  |  |     try { | 
					
						
							|  |  |  |       this.requestCameraPermission(); | 
					
						
							|  |  |  |     } catch (e) { | 
					
						
							|  |  |  |       console.log(e); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     this.config = new Configuration(); | 
					
						
							|  |  |  |     this.retrieveAndroidInformation(); | 
					
						
							|  |  |  |     setTimeout(() => this.bounce(), 500); | 
					
						
							|  |  |  |     this.bounce(); | 
					
						
							|  |  |  |     readUser().then(async user => { | 
					
						
							|  |  |  |       if (user) { | 
					
						
							|  |  |  |         if (user !== undefined) { | 
					
						
							|  |  |  |           if (user.phone !== undefined) { | 
					
						
							|  |  |  |             this.props.getAuthApiKey(user.phone); | 
					
						
							| 
									
										
										
										
											2021-10-26 18:19:13 +00:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2023-04-21 06:23:36 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   async requestCameraPermission() { | 
					
						
							|  |  |  |     try { | 
					
						
							|  |  |  |       const granted = await PermissionsAndroid.request( | 
					
						
							|  |  |  |         PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           title: 'Cool Photo App Camera Permission', | 
					
						
							|  |  |  |           message: | 
					
						
							|  |  |  |             'Cool Photo App needs access to your camera ' + | 
					
						
							|  |  |  |             'so you can take awesome pictures.', | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |       if (granted === PermissionsAndroid.RESULTS.GRANTED) { | 
					
						
							|  |  |  |       } else { | 
					
						
							|  |  |  |         console.log('try get information else'); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } catch (err) { | 
					
						
							|  |  |  |       console.log('try get information error'); | 
					
						
							|  |  |  |       console.log(err); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   handleViewRef = ref => (this.view = ref); | 
					
						
							| 
									
										
										
										
											2021-10-26 18:19:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-21 06:23:36 +00:00
										 |  |  |   bounce = () => this.view.transition({translateX: 0}, {translateX: 700}, 5000); | 
					
						
							| 
									
										
										
										
											2021-10-26 18:19:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-21 06:23:36 +00:00
										 |  |  |   render() { | 
					
						
							|  |  |  |     return ( | 
					
						
							|  |  |  |       <View style={styles.container}> | 
					
						
							|  |  |  |         <StatusBar translucent={true} /> | 
					
						
							|  |  |  |         <Image | 
					
						
							|  |  |  |           style={styles.logo} | 
					
						
							|  |  |  |           source={require('./../../datas/img/icon3up.png')} | 
					
						
							|  |  |  |         /> | 
					
						
							|  |  |  |         <View style={{flexDirection: 'row'}}> | 
					
						
							|  |  |  |           <Image | 
					
						
							|  |  |  |             style={styles.logo} | 
					
						
							|  |  |  |             source={require('./../../datas/img/iconsub3.png')} | 
					
						
							|  |  |  |           /> | 
					
						
							|  |  |  |           <Animatable.View | 
					
						
							|  |  |  |             style={{ | 
					
						
							|  |  |  |               width: responsiveWidth(90), | 
					
						
							|  |  |  |               height: 92, | 
					
						
							|  |  |  |               backgroundColor: theme.primary, | 
					
						
							|  |  |  |               position: 'absolute', | 
					
						
							|  |  |  |               zIndex: 100, | 
					
						
							|  |  |  |             }} | 
					
						
							|  |  |  |             ref={this.handleViewRef} | 
					
						
							|  |  |  |           /> | 
					
						
							|  |  |  |         </View> | 
					
						
							|  |  |  |       </View> | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2021-10-26 18:19:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-21 06:23:36 +00:00
										 |  |  |   retreiveIosInformation() { | 
					
						
							|  |  |  |     readUser() | 
					
						
							|  |  |  |       .then(result => { | 
					
						
							|  |  |  |         setTimeout(() => { | 
					
						
							|  |  |  |           this.workUserResult(result); | 
					
						
							|  |  |  |         }, 3000); | 
					
						
							|  |  |  |       }) | 
					
						
							|  |  |  |       .catch(e => { | 
					
						
							|  |  |  |         this.props.navigation.navigate('Auth'); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  |     return ''; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2021-10-26 18:19:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-21 06:23:36 +00:00
										 |  |  |   retrieveAndroidInformation() { | 
					
						
							|  |  |  |     getPasObject().then(data => { | 
					
						
							|  |  |  |       console.warn(data); | 
					
						
							|  |  |  |       this.config.setCurrentPas(data); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2021-10-26 18:19:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-21 06:23:36 +00:00
										 |  |  |     this.config | 
					
						
							|  |  |  |       ._getData() | 
					
						
							|  |  |  |       .then(lang => { | 
					
						
							|  |  |  |         if (lang) { | 
					
						
							|  |  |  |           I18n.locale = lang; | 
					
						
							|  |  |  |           readUser().then(result => { | 
					
						
							|  |  |  |             console.warn(result); | 
					
						
							|  |  |  |             if (result) { | 
					
						
							|  |  |  |               getPubActiveObject(result.country_id).then(data => { | 
					
						
							|  |  |  |                 console.warn(data); | 
					
						
							|  |  |  |                 this.config.setPubActive(data); | 
					
						
							|  |  |  |               }); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             setTimeout(() => { | 
					
						
							|  |  |  |               this.workUserResult(result); | 
					
						
							|  |  |  |             }, 3000); | 
					
						
							| 
									
										
										
										
											2021-10-26 18:19:13 +00:00
										 |  |  |           }); | 
					
						
							| 
									
										
										
										
											2023-04-21 06:23:36 +00:00
										 |  |  |         } else { | 
					
						
							|  |  |  |           const code = DeviceInfo.getDeviceLocale(); | 
					
						
							|  |  |  |           console.warn(code); | 
					
						
							|  |  |  |           I18n.locale = code.toLowerCase(); | 
					
						
							|  |  |  |           readUser() | 
					
						
							|  |  |  |             .then(result => { | 
					
						
							|  |  |  |               console.warn(result); | 
					
						
							|  |  |  |               if (result) { | 
					
						
							|  |  |  |                 getPubActiveObject(result.country_id).then(data => { | 
					
						
							|  |  |  |                   console.warn(data); | 
					
						
							|  |  |  |                   this.config.setPubActive(data); | 
					
						
							|  |  |  |                 }); | 
					
						
							|  |  |  |               } | 
					
						
							|  |  |  |               setTimeout(() => { | 
					
						
							|  |  |  |                 this.workUserResult(result); | 
					
						
							|  |  |  |               }, 3000); | 
					
						
							|  |  |  |             }) | 
					
						
							|  |  |  |             .catch(e => { | 
					
						
							|  |  |  |               this.setPubActive(data); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       }) | 
					
						
							|  |  |  |       .catch(e => { | 
					
						
							|  |  |  |         console.warn(e.message); | 
					
						
							|  |  |  |         DeviceInfo.getDeviceLocale().then(code => { | 
					
						
							|  |  |  |           console.warn(code); | 
					
						
							| 
									
										
										
										
											2021-10-26 18:19:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-21 06:23:36 +00:00
										 |  |  |           I18n.locale = code.toLowerCase(); | 
					
						
							|  |  |  |           readUser() | 
					
						
							|  |  |  |             .then(result => { | 
					
						
							|  |  |  |               setTimeout(() => { | 
					
						
							|  |  |  |                 this.workUserResult(result); | 
					
						
							|  |  |  |               }, 3000); | 
					
						
							|  |  |  |             }) | 
					
						
							|  |  |  |             .catch(e => { | 
					
						
							|  |  |  |               this.props.navigation.navigate('Auth'); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |       }); | 
					
						
							| 
									
										
										
										
											2021-10-26 18:19:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-21 06:23:36 +00:00
										 |  |  |     return ''; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-06-16 13:09:54 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2022-05-16 15:01:45 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | const mapStateToProps = state => ({ | 
					
						
							| 
									
										
										
										
											2023-04-21 06:23:36 +00:00
										 |  |  |   loading: state.authKeyReducer.loading, | 
					
						
							|  |  |  |   authKey: state.authKeyReducer.authKey, | 
					
						
							|  |  |  |   error: state.authKeyReducer.error, | 
					
						
							| 
									
										
										
										
											2022-05-16 15:01:45 +00:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-21 06:23:36 +00:00
										 |  |  | const mapDispatchToProps = dispatch => | 
					
						
							|  |  |  |   bindActionCreators( | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       getAuthApiKey, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     dispatch, | 
					
						
							|  |  |  |   ); | 
					
						
							| 
									
										
										
										
											2022-05-16 15:01:45 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | export default connect(mapStateToProps, mapDispatchToProps)(SplashScreen); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-20 18:28:22 +00:00
										 |  |  | const styles = StyleSheet.create({ | 
					
						
							| 
									
										
										
										
											2023-04-21 06:23:36 +00:00
										 |  |  |   container: { | 
					
						
							|  |  |  |     flex: 1, | 
					
						
							|  |  |  |     backgroundColor: theme.primary, | 
					
						
							|  |  |  |     justifyContent: 'center', | 
					
						
							|  |  |  |     alignItems: 'center', | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  |   logoContaner: { | 
					
						
							|  |  |  |     flexDirection: 'row', | 
					
						
							|  |  |  |     marginTop: responsiveHeight(20), | 
					
						
							|  |  |  |     justifyContent: 'center', | 
					
						
							|  |  |  |     alignItems: 'center', | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  |   logo: { | 
					
						
							|  |  |  |     width: responsiveWidth(90), | 
					
						
							|  |  |  |     resizeMode: 'contain', | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  |   lottie: { | 
					
						
							|  |  |  |     width: 48, | 
					
						
							|  |  |  |     height: 64, | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  |   title: { | 
					
						
							|  |  |  |     fontSize: responsiveFontSize(4), | 
					
						
							|  |  |  |     alignSelf: 'center', | 
					
						
							|  |  |  |     fontWeight: 'bold', | 
					
						
							|  |  |  |     color: 'white', | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  | }); |