Advertisement
enkf

Untitled

Jan 22nd, 2020
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.74 KB | None | 0 0
  1. import React from 'react';
  2. import {
  3. StyleSheet,
  4. View,
  5. Text,
  6. TouchableOpacity,
  7. BackHandler,
  8. Image,
  9. ScrollView,
  10. ActivityIndicator,
  11. FlatList,
  12. } from 'react-native';
  13. import AsyncStorage from '@react-native-community/async-storage';
  14. import {
  15. Container,
  16. Header,
  17. CardItem,
  18. Left,
  19. Body,
  20. Thumbnail,
  21. } from 'native-base';
  22. import { withNavigation } from 'react-navigation';
  23. import Axios from 'axios';
  24.  
  25. class Home extends React.Component {
  26.  
  27. constructor(props) {
  28. super(props);
  29. this.state = {
  30. isLoading: false,
  31. id: '',
  32. card_member:'',
  33. member_code: '',
  34. referral_code: '',
  35. name: '',
  36. place: '',
  37. date_of_birth: '',
  38. religion: '',
  39. address:'',
  40. phone_number: '',
  41. phone_home: '',
  42. phone_office: '',
  43. image: '',
  44. email: '',
  45. password: '',
  46. data: [],
  47. renders: []
  48.  
  49. };
  50. }
  51.  
  52.  
  53. async componentDidMount(){
  54. // const token =
  55. await AsyncStorage.getItem('token')
  56. console.log(headers);
  57. // api profile
  58. const url = 'http://192.168.56.1/vzuu/public/api/members'
  59. headers = {'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjU0MzM2YTJmMjZjMTlmOWVkOWQxMDdmYmM0MDEzNzM1NGZiNjllZGI2NjM4NThhNGE3OWQwZmM1MTE5N2JmOWU3Mzk2NWUxNzdjMDhmYTgyIn0.eyJhdWQiOiIzIiwianRpIjoiNTQzMzZhMmYyNmMxOWY5ZWQ5ZDEwN2ZiYzQwMTM3MzU0ZmI2OWVkYjY2Mzg1OGE0YTc5ZDBmYzUxMTk3YmY5ZTczOTY1ZTE3N2MwOGZhODIiLCJpYXQiOjE1Nzk3NTE1ODMsIm5iZiI6MTU3OTc1MTU4MywiZXhwIjoxNjExMzczOTgzLCJzdWIiOiIzIiwic2NvcGVzIjpbXX0.J-XFFYbWw8kJ-u9YtqUhR1egtNLH4aoDGkg-qFPE7Y2_eGqagd1PvUrPVSYvhpngItNCAh86nc6oXubl1yJyNSDKVbTHeUmf6fPeRvr0sZiB3oUa6sM44U1xQ6ZGsXzpBPxaA5RLNWj567JyZW8fpKTUwal1TjRvJrHnD3R--veckbqKclh7UKG1dQcPGq08rfs1YDKJDNw-RDyfc-VPrED54vO0nTm5zMwfOnqjQfe1ZoETyF7F_XpMRdy14lsK4rgvVddTi-DNu6fuVmACOp3iee9zAkYKOv0GWiGfXheYE0_FtYKWXKBMVWQ1MsruQcbM1DMcZ92qqnw3UrXLZzqz-4uXj7DOVJva5qTzNUkwwzkyST7aqBroTzvLQt9FsthSeaeSJVhOCXovnpMLwZ1rQnm1ZRKSO-bog5b90JocJppk6-5lq6vw3e3Cn8R9vb0hg16s6rEO-bP5_88h8CUZrFhNdIepjywaRwnf2SKJtKN2bPDci5kVfi602uXcotu14pNhLFyTonbFJC5fUPU11R71l8ggPiYrI3Ye8_L5m3AcgodbupijeNH-c9xiNOccfQaWEiKoxO7eR6Iq7zta7RnK1HcPVWlBGc3EdWuq_Wulhp9NrzQWK2_10V8iy6EP4EZTfUW-wAjJv5T6EEiJrCgRuxJUWUL-0E0ARXg' }
  60. fetch(url, headers, {method:'GET'})
  61. .then(data=>data.json())
  62. .then(res=> {
  63. console.log(res.results.members);
  64. // dari selesai fetching api profile
  65.  
  66. setTimeout(()=>{this.setState({loading:false})},1000)
  67. this.setState({
  68. data: res.results.members,
  69. renders: res.results.members.data,
  70. })
  71. console.log(this.state.data);
  72. })
  73. .catch(err=>console.warn({err}))
  74. }
  75.  
  76. render() {
  77. return (
  78. <Container>
  79. <View>
  80. <Header style={{ backgroundColor: '#E91E63' }} />
  81. {this.state.isLoading
  82. ? <ActivityIndicator color='#E91E63' size='large' />
  83. :
  84. <ScrollView>
  85.  
  86. <View style={{ flex: 1, alignItems: 'center' }}>
  87. <Text style={{ fontSize: 16 }}>{this.state.curTime}</Text>
  88. </View>
  89. <CardItem>
  90. <View style={{ marginHorizontal: 10 }}></View>
  91. <FlatList data={this.state.renders}
  92. renderItem={({ item }) => (
  93. <View style={{flex: 1}}>
  94. <Left>
  95. {/* <Thumbnail
  96. style={{ width: 80, height: 80 }}
  97. source={{uri : this.state.image}}
  98. /> */}
  99. <Body>
  100. <Text style={styles.text}>{item.name}</Text>
  101. {/* <Text style={styles.text}>{item.phone_number}</Text> */}
  102. {/* <Text>Jumlah Point</Text> */}
  103. </Body>
  104. </Left>
  105. </View>
  106. )}
  107. keyExtractor={item => item.name}
  108. />
  109.  
  110. </CardItem>
  111. <View
  112. style={{
  113. flexDirection: 'row',
  114. flexWrap: 'wrap',
  115. marginHorizontal: 50,
  116. marginTop: 50,
  117. }}></View>
  118. <View
  119. style={{
  120. flexDirection: 'row',
  121. flexWrap: 'wrap',
  122. marginHorizontal: 18,
  123. marginTop: 18,
  124. }}>
  125. <View
  126. style={{
  127. justifyContent: 'space-between',
  128. flexDirection: 'row',
  129. width: '100%',
  130. marginBottom: 18,
  131. }}>
  132. <View>
  133. <TouchableOpacity onPress={() => this.props.navigation.navigate('treatment')}>
  134. <View
  135. style={{
  136. width: 100,
  137. height: 100,
  138. borderWidth: 1,
  139. borderColor: '#EFEFEF',
  140. borderRadius: 18,
  141. }}>
  142. <Image
  143. source={require('../asset/images/color/service.png')}
  144. style={{ height: 80, width: 100, flex: 1 }}
  145. />
  146. </View>
  147. <Text
  148. style={{
  149. fontSize: 12,
  150. fontWeight: 'bold',
  151. textAlign: 'center',
  152. color: '#E91E63',
  153. }}>
  154. Treatment
  155. </Text>
  156. </TouchableOpacity>
  157. </View>
  158. <View>
  159. <TouchableOpacity onPress={() => this.props.navigation.navigate('booking')}>
  160. <View
  161. style={{
  162. width: 100,
  163. height: 100,
  164. borderWidth: 1,
  165. borderColor: '#EFEFEF',
  166. borderRadius: 18,
  167. }}>
  168. <Image
  169. source={require('../asset/images/color/booking.png')}
  170. style={{ height: 80, width: 100, flex: 1 }}
  171. />
  172. </View>
  173. <Text
  174. style={{
  175. fontSize: 12,
  176. fontWeight: 'bold',
  177. textAlign: 'center',
  178. color: '#E91E63',
  179. }}>
  180. Booking
  181. </Text>
  182. </TouchableOpacity>
  183. </View>
  184. <View>
  185. <TouchableOpacity onPress={() => this.props.navigation.navigate('promotion')}>
  186. <View
  187. style={{
  188. width: 100,
  189. height: 100,
  190. borderWidth: 1,
  191. borderColor: '#EFEFEF',
  192. borderRadius: 18,
  193. }}>
  194. <Image
  195. source={require('../asset/images/color/promo.png')}
  196. style={{ height: 80, width: 100, flex: 1 }}
  197. />
  198. </View>
  199. <Text
  200. style={{
  201. fontSize: 12,
  202. fontWeight: 'bold',
  203. textAlign: 'center',
  204. color: '#E91E63',
  205. }}>
  206. Promotion
  207. </Text>
  208. </TouchableOpacity>
  209. </View>
  210. </View>
  211. </View>
  212.  
  213. <View
  214. style={{
  215. flexDirection: 'row',
  216. flexWrap: 'wrap',
  217. marginHorizontal: 18,
  218. marginTop: 18,
  219. }}>
  220. <View
  221. style={{
  222. justifyContent: 'space-between',
  223. flexDirection: 'row',
  224. width: '100%',
  225. marginBottom: 18,
  226. }}>
  227. <View>
  228. <TouchableOpacity onPress={() => this.props.navigation.navigate('point')}>
  229. <View
  230. style={{
  231. width: 100,
  232. height: 100,
  233. borderWidth: 1,
  234. borderColor: '#EFEFEF',
  235. borderRadius: 18,
  236. }}>
  237. <Image
  238. source={require('../asset/images/color/point.png')}
  239. style={{ height: 80, width: 100, flex: 1 }}
  240. />
  241. </View>
  242. <Text
  243. style={{
  244. fontSize: 12,
  245. fontWeight: 'bold',
  246. textAlign: 'center',
  247. color: '#E91E63',
  248. }}>
  249. Point
  250. </Text>
  251. </TouchableOpacity>
  252. </View>
  253. <View>
  254. <TouchableOpacity>
  255. <View
  256. style={{
  257. width: 100,
  258. height: 100,
  259. borderWidth: 1,
  260. borderColor: '#EFEFEF',
  261. borderRadius: 18,
  262. }}>
  263. <Image
  264. source={require('../asset/images/color/spin.png')}
  265. style={{ height: 80, width: 100, flex: 1 }}
  266. />
  267. </View>
  268. <Text
  269. style={{
  270. fontSize: 12,
  271. fontWeight: 'bold',
  272. textAlign: 'center',
  273. color: '#E91E63',
  274. }}>
  275. Spin
  276. </Text>
  277. </TouchableOpacity>
  278. </View>
  279. <View>
  280. <TouchableOpacity onPress={() => this.props.navigation.navigate('contact')}>
  281. <View
  282. style={{
  283. width: 100,
  284. height: 100,
  285. borderWidth: 1,
  286. borderColor: '#EFEFEF',
  287. borderRadius: 18,
  288. }}>
  289. <Image
  290. source={require('../asset/images/color/contact.png')}
  291. style={{ height: 80, width: 100, flex: 1 }}
  292. />
  293. </View>
  294. <Text
  295. style={{
  296. fontSize: 12,
  297. fontWeight: 'bold',
  298. textAlign: 'center',
  299. color: '#E91E63',
  300. }}>
  301. Contact
  302. </Text>
  303. </TouchableOpacity>
  304. </View>
  305. </View>
  306. </View>
  307.  
  308. </ScrollView>
  309. }
  310. </View>
  311. </Container>
  312. );
  313. }
  314. }
  315.  
  316.  
  317. export default withNavigation(Home);
  318. const styles = StyleSheet.create({
  319. container: {
  320. flex: 1,
  321. justifyContent: 'center',
  322. alignItems: 'center',
  323. },
  324. text: { fontSize: 18, fontWeight:'bold', color: '#E91E63', alignItems: 'center', justifyContent: 'center' }
  325. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement