Last active
January 30, 2019 02:27
-
-
Save yildiz/2e68ef87757340cf6315ab6459db559e to your computer and use it in GitHub Desktop.
Kırmızı top sayacı
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, { Component } from 'react'; | |
import { StyleSheet, Text, View, TouchableOpacity, Button } from 'react-native'; | |
export default class App extends Component { | |
constructor(props) { | |
super(props) | |
this.state = { | |
sayi: 0 | |
} | |
} | |
sayiArtir() { | |
this.setState({ | |
sayi: this.state.sayi+1 | |
}); | |
} | |
sifirla() { | |
this.setState({ sayi: 0 }); | |
} | |
render() { | |
return ( | |
<View style={styles.kapsayici}> | |
<TouchableOpacity onPress={this.sayiArtir.bind(this)}> | |
<View style={styles.kirmiziTop}> | |
<Text style={styles.sayiStili}>{this.state.sayi}</Text> | |
</View> | |
</TouchableOpacity> | |
<Button title="Sıfırla" onPress={this.sifirla.bind(this)} /> | |
</View> | |
); | |
} | |
} | |
const styles = StyleSheet.create({ | |
kapsayici: { | |
flex: 1, justifyContent: "center", alignItems: 'center' | |
}, | |
kirmiziTop: { | |
backgroundColor: "red", height: 125, width: 125, borderRadius: 100, | |
// kırmızı top içindeki componentleri ortaladık | |
justifyContent: 'center', | |
alignItems: 'center', | |
marginBottom: 10, // marginBottum'u sıfırlama butonu ile kırmızı topun arasına mesafe koymak için verdik. | |
}, | |
sayiStili: { | |
color: "white", | |
fontSize: 25 | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment