Skip to content

Commit

Permalink
Merge pull request #3541 from Expensify/jasper-tappableIouDetailsPreview
Browse files Browse the repository at this point in the history
Make tapping the entire IOU preview component open the IOU Details modal
  • Loading branch information
mountiny authored Jun 11, 2021
2 parents 58e1584 + a37e51c commit 3284a15
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 47 deletions.
1 change: 1 addition & 0 deletions src/components/ReportActionItemIOUAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const ReportActionItemIOUAction = ({
iouReportID={action.originalMessage.IOUReportID}
chatReportID={chatReportID}
onPayButtonPressed={launchDetailsModal}
onPreviewPressed={launchDetailsModal}
/>
)}
</>
Expand Down
98 changes: 51 additions & 47 deletions src/components/ReportActionItemIOUPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
ActivityIndicator,
TouchableOpacity,
Text,
TouchableWithoutFeedback,
} from 'react-native';
import PropTypes from 'prop-types';
import Str from 'expensify-common/lib/str';
Expand Down Expand Up @@ -81,6 +82,7 @@ const ReportActionItemIOUPreview = ({
session,
shouldHidePayButton,
onPayButtonPressed,
onPreviewPressed,
translate,
}) => {
// Usually the parent determines whether the IOU Preview is displayed. But as the iouReport total cannot be known
Expand Down Expand Up @@ -110,56 +112,58 @@ const ReportActionItemIOUPreview = ({
const ownerAvatar = lodashGet(personalDetails, [ownerEmail, 'avatar'], '');
const cachedTotal = iouReport.cachedTotal ? iouReport.cachedTotal.replace(/[()]/g, '') : '';
return (
<View style={styles.iouPreviewBox}>
{reportIsLoading
? <ActivityIndicator style={styles.iouPreviewBoxLoading} color={themeColors.text} />
: (
<View>
<View style={styles.flexRow}>
<View style={styles.flex1}>
<View style={styles.flexRow}>
<Text style={styles.h1}>
{cachedTotal}
</Text>
{!iouReport.hasOutstandingIOU && (
<View style={styles.iouPreviewBoxCheckmark}>
<Icon src={Checkmark} fill={themeColors.iconSuccessFill} />
</View>
)}
<TouchableWithoutFeedback onPress={onPreviewPressed}>
<View style={styles.iouPreviewBox}>
{reportIsLoading
? <ActivityIndicator style={styles.iouPreviewBoxLoading} color={themeColors.text} />
: (
<View>
<View style={styles.flexRow}>
<View style={styles.flex1}>
<View style={styles.flexRow}>
<Text style={styles.h1}>
{cachedTotal}
</Text>
{!iouReport.hasOutstandingIOU && (
<View style={styles.iouPreviewBoxCheckmark}>
<Icon src={Checkmark} fill={themeColors.iconSuccessFill} />
</View>
)}
</View>
</View>
<View style={styles.iouPreviewBoxAvatar}>
<MultipleAvatars
avatarImageURLs={[managerAvatar, ownerAvatar]}
secondAvatarStyle={[styles.secondAvatarInline]}
/>
</View>
</View>
<View style={styles.iouPreviewBoxAvatar}>
<MultipleAvatars
avatarImageURLs={[managerAvatar, ownerAvatar]}
secondAvatarStyle={[styles.secondAvatarInline]}
/>
</View>
</View>
<Text>
{iouReport.hasOutstandingIOU
? translate('iou.owes', {manager: managerName, owner: ownerName})
: translate('iou.paid', {manager: managerName, owner: ownerName})}
</Text>
{(isCurrentUserManager
&& !shouldHidePayButton
&& iouReport.stateNum === CONST.REPORT.STATE_NUM.PROCESSING && (
<TouchableOpacity
style={[styles.buttonSmall, styles.buttonSuccess, styles.mt4]}
onPress={onPayButtonPressed}
>
<Text
style={[
styles.buttonSmallText,
styles.buttonSuccessText,
]}
<Text>
{iouReport.hasOutstandingIOU
? translate('iou.owes', {manager: managerName, owner: ownerName})
: translate('iou.paid', {manager: managerName, owner: ownerName})}
</Text>
{(isCurrentUserManager
&& !shouldHidePayButton
&& iouReport.stateNum === CONST.REPORT.STATE_NUM.PROCESSING && (
<TouchableOpacity
style={[styles.buttonSmall, styles.buttonSuccess, styles.mt4]}
onPress={onPayButtonPressed}
>
{translate('iou.pay')}
</Text>
</TouchableOpacity>
))}
</View>
)}
</View>
<Text
style={[
styles.buttonSmallText,
styles.buttonSuccessText,
]}
>
{translate('iou.pay')}
</Text>
</TouchableOpacity>
))}
</View>
)}
</View>
</TouchableWithoutFeedback>
);
};

Expand Down
1 change: 1 addition & 0 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -1404,6 +1404,7 @@ const styles = {
marginTop: 16,
maxWidth: variables.sideBarWidth,
width: '100%',
cursor: 'pointer',
},

iouPreviewBoxLoading: {
Expand Down

0 comments on commit 3284a15

Please sign in to comment.