-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Updated LHN layout in GSD Priority Mode #2015
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
Changes from all commits
1aff844
25df511
d2b98b2
4c0ec7e
fd2bdf2
b6a00ed
22dc5e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import React, {memo} from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| import {Image, Text, View} from 'react-native'; | ||
| import styles from '../styles/styles'; | ||
| import globalStyles from '../styles/styles'; | ||
|
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. Not really into the |
||
| import Avatar from './Avatar'; | ||
|
|
||
| const propTypes = { | ||
|
|
@@ -10,58 +10,86 @@ const propTypes = { | |
|
|
||
| // Whether this option is currently in focus so we can modify its style | ||
| optionIsFocused: PropTypes.bool, | ||
|
|
||
| // Set the sie of avatars | ||
| size: PropTypes.oneOf(['default', 'small']), | ||
|
|
||
| // Styles to override the basic component styles | ||
| styles: PropTypes.shape({ | ||
| // Style for First Avatar on Multiple Avatars | ||
| // eslint-disable-next-line react/forbid-prop-types | ||
| singleAvatar: PropTypes.object, | ||
|
|
||
| // Style for Second Avatar on Multiple Avatars | ||
| // eslint-disable-next-line react/forbid-prop-types | ||
| secondAvatar: PropTypes.object, | ||
|
|
||
| // Style for avatar Container | ||
| // eslint-disable-next-line react/forbid-prop-types | ||
| emptyAvatar: PropTypes.object, | ||
|
parasharrajat marked this conversation as resolved.
|
||
| }), | ||
| }; | ||
|
|
||
| const defaultProps = { | ||
| avatarImageURLs: [], | ||
| optionIsFocused: false, | ||
| size: 'default', | ||
| styles: {}, | ||
| }; | ||
|
|
||
| const MultipleAvatars = ({avatarImageURLs, optionIsFocused}) => { | ||
| const MultipleAvatars = ({ | ||
| avatarImageURLs, optionIsFocused, size, styles, | ||
| }) => { | ||
| const avatarContainerStyles = [ | ||
| size === 'small' ? globalStyles.emptyAvatarSmall : globalStyles.emptyAvatar, styles.emptyAvatar, | ||
|
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.
|
||
| ]; | ||
| const singleAvatarStyles = [ | ||
| size === 'small' ? globalStyles.singleAvatarSmall : globalStyles.singleAvatar, styles.singleAvatar, | ||
|
parasharrajat marked this conversation as resolved.
|
||
| ]; | ||
| const secondAvatarStyles = [ | ||
| size === 'small' ? globalStyles.secondAvatarSmall : globalStyles.secondAvatar, | ||
| optionIsFocused ? globalStyles.focusedAvatar : globalStyles.avatar, | ||
| styles.secondAvatar, | ||
| ]; | ||
|
|
||
| if (!avatarImageURLs.length) { | ||
| return null; | ||
| } | ||
|
|
||
| if (avatarImageURLs.length === 1) { | ||
| return ( | ||
| <View style={styles.emptyAvatar}> | ||
| <Avatar source={avatarImageURLs[0]} /> | ||
| <View style={avatarContainerStyles}> | ||
| <Avatar source={avatarImageURLs[0]} size={size} /> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <View style={styles.emptyAvatar}> | ||
| <View style={avatarContainerStyles}> | ||
| <View | ||
| style={styles.singleAvatar} | ||
| style={singleAvatarStyles} | ||
| > | ||
| <Image | ||
| source={{uri: avatarImageURLs[0]}} | ||
| style={styles.singleAvatar} | ||
| style={singleAvatarStyles} | ||
| /> | ||
| <View | ||
| style={[ | ||
| styles.singleAvatar, | ||
| optionIsFocused ? styles.focusedAvatar : styles.avatar, | ||
| styles.secondAvatar, | ||
| ]} | ||
| style={secondAvatarStyles} | ||
| > | ||
| {avatarImageURLs.length === 2 ? ( | ||
| <Image | ||
| source={{uri: avatarImageURLs[1]}} | ||
| style={[ | ||
| styles.singleAvatar, | ||
| ]} | ||
| style={singleAvatarStyles} | ||
| /> | ||
| ) : ( | ||
| <View | ||
| style={[ | ||
| styles.avatarText, | ||
| ]} | ||
| style={singleAvatarStyles} | ||
| > | ||
| <Text style={styles.avatarInnerText}> | ||
| + | ||
| {avatarImageURLs.length - 1} | ||
| <Text style={size === 'small' | ||
| ? globalStyles.avatarInnerTextSmall | ||
| : globalStyles.avatarInnerText} | ||
| > | ||
| {`+${avatarImageURLs.length - 1}`} | ||
| </Text> | ||
| </View> | ||
| )} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,9 @@ const propTypes = { | |
|
|
||
| // Whether to show the title tooltip | ||
| showTitleTooltip: PropTypes.bool, | ||
|
|
||
| // Toggle between compact and default view | ||
| mode: PropTypes.oneOf(['compact', 'default']), | ||
| }; | ||
|
|
||
| const defaultProps = { | ||
|
|
@@ -53,6 +56,7 @@ const defaultProps = { | |
| isSelected: false, | ||
| forceTextUnreadStyle: false, | ||
| showTitleTooltip: false, | ||
| mode: 'default', | ||
| }; | ||
|
|
||
| const OptionRow = ({ | ||
|
|
@@ -65,12 +69,36 @@ const OptionRow = ({ | |
| isSelected, | ||
| forceTextUnreadStyle, | ||
| showTitleTooltip, | ||
| mode, | ||
| }) => { | ||
| const textStyle = optionIsFocused | ||
| ? styles.sidebarLinkActiveText | ||
| : styles.sidebarLinkText; | ||
| const textUnreadStyle = (option.isUnread || forceTextUnreadStyle) | ||
| ? [textStyle, styles.sidebarLinkTextUnread] : [textStyle]; | ||
| const displayNameStyle = mode === 'compact' | ||
| ? [styles.optionDisplayName, textUnreadStyle, styles.optionDisplayNameCompact, styles.mr2] | ||
| : [styles.optionDisplayName, textUnreadStyle]; | ||
| const alternateTextStyle = mode === 'compact' | ||
| ? [textStyle, styles.optionAlternateText, styles.optionAlternateTextCompact] | ||
| : [textStyle, styles.optionAlternateText, styles.mt1]; | ||
| const contentContainerStyles = mode === 'compact' | ||
| ? [styles.flex1, styles.flexRow, styles.overflowHidden, styles.alignItemsCenter] | ||
| : [styles.flex1]; | ||
| const sidebarInnerRowStyle = StyleSheet.flatten(mode === 'compact' ? [ | ||
| styles.chatLinkRowPressable, | ||
| styles.flexGrow1, | ||
| styles.optionItemAvatarNameWrapper, | ||
| styles.sidebarInnerRowSmall, | ||
| styles.justifyContentCenter, | ||
| ] : [ | ||
| styles.chatLinkRowPressable, | ||
| styles.flexGrow1, | ||
| styles.optionItemAvatarNameWrapper, | ||
| styles.sidebarInnerRow, | ||
| styles.justifyContentCenter, | ||
| ]); | ||
|
|
||
| return ( | ||
| <Hoverable> | ||
| {hovered => ( | ||
|
|
@@ -87,14 +115,7 @@ const OptionRow = ({ | |
| hovered && !optionIsFocused ? hoverStyle : null, | ||
| ]} | ||
| > | ||
| <View | ||
| style={StyleSheet.flatten([ | ||
| styles.chatLinkRowPressable, | ||
| styles.flexGrow1, | ||
| styles.optionItemAvatarNameWrapper, | ||
| styles.sidebarInnerRow, | ||
| ])} | ||
| > | ||
| <View style={sidebarInnerRowStyle}> | ||
| <View | ||
| style={[ | ||
| styles.flexRow, | ||
|
|
@@ -107,20 +128,27 @@ const OptionRow = ({ | |
| <MultipleAvatars | ||
| avatarImageURLs={option.icons} | ||
| optionIsFocused={optionIsFocused} | ||
| size={mode === 'compact' ? 'small' : 'default'} | ||
| styles={hovered && !optionIsFocused && { | ||
| secondAvatar: { | ||
|
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. This should be in |
||
| backgroundColor: themeColors.sidebarHover, | ||
| borderColor: themeColors.sidebarHover, | ||
| }, | ||
| }} | ||
| /> | ||
| ) | ||
| } | ||
| <View style={[styles.flex1]}> | ||
| <View style={contentContainerStyles}> | ||
| <OptionRowTitle | ||
| option={option} | ||
| tooltipEnabled={showTitleTooltip} | ||
| numberOfLines={1} | ||
| style={[styles.optionDisplayName, textUnreadStyle]} | ||
| style={displayNameStyle} | ||
| /> | ||
|
|
||
| {option.alternateText ? ( | ||
| <Text | ||
| style={[textStyle, styles.optionAlternateText, styles.mt1]} | ||
| style={alternateTextStyle} | ||
| numberOfLines={1} | ||
| > | ||
| {option.alternateText} | ||
|
|
@@ -170,6 +198,10 @@ export default memo(OptionRow, (prevProps, nextProps) => { | |
| return false; | ||
| } | ||
|
|
||
| if (prevProps.mode !== nextProps.mode) { | ||
| return false; | ||
| } | ||
|
|
||
| if (prevProps.option.isUnread !== nextProps.option.isUnread) { | ||
| return false; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.