Skip to content

Commit

Permalink
Merge pull request #9 from Expensify/master
Browse files Browse the repository at this point in the history
Merge
  • Loading branch information
tugbadogan authored Apr 1, 2021
2 parents ae30f03 + edf3b3a commit b140d36
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 115 deletions.
58 changes: 3 additions & 55 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"react-native-image-picker": "^2.3.3",
"react-native-keyboard-spacer": "^0.4.1",
"react-native-modal": "^11.5.6",
"react-native-onyx": "git+https://github.com/Expensify/react-native-onyx.git#bd59626781393c93226fb80cb45569408e97b67c",
"react-native-onyx": "git+https://github.com/Expensify/react-native-onyx.git#aa36bdb7b5cd2319c34b9ee1b4c73cb73e89f4a5",
"react-native-pdf": "^6.2.2",
"react-native-picker-select": "8.0.4",
"react-native-reanimated": "1.13.2",
Expand Down
7 changes: 3 additions & 4 deletions src/components/Avatar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import _ from 'underscore';
import React, {PureComponent} from 'react';
import {Image} from 'react-native';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -30,10 +29,10 @@ class Avatar extends PureComponent {
return (
<Image
source={{uri: this.props.source}}
style={_.union([
style={[
this.props.size === 'small' ? styles.avatarSmall : styles.avatarNormal,
this.props.style,
])}
...this.props.style,
]}
/>
);
}
Expand Down
43 changes: 12 additions & 31 deletions src/components/MultipleAvatars.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,36 @@
import React, {memo} from 'react';
import PropTypes from 'prop-types';
import {Image, Text, View} from 'react-native';
import globalStyles from '../styles/styles';
import styles from '../styles/styles';
import Avatar from './Avatar';

const propTypes = {
// Array of avatar URL
avatarImageURLs: PropTypes.arrayOf(PropTypes.string),

// 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 Second Avatar
// eslint-disable-next-line react/forbid-prop-types
secondAvatarStyle: PropTypes.arrayOf(PropTypes.object),

// Style for avatar Container
// eslint-disable-next-line react/forbid-prop-types
emptyAvatar: PropTypes.object,
}),
};

const defaultProps = {
avatarImageURLs: [],
optionIsFocused: false,
size: 'default',
styles: {},
secondAvatarStyle: [styles.secondAvatarHovered],
};

const MultipleAvatars = ({
avatarImageURLs, optionIsFocused, size, styles,
avatarImageURLs, size, secondAvatarStyle,
}) => {
const avatarContainerStyles = [
size === 'small' ? globalStyles.emptyAvatarSmall : globalStyles.emptyAvatar, styles.emptyAvatar,
];
const singleAvatarStyles = [
size === 'small' ? globalStyles.singleAvatarSmall : globalStyles.singleAvatar, styles.singleAvatar,
];
const avatarContainerStyles = size === 'small' ? styles.emptyAvatarSmall : styles.emptyAvatar;
const singleAvatarStyles = size === 'small' ? styles.singleAvatarSmall : styles.singleAvatar;
const secondAvatarStyles = [
size === 'small' ? globalStyles.secondAvatarSmall : globalStyles.secondAvatar,
optionIsFocused ? globalStyles.focusedAvatar : globalStyles.avatar,
styles.secondAvatar,
size === 'small' ? styles.secondAvatarSmall : styles.secondAvatar,
...secondAvatarStyle,
];

if (!avatarImageURLs.length) {
Expand Down Expand Up @@ -86,8 +67,8 @@ const MultipleAvatars = ({
style={singleAvatarStyles}
>
<Text style={size === 'small'
? globalStyles.avatarInnerTextSmall
: globalStyles.avatarInnerText}
? styles.avatarInnerTextSmall
: styles.avatarInnerText}
>
{`+${avatarImageURLs.length - 1}`}
</Text>
Expand Down
5 changes: 5 additions & 0 deletions src/components/OptionsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import optionPropTypes from './optionPropTypes';
import SectionList from './SectionList';

const propTypes = {
// option Background Color
optionBackgroundColor: PropTypes.string,

// Style for hovered state
// eslint-disable-next-line react/forbid-prop-types
optionHoveredStyle: PropTypes.object,
Expand Down Expand Up @@ -71,6 +74,7 @@ const propTypes = {
};

const defaultProps = {
optionBackgroundColor: undefined,
optionHoveredStyle: undefined,
contentContainerStyles: [],
sections: [],
Expand Down Expand Up @@ -153,6 +157,7 @@ class OptionsList extends Component {
option={item}
mode={this.props.optionMode}
showTitleTooltip={this.props.showTitleTooltip}
backgroundColor={this.props.optionBackgroundColor}
hoverStyle={this.props.optionHoveredStyle}
optionIsFocused={!this.props.disableFocusOptions
&& this.props.focusedIndex === (index + section.indexOffset)}
Expand Down
5 changes: 4 additions & 1 deletion src/pages/home/HeaderView.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ const HeaderView = (props) => {
}}
style={[styles.flexRow, styles.alignItemsCenter, styles.flex1]}
>
<MultipleAvatars avatarImageURLs={props.report.icons} />
<MultipleAvatars
avatarImageURLs={props.report.icons}
secondAvatarStyle={[styles.secondAvatarHovered]}
/>
<View style={[styles.flex1, styles.flexRow]}>
<OptionRowTitle
option={reportOption}
Expand Down
16 changes: 4 additions & 12 deletions src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,16 @@ class ReportActionCompose extends React.Component {
this.comment = props.comment;

this.state = {
isFocused: false,
isFocused: true,
textInputShouldClear: false,
isCommentEmpty: props.comment.length === 0,
isMenuVisible: false,
};
}

componentDidUpdate(prevProps) {
// The first time the component loads the props is empty and the next time it may contain value.
// If it does let's update this.comment so that it matches the defaultValue that we show in textInput.
if (this.props.comment && prevProps.comment === '' && prevProps.comment !== this.props.comment) {
this.comment = this.props.comment;
}

// When any modal goes from visible to hidden or when the report ID changes, bring focus to the compose field
if (
(prevProps.modal.isVisible && !this.props.modal.isVisible)
|| (prevProps.reportID !== this.props.reportID)
) {
// When any modal goes from visible to hidden, bring focus to the compose field
if (prevProps.modal.isVisible && !this.props.modal.isVisible) {
this.setIsFocused(true);
}
}
Expand Down Expand Up @@ -255,6 +246,7 @@ class ReportActionCompose extends React.Component {
)}
</AttachmentPicker>
<TextInputFocusable
autoFocus
multiline
ref={el => this.textInput = el}
textAlignVertical="top"
Expand Down
1 change: 1 addition & 0 deletions src/pages/home/report/ReportView.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class ReportView extends React.Component {
<ReportActionCompose
onSubmit={text => addAction(this.props.reportID, text)}
reportID={this.props.reportID}
key={this.props.reportID}
/>
</SwipeableView>
<KeyboardSpacer />
Expand Down
26 changes: 17 additions & 9 deletions src/pages/home/sidebar/OptionRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
View,
StyleSheet,
} from 'react-native';
import styles from '../../../styles/styles';
import styles, {getSecondAvatarStyle} from '../../../styles/styles';
import {optionPropTypes} from './optionPropTypes';
import Icon from '../../../components/Icon';
import {Pencil, PinCircle, Checkmark} from '../../../components/Icon/Expensicons';
Expand All @@ -16,8 +16,12 @@ import themeColors from '../../../styles/themes/default';
import Hoverable from '../../../components/Hoverable';
import OptionRowTitle from './OptionRowTitle';
import IOUBadge from '../../../components/IOUBadge';
import colors from '../../../styles/colors';

const propTypes = {
// Background Color of the Option Row
backgroundColor: PropTypes.string,

// Style for hovered state
// eslint-disable-next-line react/forbid-prop-types
hoverStyle: PropTypes.object,
Expand Down Expand Up @@ -51,6 +55,7 @@ const propTypes = {
};

const defaultProps = {
backgroundColor: colors.white,
hoverStyle: styles.sidebarLinkHover,
hideAdditionalOptionStates: false,
showSelectedState: false,
Expand All @@ -61,6 +66,7 @@ const defaultProps = {
};

const OptionRow = ({
backgroundColor,
hoverStyle,
option,
optionIsFocused,
Expand Down Expand Up @@ -99,7 +105,10 @@ const OptionRow = ({
styles.sidebarInnerRow,
styles.justifyContentCenter,
]);

const hoveredBackgroundColor = hoverStyle && hoverStyle.backgroundColor
? hoverStyle.backgroundColor
: backgroundColor;
const focusedBackgroundColor = styles.sidebarLinkActive.backgroundColor;
return (
<Hoverable>
{hovered => (
Expand All @@ -112,6 +121,7 @@ const OptionRow = ({
styles.justifyContentBetween,
styles.sidebarLink,
styles.sidebarLinkInner,
{backgroundColor},
optionIsFocused ? styles.sidebarLinkActive : null,
hovered && !optionIsFocused ? hoverStyle : null,
]}
Expand All @@ -128,14 +138,12 @@ const OptionRow = ({
&& (
<MultipleAvatars
avatarImageURLs={option.icons}
optionIsFocused={optionIsFocused}
size={mode === 'compact' ? 'small' : 'default'}
styles={(hovered && !optionIsFocused) ? {
secondAvatar: {
backgroundColor: themeColors.sidebarHover,
borderColor: themeColors.sidebarHover,
},
} : undefined}
secondAvatarStyle={[
getSecondAvatarStyle(backgroundColor),
optionIsFocused && getSecondAvatarStyle(focusedBackgroundColor),
hovered && !optionIsFocused && getSecondAvatarStyle(hoveredBackgroundColor),
]}
/>
)
}
Expand Down
2 changes: 2 additions & 0 deletions src/pages/home/sidebar/SidebarLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {getDefaultAvatar} from '../../../libs/actions/PersonalDetails';
import KeyboardSpacer from '../../../components/KeyboardSpacer';
import CONST from '../../../CONST';
import {participantPropTypes} from './optionPropTypes';
import themeColors from '../../../styles/themes/default';

const propTypes = {
// Toggles the navigation menu open and closed
Expand Down Expand Up @@ -145,6 +146,7 @@ class SidebarLinks extends React.Component {
Navigation.navigate(ROUTES.getReportRoute(option.reportID));
this.props.onLinkClick();
}}
optionBackgroundColor={themeColors.sidebar}
hideSectionHeaders
showTitleTooltip
disableFocusOptions={this.props.isSmallScreenWidth}
Expand Down
16 changes: 14 additions & 2 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,11 @@ const styles = {
borderColor: 'transparent',
},

secondAvatarHovered: {
backgroundColor: themeColors.sidebarHover,
borderColor: themeColors.sidebarHover,
},

secondAvatarSmall: {
position: 'absolute',
right: -13,
Expand Down Expand Up @@ -915,8 +920,8 @@ const styles = {
},

focusedAvatar: {
backgroundColor: themeColors.pillBG,
borderColor: themeColors.pillBG,
backgroundColor: themeColors.border,
borderColor: themeColors.border,
},

emptyAvatar: {
Expand Down Expand Up @@ -1405,6 +1410,12 @@ function getZoomSizingStyle(isZoomed) {
};
}

function getSecondAvatarStyle(parentBGColor) {
return {
backgroundColor: parentBGColor,
borderColor: parentBGColor,
};
}
export default styles;
export {
getSafeAreaPadding,
Expand All @@ -1415,4 +1426,5 @@ export {
getNavigationModalCardStyle,
getZoomCursorStyle,
getZoomSizingStyle,
getSecondAvatarStyle,
};

0 comments on commit b140d36

Please sign in to comment.