Skip to content

Commit

Permalink
Add new message read status
Browse files Browse the repository at this point in the history
  • Loading branch information
terrysahaidak committed Mar 22, 2016
1 parent 965c9a0 commit d732e42
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 13 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 18 additions & 10 deletions app/components/Room/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React, {
TouchableNativeFeedback,
TouchableOpacity,
Linking,
Image,
View,
Text
} from 'react-native'
Expand Down Expand Up @@ -92,14 +93,8 @@ class Message extends Component {
text, status, onUsernamePress, onUserAvatarPress} = this.props
const opacity = sending === true ? 0.4 : 1

let backgroundColor
if (failed === true) {
backgroundColor = 'rgba(255, 0, 0, 0.2)'
} else if (readBy === 0) {
backgroundColor = 'rgba(200, 200, 200, 0.2)'
} else {
backgroundColor = 'transparent'
}
const backgroundColor = failed === true ? 'rgba(255, 0, 0, 0.2)' : 'transparent'
const readStatusOpacity = readBy === 0 ? 0 : 0.6

if (!!status) {
return (
Expand All @@ -108,7 +103,8 @@ class Message extends Component {
onLongPress={this.onLongPress.bind(this)}
onPress={this.onMessagePress.bind(this)}
handleUrlPress={this.handleUrlPress.bind(this)}
backgroundColor={backgroundColor} />
backgroundColor={backgroundColor}
opacity={readStatusOpacity} />
)
}

Expand All @@ -126,6 +122,11 @@ class Message extends Component {
{this.renderMessageText()}
</View>
</View>
<View style={s.readStatus}>
<Image
style={[s.readStatusIcon, {opacity: readStatusOpacity}]}
source={require('image!ic_done_black_24dp')} />
</View>
</View>
</TouchableNativeFeedback>
)
Expand All @@ -145,12 +146,19 @@ class Message extends Component {
<Text
style={s.username}
onPress={() => onUsernamePress(fromUser.username)}>{fromUser.username}</Text>
<Text style={s.date}>{this.renderDate()}</Text>
<Text style={s.date}>
{this.renderDate()}
</Text>
</View>
<View style={s.bottom}>
{this.renderMessageText()}
</View>
</View>
<View style={s.readStatus}>
<Image
style={[s.readStatusIcon, {opacity: readStatusOpacity}]}
source={require('image!ic_done_black_24dp')} />
</View>
</View>
</TouchableNativeFeedback>
)
Expand Down
11 changes: 9 additions & 2 deletions app/components/Room/StatusMessage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {
PropTypes,
TouchableNativeFeedback,
Image,
View
} from 'react-native'
import s from '../../styles/screens/Room/StatusMessageStyles'
Expand All @@ -18,7 +19,7 @@ const renderEmoji = (matchingString, matches) => {
)
}

const StatusMessage = ({onPress, onLongPress, text, handleUrlPress, backgroundColor}) => {
const StatusMessage = ({onPress, onLongPress, text, handleUrlPress, backgroundColor, opacity}) => {
const patterns = [
{type: 'url', style: s.url, onPress: handleUrlPress},
{pattern: EMOJI_REGEX, style: s.emoji, renderText: renderEmoji},
Expand All @@ -43,6 +44,11 @@ const StatusMessage = ({onPress, onLongPress, text, handleUrlPress, backgroundCo
</Parser>
</View>
</View>
<View style={s.readStatus}>
<Image
style={[s.readStatusIcon, {opacity}]}
source={require('image!ic_done_black_24dp')} />
</View>
</View>
</TouchableNativeFeedback>
)
Expand All @@ -53,7 +59,8 @@ StatusMessage.propTypes = {
onLongPress: PropTypes.func,
text: PropTypes.string,
handleUrlPress: PropTypes.func,
backgroundColor: PropTypes.string
backgroundColor: PropTypes.string,
opacity: PropTypes.number
}

export default StatusMessage
3 changes: 2 additions & 1 deletion app/screens/RoomScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,8 @@ class Room extends Component {
{this.renderToolbar()}
{isLoadingMore ? this.renderLoadingMore() : null}
{isLoadingMessages ? this.renderLoading() : this.renderListView()}
{getMessagesError || isLoadingMessages || _.has(listView, 'data') && listView.data.length === 0 ? null : this.renderBottom()}
{getMessagesError || isLoadingMessages || _.has(listView, 'data') &&
listView.data.length === 0 ? null : this.renderBottom()}
</View>
)
}
Expand Down
8 changes: 8 additions & 0 deletions app/styles/screens/Room/MessageStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ const style = StyleSheet.create({
},
url: {
color: 'blue'
},
readStatus: {
width: 15,
marginTop: 3
},
readStatusIcon: {
width: 15,
height: 15
}
})

Expand Down
8 changes: 8 additions & 0 deletions app/styles/screens/Room/StatusMessageStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ const style = StyleSheet.create({
},
url: {
color: colors.link
},
readStatus: {
width: 15,
marginTop: 3
},
readStatusIcon: {
width: 15,
height: 15
}
})

Expand Down

0 comments on commit d732e42

Please sign in to comment.