Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.23 KB | None | 0 0
  1. import React from 'react';
  2. import { Text, View, TextInput, Button, StyleSheet } from 'react-native';
  3.  
  4. export default class Siak extends React.Component {
  5.  
  6. constructor(props) {
  7. super(props)
  8. this.state = {
  9. Tugas1:0,
  10. Tugas2:0,
  11. NA:0,
  12. Predikat:'',
  13. };
  14. }
  15. render() {
  16. return (
  17. <View style={styles.containerMain}>
  18. <View style={styles.header}>
  19. <Text style={styles.text}>Siak</Text>
  20. </View>
  21.  
  22.  
  23. <View style={styles.slider}>
  24. <View style={styles.masuk}>
  25. <Text style={styles.text2}>Tugas 1 :</Text>
  26. <TextInput style = {{height: 40, backgroundColor:'white', margin:20,padding: 10}}
  27. placeholder="Masukkan Nilai Tugas1"
  28. onChangeText={
  29. (Tugas1)=>this.setState({Tugas1})
  30. }
  31. keyboardType = 'numeric'
  32. />
  33. </View>
  34.  
  35. <View style={styles.masuk}>
  36. <Text style={styles.text2}>Tugas 2 :</Text>
  37. <TextInput style = {{height: 40, backgroundColor:'white', margin:20,padding: 10}}
  38. placeholder="Masukkan Nilai Tugas2"
  39. onChangeText={
  40. (Tugas2)=>this.setState({Tugas2})
  41. }
  42. keyboardType = 'numeric'
  43. />
  44.  
  45. </View>
  46.  
  47. <View style={styles.vbutton}>
  48. <Button
  49. onPress={() => {
  50. this.setState({NA:0.5* this.state.Tugas1 +0.5* this.state.Tugas2 });
  51.  
  52. }
  53. title="Hitung"
  54. accessibilityLabel="Klik untuk menghitung"
  55. />
  56. </View>
  57.  
  58.  
  59. </View>
  60.  
  61.  
  62. <View style={styles.box3}>
  63.  
  64.  
  65. <Text style={styles.text2}>Nilai Akhir : {this.state.NA} </Text>
  66. <Text style={styles.text2}>Predikat : {this.state.Predikat} </Text>
  67.  
  68.  
  69. </View>
  70. </View>
  71. );
  72. }
  73. }
  74.  
  75. const styles = StyleSheet.create({
  76. containerMain: {
  77. flex: 1,
  78. flexDirection: 'column',
  79.  
  80. },
  81. header:{
  82. flex: 1,
  83. backgroundColor: 'blue',
  84. justifyContent: 'center',
  85. alignItems: 'center',
  86.  
  87. },
  88.  
  89. slider:{
  90. flex: 4,
  91. backgroundColor: '#61cdf4',
  92. flexDirection: 'column',
  93. justifyContent : 'center',
  94. },
  95.  
  96. masuk:{
  97. flex : 1,
  98. flexDirection: 'row',
  99.  
  100. },
  101.  
  102. box3: {
  103. flex: 3,
  104. backgroundColor: 'powderblue',
  105. justifyContent: 'center',
  106. alignItems: 'center',
  107. },
  108.  
  109. box: {
  110. backgroundColor: 'white',
  111. width: 60,
  112. height: 60,
  113. borderRadius: 10,
  114. justifyContent: 'center',
  115. alignItems: 'center',
  116. },
  117.  
  118. text: {
  119. fontSize: 25,
  120. color: 'white',
  121. },
  122.  
  123. text2: {
  124. fontSize: 20,
  125. color: 'black',
  126. fontWeight: 'bold',
  127. margin:20,
  128. padding: 10
  129. },
  130.  
  131. tinggi:{
  132. height:20,
  133. },
  134.  
  135. vbutton:{
  136. flex:1,
  137. justifyContent: 'center',
  138. padding: 20,
  139.  
  140. },
  141.  
  142. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement