-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Make LHN rows look the same as chatswitcher ones #793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d35e41a
Use the same formatting for LHN and chatswitcher rows
Gonals 3fa31df
make it work correctly
Gonals bc89214
Hide the Add button for LHN
Gonals 9f128db
correctly bold the row when unread messages are there
Gonals 6977ddc
Remane ChatSwitcherRow
Gonals 945be84
style
Gonals 291b520
Merge branch 'master' into alberto-styleLHNRows
Gonals 98d0e8d
bold only the main name
Gonals File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| import React from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| import { | ||
| Image, | ||
| Text, | ||
| TouchableOpacity, | ||
| View, | ||
| } from 'react-native'; | ||
| import styles from '../../../styles/StyleSheet'; | ||
| import ChatSwitcherOptionPropTypes from './ChatSwitcherOptionPropTypes'; | ||
| import ROUTES from '../../../ROUTES'; | ||
| import PressableLink from '../../../components/PressableLink'; | ||
|
|
||
| const propTypes = { | ||
| // Option to allow the user to choose from can be type 'report' or 'user' | ||
| option: ChatSwitcherOptionPropTypes.isRequired, | ||
|
|
||
| // Whether this option is currently in focus so we can modify its style | ||
| optionIsFocused: PropTypes.bool.isRequired, | ||
|
|
||
| // A function that is called when an option is selected. Selected option is passed as a param | ||
| onSelectRow: PropTypes.func.isRequired, | ||
|
|
||
| // Callback that adds a user to the pending list of Group DM users | ||
| onAddToGroup: PropTypes.func, | ||
|
|
||
| // A flag to indicate whether this comes from the Chat Switcher so we can display the group button | ||
| isChatSwitcher: PropTypes.bool, | ||
| }; | ||
|
|
||
| const defaultProps = { | ||
| onAddToGroup: () => {}, | ||
| isChatSwitcher: false, | ||
| }; | ||
|
|
||
| const ChatLinkRow = ({ | ||
| option, | ||
| optionIsFocused, | ||
| onSelectRow, | ||
| onAddToGroup, | ||
| isChatSwitcher, | ||
| }) => { | ||
| const isUserRow = option.type === 'user'; | ||
| const textStyle = optionIsFocused | ||
| ? styles.sidebarLinkActiveText | ||
| : styles.sidebarLinkText; | ||
| const textUnreadStyle = option.isUnread | ||
| ? [textStyle, styles.sidebarLinkTextUnread] : [textStyle]; | ||
| return ( | ||
| <View | ||
| style={[ | ||
| styles.flexRow, | ||
| styles.alignItemsCenter, | ||
| styles.flexJustifySpaceBetween, | ||
| styles.sidebarLink, | ||
| styles.sidebarLinkInner, | ||
| optionIsFocused ? styles.sidebarLinkActive : null | ||
| ]} | ||
| > | ||
| <PressableLink | ||
| onClick={() => onSelectRow(option)} | ||
| to={ROUTES.getReportRoute(option.reportID)} | ||
| style={styles.textDecorationNoLine} | ||
| > | ||
| <TouchableOpacity | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI, this broke mobile clients because the touchable opacity is on top of the pressable link and this prevents the link from triggering a router change. |
||
| onPress={() => onSelectRow(option)} | ||
| style={[ | ||
| styles.flexGrow1, | ||
| styles.chatSwitcherItemAvatarNameWrapper, | ||
| ]} | ||
| > | ||
| <View | ||
| style={[ | ||
| styles.flexRow, | ||
| styles.alignItemsCenter, | ||
| ]} | ||
| > | ||
| { | ||
| option.icon | ||
| && ( | ||
| <View style={[styles.chatSwitcherAvatar, styles.mr2]}> | ||
| <Image | ||
| source={{uri: option.icon}} | ||
| style={[styles.chatSwitcherAvatarImage]} | ||
| /> | ||
| </View> | ||
| ) | ||
| } | ||
| <View style={[styles.flex1]}> | ||
| {option.text === option.alternateText ? ( | ||
| <Text style={textUnreadStyle} numberOfLines={1}> | ||
| {option.alternateText} | ||
| </Text> | ||
| ) : ( | ||
| <> | ||
| <Text style={textUnreadStyle} numberOfLines={1}> | ||
| {option.text} | ||
| </Text> | ||
| <Text style={[textStyle, styles.textMicro]} numberOfLines={1}> | ||
| {option.alternateText} | ||
| </Text> | ||
| </> | ||
| )} | ||
| </View> | ||
| </View> | ||
| </TouchableOpacity> | ||
| </PressableLink> | ||
| {isUserRow && isChatSwitcher && ( | ||
| <View> | ||
| <TouchableOpacity | ||
| style={[styles.chatSwitcherItemButton]} | ||
| onPress={() => onAddToGroup(option)} | ||
| > | ||
| <Text | ||
| style={[styles.chatSwitcherItemButtonText]} | ||
| numberOfLines={1} | ||
| > | ||
| Add | ||
| </Text> | ||
| </TouchableOpacity> | ||
| </View> | ||
| )} | ||
| </View> | ||
| ); | ||
| }; | ||
|
|
||
| ChatLinkRow.propTypes = propTypes; | ||
| ChatLinkRow.defaultProps = defaultProps; | ||
| ChatLinkRow.displayName = 'ChatLinkRow'; | ||
|
|
||
| export default ChatLinkRow; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just
ChatRowwould be good enough.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about it, but it felt like a row in the chat itself, instead of a row with a chat 🤷