Skip to content

Instantly share code, notes, and snippets.

@LuffyAnshul
Last active February 5, 2021 07:51
Show Gist options
  • Select an option

  • Save LuffyAnshul/e952f3d501046eb86217e91535725999 to your computer and use it in GitHub Desktop.

Select an option

Save LuffyAnshul/e952f3d501046eb86217e91535725999 to your computer and use it in GitHub Desktop.
Civil App Splash Screen
import React, {useState, useEffect} from 'react';
import {
ActivityIndicator,
View,
StyleSheet,
Image
} from 'react-native';
import AsyncStorage from '@react-native-async-storage/async-storage';
const SplashScreen = ({ navigation }) => {
//State for ActivityIndicator animation
const [animating, setAnimating] = useState(true);
useEffect(() => {
setTimeout(() => {
setAnimating(false);
//Check if user_id is set or not
//If not then send for Authentication
//else send to Home Screen
AsyncStorage.getItem('isAuth').then((value) => {
navigation.replace(
value === null || value === 'false' ? 'Auth' : 'MaterialBottomNavigation'
)
});
}, 500);
}, []);
return (
<View style={styles.container}>
<Image
source={require('../assets/logo.png')}
style={{width: '90%', resizeMode: 'contain', margin: 30}}
/>
<ActivityIndicator
animating={animating}
color="#FFFFFF"
size="large"
style={styles.activityIndicator}
/>
</View>
);
};
export default SplashScreen;
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#fff',
},
activityIndicator: {
alignItems: 'center',
height: 80,
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment