Skip to content

Instantly share code, notes, and snippets.

@ydatech
Created March 28, 2020 23:48
Show Gist options
  • Select an option

  • Save ydatech/24c9a7ea1e0ad36630554acf45481b1b to your computer and use it in GitHub Desktop.

Select an option

Save ydatech/24c9a7ea1e0ad36630554acf45481b1b to your computer and use it in GitHub Desktop.
import React, {useEffect, useState} from 'react';
import {
View,
Text,
Image,
ProgressBarAndroid,
StyleSheet,
Dimensions,
StatusBar,
} from 'react-native';
import { useNavigation } from '@react-navigation/native';
const MAIN_LOGO = '../../assets/img/MAIN_LOGO.png';
const SCREEN_HEIGHT = Dimensions.get('window').height;
const SCREEN_WIDTH = Dimensions.get('window').width;
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#292826',
},
logo: {
marginTop: SCREEN_HEIGHT * 0.35,
height: SCREEN_WIDTH * 0.5,
width: SCREEN_WIDTH * 0.9,
resizeMode: 'stretch',
marginBottom: -40,
},
footer: {
flex: 1,
alignItems: 'center',
justifyContent: 'flex-end',
marginBottom: 36,
},
footText: {
marginTop: 5,
color: '#FFF',
},
});
export default function SplashScreen(){
const navigation = useNavigation();
const [progressValue, setProgressValue] = useState(0.0);
useEffect(() => {
const progressInterval = setInterval(() => {
setProgressValue(progressValue => progressValue + 0.05);
}, 100);
return () => {
if (progressInterval) {
clearInterval(progressInterval);
}
};
}, []);
useEffect(() => {
if (progressValue > 1) {
navigation.navigate('Auth');
}
}, [progressValue,navigation]);
return (
<>
<StatusBar backgroundColor="#292826" barStyle="light-content" />
<View style={styles.container}>
<Image source={require(MAIN_LOGO)} style={styles.logo} />
<ProgressBarAndroid
width={SCREEN_WIDTH * 0.75}
styleAttr="Horizontal"
progress={this.state.progressValue}
indeterminate={false}
color="#FFF"
/>
<View style={styles.footer}>
<Text style={styles.footText}>@2020 Copyright.</Text>
<Text style={styles.footText}>
Powered by Indonesia Raya.
</Text>
</View>
</View>
</>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment