Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ImageOrViewMessages = (props) => {
- if(item != null && item.image != ''){
- return (
- <View>
- <Image source={{uri: item.image, cache: "force-cache"}} style={{display: 'flex', height: 300, flex: 1, padding: 5}} />
- </View>
- )
- } else {
- return(
- <View style={{display: 'none'}}></View>
- )
- }
- }
- <FlatList
- data={this.props.unsent_messages.length > 0 && this.props.chat != '' ? this.props.unsent_messages.concat(this.props.messages) : this.props.messages}
- renderItem={({item}) => {
- var align_text = "flex-end"
- var background_color = colors.main_color_light;
- var text_color = "white"
- var stamp = "none"
- if(item.username.toLowerCase() != this.props.displayName.toLowerCase()){
- //do something differ
- align_text = "flex-start"
- background_color = colors.main_color_dark;
- text_color = "white"
- stamp = "flex"
- }
- ImageOrViewMessages = (props) => {
- if(item != null && item.image != ''){
- return (
- <View>
- <Image source={{uri: item.image, cache: "force-cache"}} style={{display: 'flex', height: 300, flex: 1, padding: 5}} />
- </View>
- )
- } else {
- return(
- <View style={{display: 'none'}}></View>
- )
- }
- }
- return(
- <View style={{padding: 5, minHeight: 70, alignItems: align_text, justifyContent: "center"}}>
- <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}}>
- <Text style={{fontFamily: "MarkerFelt-Thin", color: text_color, fontSize: 16, textAlign: "left", flex: 1}}>{item.message}</Text>
- {/* <Text style={{display: stamp, fontFamily: "MarkerFelt-Thin", color: colors.background_color, fontSize: 14, textAlign: "right", flex: 1}}>{item.username}</Text> */}
- <ImageOrViewMessages />
- </View>
- </View>
- )}
- }
- keyExtractor={item => item.image != '' ? item.image : item.id.toString()}
- style={{display: 'flex', flex: 1, borderTopLeftRadius: 25, borderTopRightRadius: 25}}
- ref={ref => this.flatList = ref}
- inverted={true}
- />
- <FastImage
- style={styles.image}
- source={{
- uri: YOUR_IMAGE_URL,
- priority: FastImage.priority.normal,
- }}
- resizeMode={FastImage.resizeMode.contain}
- />
- import FastImage from 'react-native-fast-image'
Add Comment
Please, Sign In to add comment