Guest User

Untitled

a guest
Jul 18th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. ImageOrViewMessages = (props) => {
  2. if(item != null && item.image != ''){
  3. return (
  4. <View>
  5. <Image source={{uri: item.image, cache: "force-cache"}} style={{display: 'flex', height: 300, flex: 1, padding: 5}} />
  6. </View>
  7. )
  8. } else {
  9. return(
  10. <View style={{display: 'none'}}></View>
  11. )
  12. }
  13. }
  14.  
  15. <FlatList
  16. data={this.props.unsent_messages.length > 0 && this.props.chat != '' ? this.props.unsent_messages.concat(this.props.messages) : this.props.messages}
  17. renderItem={({item}) => {
  18. var align_text = "flex-end"
  19. var background_color = colors.main_color_light;
  20. var text_color = "white"
  21. var stamp = "none"
  22. if(item.username.toLowerCase() != this.props.displayName.toLowerCase()){
  23. //do something differ
  24. align_text = "flex-start"
  25. background_color = colors.main_color_dark;
  26. text_color = "white"
  27. stamp = "flex"
  28. }
  29. ImageOrViewMessages = (props) => {
  30. if(item != null && item.image != ''){
  31. return (
  32. <View>
  33. <Image source={{uri: item.image, cache: "force-cache"}} style={{display: 'flex', height: 300, flex: 1, padding: 5}} />
  34. </View>
  35. )
  36. } else {
  37. return(
  38. <View style={{display: 'none'}}></View>
  39. )
  40. }
  41. }
  42.  
  43.  
  44. return(
  45. <View style={{padding: 5, minHeight: 70, alignItems: align_text, justifyContent: "center"}}>
  46. <View style={{opacity: item.id.toString().includes("Unset") ? .3 : 1, backgroundColor: background_color, padding: 5, borderWidth: 0, borderColor: colors.border_color,borderRadius: 8 , width: (Dimensions.get('window').width / 2) - 10, alignSelf: align_text}}>
  47. <Text style={{fontFamily: "MarkerFelt-Thin", color: text_color, fontSize: 16, textAlign: "left", flex: 1}}>{item.message}</Text>
  48. {/* <Text style={{display: stamp, fontFamily: "MarkerFelt-Thin", color: colors.background_color, fontSize: 14, textAlign: "right", flex: 1}}>{item.username}</Text> */}
  49. <ImageOrViewMessages />
  50. </View>
  51. </View>
  52. )}
  53. }
  54. keyExtractor={item => item.image != '' ? item.image : item.id.toString()}
  55. style={{display: 'flex', flex: 1, borderTopLeftRadius: 25, borderTopRightRadius: 25}}
  56. ref={ref => this.flatList = ref}
  57. inverted={true}
  58. />
  59.  
  60. <FastImage
  61. style={styles.image}
  62. source={{
  63. uri: YOUR_IMAGE_URL,
  64. priority: FastImage.priority.normal,
  65. }}
  66. resizeMode={FastImage.resizeMode.contain}
  67. />
  68.  
  69. import FastImage from 'react-native-fast-image'
Add Comment
Please, Sign In to add comment