Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.95 KB | None | 0 0
  1. import React, { PureComponent } from 'react';
  2. import { View, StyleSheet, Image, ListView, TouchableOpacity, FlatList, Text } from 'react-native';
  3. import PropTypes from 'prop-types';
  4. import {WHITE, THEMECOLOR} from '../../constants/colors';
  5.  
  6. var moment = require('moment');
  7.  
  8. export default class InvitationList extends PureComponent {
  9. static propTypes = {
  10. navigation: PropTypes.object.isRequired,
  11. jwttoken: PropTypes.object.isRequired,
  12. fetchUser: PropTypes.func.isRequired,
  13. fetchUserProfile: PropTypes.func.isRequired,
  14. fetchDriverInvites: PropTypes.func.isRequired,
  15. }
  16.  
  17. constructor(props) {
  18. super(props);
  19.  
  20. console.log("In constructor props is ");
  21. console.log(this.props);
  22. }
  23.  
  24. FlatListItemSeparator = () => {
  25. return (
  26. <View
  27. style={{
  28. height: 1,
  29. width: "100%",
  30. backgroundColor: "#BEBEBE",
  31. }}
  32. />
  33. );
  34. }
  35.  
  36. renderItem({item}) {
  37. console.log("In render item props is ");
  38. console.log(this.props);
  39.  
  40. return (
  41. <InvitationListItem
  42. tripToFromText={item.source_city + " > " + item.destination_city}
  43. tripDateText={item.to_date}
  44. tripTimeText={item.to_date}
  45. />
  46. );
  47. }
  48.  
  49. render() {
  50. return (
  51. <View style={styles.container}>
  52. <FlatList style={styles.listContainer}
  53. data={this.props.inviteData}
  54. renderItem={this.renderItem}
  55. ItemSeparatorComponent = {this.FlatListItemSeparator} />
  56. </View>
  57. );
  58. }
  59. }
  60.  
  61. class InvitationListItem extends PureComponent {
  62. static propTypes = {
  63. //navigation: PropTypes.object.isRequired
  64. }
  65.  
  66. render() {
  67. return (
  68. <View style={styles.listContainer}>
  69. <View style={styles.profileAndTripInfo}>
  70. <Image
  71. style={styles.image}
  72. resizeMode={"cover"}
  73. source={{ uri: "https://s-media-cache-ak0.pinimg.com/736x/43/cd/6e/43cd6e82491bf130d97624c198ee1a3f--funny-movie-quotes-funny-movies.jpg"}}
  74. />
  75. <View style={styles.tripInfoContainer}>
  76. <Text style={styles.tripToFromText}> {this.props.tripToFromText} </Text>
  77. <Text style={styles.tripDateText}> {moment(this.props.tripDateText).format("MMMM Do, YYYY")} </Text>
  78. <Text style={styles.tripTimeText}> {moment(this.props.tripDateText).format("h:mm a")} </Text>
  79. </View>
  80. </View>
  81. <View style={styles.redCrossButton}>
  82. <TouchableOpacity>
  83. <Image
  84. source={require('../../../res/invite_screen/red_cross.png')}
  85. />
  86. </TouchableOpacity>
  87. </View>
  88. <View style={styles.greenCheckmarkButton}>
  89. <TouchableOpacity>
  90. <Image
  91. source={require('../../../res/invite_screen/green_checkmark.png')}
  92. />
  93. </TouchableOpacity>
  94. </View>
  95. </View>
  96. )
  97. }
  98. }
  99.  
  100. const styles = StyleSheet.create({
  101. container: {
  102. backgroundColor: WHITE,
  103. },
  104. listContainer: {
  105. flexDirection:'row',
  106. marginTop: 5,
  107. marginBottom: 5,
  108. },
  109. tripInfoContainer: {
  110. marginLeft: 12,
  111. flexDirection: 'column',
  112. justifyContent: 'center',
  113. },
  114. profileAndTripInfo: {
  115. flexDirection:'row',
  116. },
  117. tripToFromText: {
  118. fontWeight: 'bold',
  119. fontSize: 13,
  120. },
  121. tripDateText: {
  122. fontSize: 11
  123. },
  124. tripTimeText: {
  125. fontSize: 11
  126. },
  127. redCrossButton: {
  128. alignSelf: 'flex-end',
  129. flexDirection: 'row',
  130. alignItems: 'center',
  131. marginRight: 30,
  132. marginBottom: 30
  133. },
  134. greenCheckmarkButton: {
  135. alignSelf: 'flex-end',
  136. flexDirection: 'row',
  137. alignItems: 'center',
  138. marginBottom: 30,
  139. marginRight: 10,
  140. },
  141. separator: {
  142. flex: 1,
  143. height: 1,
  144. backgroundColor: '#8E8E8E',
  145. },
  146. image: {
  147. height: 80,
  148. width: 80,
  149. borderRadius: 40,
  150. borderWidth: 1,
  151. borderColor: '#BEBEBE',
  152. marginLeft: 10
  153. }
  154. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement