Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { View, Text, StyleSheet, Image, Animated } from 'react-native';
  3. import Icon from '@expo/vector-icons/MaterialCommunityIcons';
  4. import { AnimatedRegion } from 'react-native-maps';
  5.  
  6. class ComponentName extends Component {
  7. constructor(props) {
  8. super(props);
  9. this.state = {
  10. like: false,
  11. };
  12.  
  13.  
  14. }
  15.  
  16.  
  17. ChangeLikeState = () =>{
  18. this.setState(prevState => ({
  19. like: !prevState.like
  20. }));
  21. }
  22.  
  23. render() {
  24.  
  25. let likeButton;
  26.  
  27. if(!this.state.like){
  28. likeButton =
  29.  
  30. <Icon style = {styles.iconFeedRight}
  31. name="thumb-up-outline"
  32. type= "thumb-up-outline"
  33. color="rgba(255,255,255, 0.7)"
  34. size = {36}
  35. onPress = {this.ChangeLikeState}
  36. ></Icon>
  37.  
  38. } else {
  39. likeButton =
  40.  
  41. <Icon style = {styles.iconFeedRight}
  42. name="thumb-up"
  43. type= "thumb-up"
  44. color="rgba(255,255,255, 0.7)"
  45. size = {36}
  46. onPress = {this.ChangeLikeState}
  47. ></Icon>
  48.  
  49.  
  50. }
  51. return (
  52. <View style={styles.boxFeed}>
  53. <View style={styles.rows}>
  54. <Image style ={styles.avatarFeed} source = {require("../stenson.jpg")}></Image>
  55. <View style={styles.columns}>
  56. <Text style = {styles.textFeed}>
  57. {this.props.name} added a session.
  58. </Text>
  59. <Text style = {styles.textFeed}>
  60. Yesterday 15:15
  61. </Text>
  62. <View style={styles.rows}>
  63. <Icon style = {styles.iconFeed}
  64. name="golf"
  65. type="golf"
  66. color="rgba(255,255,255, 0.7)"
  67. size = {36}></Icon>
  68. <Icon style = {styles.iconFeed}
  69. name="golf"
  70. type="golf"
  71. color="rgba(255,255,255, 0.7)"
  72. size = {36}></Icon>
  73. <Icon style = {styles.iconFeed}
  74. name="dumbbell"
  75. type="dumbbell"
  76. color="rgba(255,255,255, 0.7)"
  77. size = {36}></Icon>
  78. <View style={styles.rowsRight}>
  79. </View>
  80. <Icon style = {styles.iconFeedRight}
  81. name="message-outline"
  82. type="message-outline"
  83. color="rgba(255,255,255, 0.7)"
  84. size = {36}></Icon>
  85.  
  86. {likeButton}
  87.  
  88. </View>
  89.  
  90. </View>
  91. </View>
  92. </View>
  93. );
  94. }
  95. }
  96.  
  97. const styles = StyleSheet.create({
  98. iconFeed: {
  99. marginTop: 8,
  100. marginRight: 10,
  101. },
  102.  
  103. iconFeedRight: {
  104. marginTop: 8,
  105. marginRight: 20,
  106. },
  107.  
  108.  
  109. container: {
  110. flex: 1,
  111. },
  112.  
  113. columns: {
  114. marginLeft: 10
  115. },
  116.  
  117. avatarFeed: {
  118. width:80,
  119. height:80,
  120. borderRadius:100,
  121. borderWidth:1,
  122. marginLeft: 20,
  123.  
  124.  
  125. },
  126.  
  127. rows: {
  128. flexDirection: 'row',
  129. },
  130.  
  131.  
  132. rowsRight: {
  133. flexDirection: 'row',
  134.  
  135. marginLeft: 60,
  136. },
  137.  
  138. textFeed: {
  139. fontSize: 18,
  140. color: "white",
  141. fontWeight: "bold",
  142. marginBottom: 5,
  143.  
  144. },
  145.  
  146. boxFeed: {
  147. backgroundColor: "rgba(93, 122, 177, 0.4)",
  148.  
  149. width: "100%",
  150. paddingTop: 20,
  151. paddingBottom: 20,
  152. marginTop: 20,
  153. marginBottom: 10,
  154.  
  155. }
  156.  
  157.  
  158. });
  159.  
  160. export default ComponentName;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement