Guest User

Untitled

a guest
Jan 16th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.18 KB | None | 0 0
  1. constructor(props){
  2. super(props);
  3. this.state = {
  4. APIUrl: '?????',
  5. provinceList: [],
  6. //subProvinsiList: []
  7. }
  8.  
  9. this.getProvinsiListData = this.getProvinsiListData.bind(this);
  10. }
  11.  
  12. //GET DATA PROVINSI
  13. getProvinsiListData(){
  14.  
  15. var temp = [];
  16. fetch( this.state.APIUrl + '/tracking/get/province' , {
  17. method: 'GET',
  18. headers: {
  19. Accept: "application/json",
  20. "Content-Type": "application/json"
  21. }
  22. })
  23. .then(response => response.json())
  24. .then(responseJSON => {
  25. var len = responseJSON.length;
  26. //responseJSON.data.map(data => ({ value: data })
  27. //console.log(len);
  28. if ( len > 0 ){
  29. for ( let i = 0; i < len; i++ ){
  30. var data = responseJSON[i];
  31. //console.log('masuk' + data.province);
  32. var joined = { value: data };
  33. console.log(data);
  34. temp.push(joined);
  35. }
  36. }
  37. //console.log('ini list provinsi=', JSON.stringify(temp));
  38. this.setState({
  39. provinceList: temp
  40. });
  41. console.log('testing' + this.state.provinceList);
  42. })
  43. .catch(error => {
  44. console.log(error);
  45. });
  46.  
  47. }
  48.  
  49.  
  50. //Header customize from react native navigator
  51. static navigationOptions = ({ navigation }) => {
  52. let headerTitle = 'Tambah Alamat';
  53. let headerTitleStyle={ color:'#fff', textAlign: 'center', fontSize:18 , flex:1, marginLeft:-50};
  54. let headerTintColor= '#fff';
  55. let headerStyle={ backgroundColor: '#3250E0' };
  56. let headerBackTitle= '';
  57.  
  58. return{ headerTitle, headerTitleStyle, headerStyle, headerTintColor, headerBackTitle }
  59. }
  60.  
  61.  
  62. //Get API Provinsi
  63. componentDidMount()
  64. {
  65. this.getProvinsiListData();
  66. }
  67.  
  68.  
  69.  
  70.  
  71. render(){
  72.  
  73. return(
  74. <View style={styles.container}>
  75. <KeyboardAvoidingView behavior="padding" enabled>
  76. <ScrollView>
  77. <View style={{marginVertical:10, marginHorizontal:10}}>
  78.  
  79. <View style={styles.jarak}>
  80. <Text style={{fontSize:14}}>Nama Lengkap</Text>
  81. <TextInput
  82. style={{height: 40, borderBottomColor: '#616161', borderBottomWidth: 2}}
  83. placeholder='Masukkan nama lengkap'
  84. />
  85. </View>
  86.  
  87. <View style={styles.jarak}>
  88. <Text style={{fontSize:14}}>Alamat</Text>
  89. <TextInput
  90. style={{height: 40, borderBottomColor: '#616161', borderBottomWidth: 2}}
  91. placeholder='Masukkan alamat lengkap'
  92. />
  93. </View>
  94.  
  95. <View style={styles.jarak}>
  96. <Text style={{fontSize:14}}>Provinsi</Text>
  97. <Dropdown
  98. baseColor='#616161'
  99. textColor='#616161'
  100. label='Pilih Provinsi'
  101. onChangeText={this.onChangeText}
  102. data={this.state.provinceList}
  103. />
  104. </View>
  105.  
  106. <View style={styles.jarak}>
  107. <Text style={{fontSize:14}}>Kota</Text>
  108. <TextInput
  109. style={{height: 40, borderBottomColor: '#616161', borderBottomWidth: 2}}
  110. placeholder='Pilih Kota'
  111. />
  112. </View>
  113.  
  114. <View style={styles.jarak}>
  115. <Text style={{fontSize:14}}>Kecamatan</Text>
  116. <TextInput
  117. style={{height: 40, borderBottomColor: '#616161', borderBottomWidth: 2}}
  118. placeholder='Pilih Kecamatan'
  119. />
  120. </View>
  121.  
  122. <View style={styles.jarak}>
  123. <Text style={{fontSize:14}}>Kode Pos</Text>
  124. <TextInput
  125. style={{height: 40, borderBottomColor: '#616161', borderBottomWidth: 2}}
  126. placeholder='Masukkan Kode Pos'
  127. />
  128. </View>
  129.  
  130. <View style={styles.jarak}>
  131. <Text style={{fontSize:14}}>No. Telp</Text>
  132. <TextInput
  133. style={{height: 40, borderBottomColor: '#616161', borderBottomWidth: 2}}
  134. placeholder='Masukkan No Telepon'
  135. />
  136. </View>
  137.  
  138. <View style={styles.jarak}>
  139. <Text style={{fontSize:14}}>Status</Text>
  140. <TextInput
  141. style={{height: 40, borderBottomColor: '#616161', borderBottomWidth: 2}}
  142. placeholder='Status'
  143. />
  144. </View>
  145.  
  146. <TouchableHighlight style={styles.btn}>
  147. <Text style={styles.btnText}>Simpan</Text>
  148. </TouchableHighlight>
  149.  
  150. </View>
  151. </ScrollView>
  152. </KeyboardAvoidingView>
  153. </View>
  154. );
  155. }
Add Comment
Please, Sign In to add comment