-
-
Save DominikDanielewicz/04f9ec3a387ed3aecea8e30dfd24bfc8 to your computer and use it in GitHub Desktop.
Video background article code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import {SafeAreaView, StatusBar, StyleSheet, Text, View} from 'react-native'; | |
import {VideoBackground} from './src/components/VideoBackground/VideoBackground'; | |
import {Button} from './src/components/Button/Button'; | |
const background = require('./src/assets/cars.mp4'); | |
const App = () => { | |
return ( | |
<> | |
<VideoBackground source={background} /> | |
<View style={styles.overlay} /> | |
<SafeAreaView style={styles.contentWrapper}> | |
<StatusBar | |
backgroundColor="transparent" | |
translucent={true} | |
hidden={false} | |
/> | |
<View style={styles.contentContainer}> | |
<Text style={styles.title}>Welcome</Text> | |
<Text style={styles.subtitle}>Start your journey now</Text> | |
<View style={styles.buttonsContainer}> | |
<View style={styles.buttonWrapper}> | |
<Button | |
onPress={() => console.log('Sign in')} | |
style={styles.button}> | |
Sign in | |
</Button> | |
</View> | |
<View style={styles.buttonWrapper}> | |
<Button | |
onPress={() => console.log('Sign up')} | |
style={styles.button}> | |
Sign up | |
</Button> | |
</View> | |
</View> | |
</View> | |
</SafeAreaView> | |
</> | |
); | |
}; | |
const styles = StyleSheet.create({ | |
title: { | |
fontSize: 40, | |
fontWeight: '700', | |
color: '#fff', | |
textAlign: 'center', | |
marginBottom: 5, | |
}, | |
subtitle: { | |
fontSize: 20, | |
fontWeight: '500', | |
color: '#fff', | |
textAlign: 'center', | |
marginBottom: 50, | |
}, | |
contentWrapper: { | |
flex: 1, | |
}, | |
contentContainer: { | |
flex: 1, | |
justifyContent: 'center', | |
paddingHorizontal: 40, | |
}, | |
button: { | |
marginTop: 20, | |
}, | |
buttonsContainer: { | |
alignItems: 'center', | |
justifyContent: 'center', | |
maxWidth: 400, | |
alignSelf: 'center', | |
}, | |
buttonWrapper: { | |
minWidth: '100%', | |
}, | |
overlay: { | |
position: 'absolute', | |
top: 0, | |
right: 0, | |
bottom: 0, | |
left: 0, | |
backgroundColor: 'rgba(0, 0, 0, 0.2)', | |
}, | |
}); | |
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import {StyleSheet} from 'react-native'; | |
import Video from 'react-native-video'; | |
export const VideoBackground = ({source}) => { | |
return ( | |
<Video | |
resizeMode="cover" | |
muted={true} | |
repeat | |
source={source} | |
style={styles.backgroundVideo} | |
/> | |
); | |
}; | |
const styles = StyleSheet.create({ | |
backgroundVideo: { | |
position: 'absolute', | |
top: 0, | |
left: 0, | |
bottom: 0, | |
right: 0, | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment