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 { View, Text, Dimensions, StyleSheet, TouchableOpacity } from 'react-native'; | |
import { loremIpsum } from './contants'; | |
const { width, height } = Dimensions.get('window'); | |
const AwesomeComponent = () => | |
<View style={styles.container}> | |
<View style={styles.box}> | |
<Text style={styles.title}>Awesome Blog Post Page</Text> | |
<Text style={styles.text}>{loremIpsum}</Text> |
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 { View, Text, Dimensions, StyleSheet, TouchableOpacity } from 'react-native'; | |
import { loremIpsum } from './contants'; | |
const { width, height } = Dimensions.get('window'); | |
const AwesomeComponent = () => | |
<View style={styles.container}> | |
<View style={styles.box}> | |
<Text style={styles.title}>Awesome Blog Post Page</Text> | |
<Text style={styles.text}>{loremIpsum}</Text> |
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 { View, Text, Dimensions, StyleSheet, TouchableOpacity } from 'react-native'; | |
import { loremIpsum } from './contants'; | |
const { width, height } = Dimensions.get('window'); | |
const AwesomeComponent = () => | |
<View style={styles.container}> | |
<View style={styles.box}> | |
<Text style={styles.title}>Awesome Blog Post Page</Text> | |
<Text style={styles.text}>{loremIpsum}</Text> |
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
const styles = StyleSheet.create({ | |
container: { | |
width: width, | |
height: height, | |
backgroundColor: '#E0E0E0', | |
alignItems: 'center', | |
justifyContent: 'center', | |
}, | |
box: { | |
width: 300, |
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
const FlexExample = () => | |
<View style={[styles.container, {flex: 1}]}> | |
<View style={{flex: 16}}/> | |
<View style={{flexDirection: 'row', flex: 68}}> | |
<View style={{flex: 1}}/> | |
<View style={[styles.box, {flex: 8}]}> | |
<Text style={styles.title}>Awesome Blog Post Page</Text> | |
<Text style={styles.text}>{loremIpsum}</Text> | |
<View style={styles.buttonsContainer}> | |
<TouchableOpacity style={styles.button}> |
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 {vw, vh} from 'react-native-viewport-units'; | |
const styles = StyleSheet.create({ | |
container: { | |
... | |
}, | |
box: { | |
width: 80 * vw, | |
height: 67 * vh, | |
padding: 2.6 * vw, |
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 { Dimensions } from 'react-native'; | |
const { width, height } = Dimensions.get('window'); | |
//Guideline sizes are based on standard ~5" screen mobile device | |
const guidelineBaseWidth = 350; | |
const guidelineBaseHeight = 680; | |
const scale = size => width / guidelineBaseWidth * size; | |
const verticalScale = size => height / guidelineBaseHeight * size; | |
const moderateScale = (size, factor = 0.5) => size + ( scale(size) - size ) * factor; |
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 { scale, moderateScale, verticalScale} from './scaling'; | |
const styles = StyleSheet.create({ | |
... | |
box: { | |
width: moderateScale(300), | |
height: verticalScale(450), | |
padding: scale(10), | |
... | |
}, |
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
//Class | |
class CounterButton extends Component { | |
constructor() { | |
super(); | |
this.state = { | |
count: 0 | |
} | |
} | |
render() { | |
return <button onClick={() => this.setState({ count: this.state.count + 1 })}> |
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
//Class | |
componentDidMount() { | |
console.log('I just mounted!'); | |
} | |
//Hooks | |
useEffect(() => { | |
console.log('I just mounted!'); | |
}, []) |
OlderNewer