Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. import React from 'react';
  2. import { Text, View, TextInput, Button } from 'react-native';
  3.  
  4. export default class App extends React.Component {
  5. constructor(props) {
  6. super(props)
  7. this.state = {
  8. panjang: 0,
  9. lebar: 0,
  10. tinggi: 0,
  11. volume: 0
  12. };
  13. }
  14.  
  15.  
  16. render() {
  17. return (
  18. <View style = {{flex:1,backgroundColor:'#bbdefb'}}>
  19. <View style={{backgroundColor:'#2196f3'}}>
  20. <Text style = {{padding: 10, fontSize: 20, color: 'white', textAlign:'center'}} >
  21. Menghitung Volume Balok
  22. </Text>
  23. </View>
  24.  
  25. <View style={{margin:20,padding: 10, backgroundColor:'#e3f2fd'}}>
  26. <TextInput style = {{height: 40}}
  27. placeholder="Masukkan Panjang"
  28. onChangeText={
  29. (panjang)=>this.setState({panjang})
  30. }
  31. keyboardType = 'numeric'
  32. />
  33. <TextInput style = {{height: 40}}
  34. placeholder="Masukkan Lebar"
  35. onChangeText={(lebar)=>this.setState({lebar})}
  36. keyboardType = 'numeric'
  37. />
  38.  
  39. <TextInput style = {{height: 40}}
  40. placeholder="Masukkan Tinggi"
  41. onChangeText={(tinggi)=>this.setState({tinggi})}
  42. keyboardType='numeric'
  43. />
  44.  
  45. <Button
  46. onPress={() => {
  47. this.setState({ volume: this.state.panjang * this.state.lebar * this.state.tinggi });
  48. }
  49. }
  50. title="Hitung"
  51. accessibilityLabel="Klik untuk menghitung"
  52. />
  53. </View>
  54.  
  55. <View style={{margin:20, backgroundColor:'#90caf9'}}>
  56. <Text style = {{padding: 10, fontSize: 20}} >
  57. Panjang = {this.state.panjang} {"\n"}
  58. Lebar = {this.state.lebar} {"\n"}
  59. Tinggi = {this.state.tinggi} {"\n"}
  60. Volume = {this.state.volume} {"\n"}
  61. </Text>
  62. </View>
  63.  
  64. </View>
  65.  
  66. );
  67. }
  68.  
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement