Advertisement
enkf

Untitled

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