Menerapkan Container sebagai komponen dan menerapkan flex pada Container
This commit is contained in:
parent
f0c42f6378
commit
95670084f7
15
components/Container.js
Normal file
15
components/Container.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import { View, StyleSheet } from 'react-native';
|
||||||
|
|
||||||
|
const Container = ({ children, style }) => {
|
||||||
|
return <View style={[styles.container, style]}>{children}</View>;
|
||||||
|
};
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
flex:1,
|
||||||
|
flexDirection: 'column',
|
||||||
|
padding: 20,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default Container;
|
@ -1,22 +1,28 @@
|
|||||||
import { StatusBar } from 'expo-status-bar';
|
|
||||||
import { StyleSheet, Text, View } from 'react-native';
|
import { StyleSheet, Text, View } from 'react-native';
|
||||||
|
import Container from '../components/Container';
|
||||||
|
|
||||||
const ScreenHome = ({ navigation }) => {
|
const ScreenHome = ({ navigation }) => {
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<Container>
|
||||||
<Text>Ini halaman Home</Text>
|
<View style={styles.header}>
|
||||||
<StatusBar style="auto" />
|
<Text>Ini Header</Text>
|
||||||
</View>
|
</View>
|
||||||
|
<View style={styles.main}>
|
||||||
|
<Text>Ini Main Content</Text>
|
||||||
|
</View>
|
||||||
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
header: {
|
||||||
flex: 1,
|
flex:1,
|
||||||
backgroundColor: '#fff',
|
backgroundColor:"#FFDDDD"
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
},
|
},
|
||||||
|
main: {
|
||||||
|
flex:3,
|
||||||
|
backgroundColor:"#DDFFDD"
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default ScreenHome;
|
export default ScreenHome;
|
Loading…
Reference in New Issue
Block a user