Skip to content
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

Add Push-to-Page support for IOUConfirmationList #16919

Merged
merged 26 commits into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f57b97f
Aesthetic changes to IOUConfirmationList for manual requests
yuwenmemon Apr 3, 2023
a453d1e
Repurpose style prop for menuitem to apply to pressable
yuwenmemon Apr 4, 2023
11df2c7
Fix conflcits:
yuwenmemon Apr 7, 2023
c6d4fca
Add push to page support for amount field
yuwenmemon Apr 8, 2023
5e16bf5
Add description page for IOU requests
yuwenmemon Apr 8, 2023
31ab836
JSX linting
yuwenmemon Apr 10, 2023
268459c
Add some comments
yuwenmemon Apr 10, 2023
bf026c1
ESLint
yuwenmemon Apr 10, 2023
49116c3
Merge branch 'main' of github.com:Expensify/App into yuwen-pushToPage…
yuwenmemon Apr 10, 2023
8c5df5e
Merge branch 'main' of github.com:Expensify/App into yuwen-pushToPage…
yuwenmemon Apr 11, 2023
a295dd8
use Description instead of whats it for?
yuwenmemon Apr 11, 2023
3055e18
IOU -> MoneyRequest
yuwenmemon Apr 11, 2023
f61412d
WhatsItFor label
yuwenmemon Apr 11, 2023
8f5e22a
PR comments
yuwenmemon Apr 12, 2023
8a1535c
Merge branch 'main' of github.com:Expensify/App into yuwen-pushToPage…
yuwenmemon Apr 14, 2023
33248d0
More Changes from IOU -> MoneyRequest
yuwenmemon Apr 14, 2023
90ef6f9
Make onChangeText no longer required
yuwenmemon Apr 14, 2023
eb64a35
Add some polish to the pushed amount step when it comes from the conf…
yuwenmemon Apr 14, 2023
30a3615
Add close button
yuwenmemon Apr 14, 2023
d501b2b
Remove unneeded props
yuwenmemon Apr 14, 2023
361b208
JS Lint
yuwenmemon Apr 14, 2023
a9b8876
Fix conflicts
yuwenmemon Apr 14, 2023
b999d1c
Fix more bugs related to change of name in main
yuwenmemon Apr 14, 2023
b57f261
JS Linting
yuwenmemon Apr 14, 2023
c8c9974
Make amount 'edit' feel similar to description
yuwenmemon Apr 14, 2023
26a177e
Hooky hooky hooks
yuwenmemon Apr 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ONYXKEYS.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export default {
HOME_ADDRESS_FORM: 'homeAddressForm',
NEW_ROOM_FORM: 'newRoomForm',
ROOM_SETTINGS_FORM: 'roomSettingsForm',
MONEY_REQUEST_DESCRIPTION_FORM: 'moneyRequestDescriptionForm',
},

// Whether we should show the compose input or not
Expand Down
1 change: 1 addition & 0 deletions src/ROUTES.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export default {
getIOUSendRoute: reportID => `${IOU_SEND}/${reportID}`,
IOU_BILL_CURRENCY: `${IOU_BILL_CURRENCY}/:reportID?`,
IOU_REQUEST_CURRENCY: `${IOU_REQUEST_CURRENCY}/:reportID?`,
MONEY_REQUEST_DESCRIPTION: `${IOU_REQUEST}/description`,
IOU_SEND_CURRENCY: `${IOU_SEND_CURRENCY}/:reportID?`,
IOU_SEND_ADD_BANK_ACCOUNT: `${IOU_SEND}/add-bank-account`,
IOU_SEND_ADD_DEBIT_CARD: `${IOU_SEND}/add-debit-card`,
Expand Down
9 changes: 5 additions & 4 deletions src/components/MenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const defaultProps = {
shouldShowBasicTitle: false,
shouldShowDescriptionOnTop: false,
wrapperStyle: [],
style: {},
style: styles.popoverMenuItem,
titleStyle: {},
success: false,
icon: undefined,
iconWidth: undefined,
Expand Down Expand Up @@ -59,15 +60,15 @@ const MenuItem = (props) => {
(props.shouldShowBasicTitle ? undefined : styles.textStrong),
(props.interactive && props.disabled ? {...styles.disabledText, ...styles.userSelectNone} : undefined),
styles.pre,
], props.style);
], props.titleStyle);
const descriptionVerticalMargin = props.shouldShowDescriptionOnTop ? styles.mb1 : styles.mt1;
const descriptionTextStyle = StyleUtils.combineStyles([
styles.textLabelSupporting,
(props.icon ? styles.ml3 : undefined),
styles.breakWord,
styles.lineHeightNormal,
props.title ? descriptionVerticalMargin : undefined,
], props.style);
]);

return (
<Pressable
Expand All @@ -83,7 +84,7 @@ const MenuItem = (props) => {
props.onPress(e);
}}
style={({hovered, pressed}) => ([
styles.popoverMenuItem,
props.style,
StyleUtils.getButtonBackgroundColorStyle(getButtonState(props.focused || hovered, pressed, props.success, props.disabled, props.interactive), true),
..._.isArray(props.wrapperStyle) ? props.wrapperStyle : [props.wrapperStyle],
])}
Expand Down
51 changes: 31 additions & 20 deletions src/components/MoneyRequestConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import SettlementButton from './SettlementButton';
import ROUTES from '../ROUTES';
import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsPropTypes, withCurrentUserPersonalDetailsDefaultProps} from './withCurrentUserPersonalDetails';
import * as IOUUtils from '../libs/IOUUtils';
import MenuItemWithTopDescription from './MenuItemWithTopDescription';
import Navigation from '../libs/Navigation/Navigation';
import optionPropTypes from './optionPropTypes';

const propTypes = {
Expand All @@ -25,12 +27,6 @@ const propTypes = {
/** Callback to parent modal to send money */
onSendMoney: PropTypes.func.isRequired,

/** Callback to update comment from MoneyRequestModal */
onUpdateComment: PropTypes.func,

/** Comment value from MoneyRequestModal */
comment: PropTypes.string,

/** Should we request a single or multiple participant selection from user */
hasMultipleParticipants: PropTypes.bool.isRequired,

Expand Down Expand Up @@ -68,14 +64,15 @@ const propTypes = {
session: PropTypes.shape({
email: PropTypes.string.isRequired,
}),

/** Callback function to navigate to a provided step in the MoneyRequestModal flow */
navigateToStep: PropTypes.func.isRequired,
};

const defaultProps = {
iou: {
selectedCurrencyCode: CONST.CURRENCY.USD,
},
onUpdateComment: null,
comment: '',
iouType: CONST.IOU.MONEY_REQUEST_TYPE.REQUEST,
canModifyParticipants: false,
session: {
Expand Down Expand Up @@ -193,12 +190,7 @@ class MoneyRequestConfirmationList extends Component {
indexOffset: 1,
});
} else {
const formattedParticipants = OptionsListUtils.getIOUConfirmationOptionsFromParticipants(this.props.participants,
this.props.numberFormat(this.props.iouAmount, {
style: 'currency',
currency: this.props.iou.selectedCurrencyCode,
}));

const formattedParticipants = this.getParticipantsWithoutAmount(this.props.participants);
sections.push({
title: this.props.translate('common.to'),
data: formattedParticipants,
Expand Down Expand Up @@ -272,24 +264,25 @@ class MoneyRequestConfirmationList extends Component {
const shouldDisableButton = selectedParticipants.length === 0;
const recipient = this.state.participants[0];
const canModifyParticipants = this.props.canModifyParticipants && this.props.hasMultipleParticipants;
const formattedAmount = this.props.numberFormat(this.props.iouAmount, {
style: 'currency',
currency: this.props.iou.selectedCurrencyCode,
});

return (
<OptionsSelector
sections={this.getSections()}
value={this.props.comment}
value=""
onSelectRow={canModifyParticipants ? this.toggleOption : undefined}
onConfirmSelection={this.confirm}
onChangeText={this.props.onUpdateComment}
textInputLabel={this.props.translate('moneyRequestConfirmationList.whatsItFor')}
placeholderText={this.props.translate('common.optional')}
selectedOptions={this.getSelectedOptions()}
canSelectMultipleOptions={canModifyParticipants}
disableArrowKeysActions={!canModifyParticipants}
isDisabled={!canModifyParticipants}
boldStyle
autoFocus
shouldDelayFocus
shouldTextInputAppearBelowOptions
shouldShowTextInput={false}
optionHoveredStyle={canModifyParticipants ? styles.hoveredComponentBG : {}}
footerContent={shouldShowSettlementButton
? (
Expand All @@ -309,7 +302,25 @@ class MoneyRequestConfirmationList extends Component {
options={this.getSplitOrRequestOptions()}
/>
)}
/>
>
<MenuItemWithTopDescription
shouldShowRightIcon
title={formattedAmount}
description={this.props.translate('iou.amount')}
interactive={false} // This is so the menu item's background doesn't change color on hover
onPress={() => this.props.navigateToStep(0)}
style={styles.moneyRequestMenuItem}
titleStyle={styles.moneyRequestConfirmationAmount}
/>
<MenuItemWithTopDescription
shouldShowRightIcon
title={this.props.iou.comment}
description={this.props.translate('common.description')}
interactive={false} // This is so the menu item's background doesn't change color on hover
onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_DESCRIPTION)}
style={styles.moneyRequestMenuItem}
/>
</OptionsSelector>
);
}
}
Expand Down
18 changes: 11 additions & 7 deletions src/components/OptionsSelector/BaseOptionsSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,12 @@ class BaseOptionsSelector extends Component {
return;
}

if (this.props.shouldDelayFocus) {
this.focusTimeout = setTimeout(() => this.textInput.focus(), CONST.ANIMATED_TRANSITION);
} else {
this.textInput.focus();
if (this.props.shouldShowTextInput) {
if (this.props.shouldDelayFocus) {
this.focusTimeout = setTimeout(() => this.textInput.focus(), CONST.ANIMATED_TRANSITION);
} else {
this.textInput.focus();
}
}
}

Expand Down Expand Up @@ -238,7 +240,7 @@ class BaseOptionsSelector extends Component {
*/
selectRow(option, ref) {
return new Promise((resolve) => {
if (this.props.shouldFocusOnSelectRow) {
if (this.props.shouldShowTextInput && this.props.shouldFocusOnSelectRow) {
if (this.relatedTarget && ref === this.relatedTarget) {
this.textInput.focus();
this.relatedTarget = null;
Expand Down Expand Up @@ -328,13 +330,15 @@ class BaseOptionsSelector extends Component {
{optionsList}
</View>
<View style={[styles.ph5, styles.pv5, styles.flexGrow1, styles.flexShrink0]}>
{textInput}
{this.props.children}
{this.props.shouldShowTextInput && textInput}
</View>
</>
) : (
<>
<View style={[styles.ph5, styles.pv3]}>
{textInput}
{this.props.children}
{this.props.shouldShowTextInput && textInput}
</View>
{optionsList}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const propTypes = {
value: PropTypes.string.isRequired,

/** Callback fired when text changes */
onChangeText: PropTypes.func.isRequired,
onChangeText: PropTypes.func,

/** Limits the maximum number of characters that can be entered in input field */
maxLength: PropTypes.number,
Expand Down Expand Up @@ -84,6 +84,9 @@ const propTypes = {
/** If true, the text input will be below the options in the selector, not above. */
shouldTextInputAppearBelowOptions: PropTypes.bool,

/** If false, the text input will not be shown at all. Defaults to true */
shouldShowTextInput: PropTypes.bool,

/** Custom content to display in the footer instead of the default button. */
footerContent: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),

Expand Down Expand Up @@ -125,6 +128,8 @@ const defaultProps = {
shouldHaveOptionSeparator: false,
initiallyFocusedOptionKey: undefined,
maxLength: undefined,
shouldShowTextInput: true,
onChangeText: () => {},
};

export {propTypes, defaultProps};
3 changes: 3 additions & 0 deletions src/components/menuItemPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ const propTypes = {
/** Used to apply offline styles to child text components */
style: stylePropTypes,

/** Used to apply styles specifically to the title */
titleStyle: stylePropTypes,

/** Function to fire when component is pressed */
onPress: PropTypes.func,

Expand Down
1 change: 1 addition & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export default {
yesContinue: 'Yes, continue',
websiteExample: 'e.g. https://www.expensify.com',
zipCodeExampleFormat: ({zipSampleFormat}) => (zipSampleFormat ? `e.g. ${zipSampleFormat}` : ''),
description: 'Description',
},
attachmentPicker: {
cameraPermissionRequired: 'Camera access',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export default {
yesContinue: 'Sí, Continuar',
websiteExample: 'p. ej. https://www.expensify.com',
zipCodeExampleFormat: ({zipSampleFormat}) => (zipSampleFormat ? `p. ej. ${zipSampleFormat}` : ''),
description: 'Descripción',
},
attachmentPicker: {
cameraPermissionRequired: 'Permiso para acceder a la cámara',
Expand Down
7 changes: 7 additions & 0 deletions src/libs/Navigation/AppNavigator/ModalStackNavigators.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ const IOURequestModalStackNavigator = createModalStackNavigator([{
return IOUCurrencySelection;
},
name: 'IOU_Request_Currency',
},
{
getComponent: () => {
const MoneyRequestDescriptionPage = require('../../../pages/iou/MoneyRequestDescriptionPage').default;
return MoneyRequestDescriptionPage;
},
name: 'Money_Request_Description',
}]);

const IOUSendModalStackNavigator = createModalStackNavigator([{
Expand Down
1 change: 1 addition & 0 deletions src/libs/Navigation/linkingConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ export default {
screens: {
IOU_Request_Root: ROUTES.IOU_REQUEST_WITH_REPORT_ID,
IOU_Request_Currency: ROUTES.IOU_REQUEST_CURRENCY,
Money_Request_Description: ROUTES.MONEY_REQUEST_DESCRIPTION,
},
},
IOU_Bill: {
Expand Down
10 changes: 10 additions & 0 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,15 @@ function setIOUSelectedCurrency(selectedCurrencyCode) {
Onyx.merge(ONYXKEYS.IOU, {selectedCurrencyCode});
}

/**
* Sets Money Request description
*
* @param {String} comment
*/
function setMoneyRequestDescription(comment) {
Onyx.merge(ONYXKEYS.IOU, {comment});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we forgot to trim white spaces in the Description comment and it lead to this issue

}

/**
* @param {Number} amount
* @param {String} submitterPayPalMeAddress
Expand Down Expand Up @@ -1002,6 +1011,7 @@ export {
payMoneyRequestElsewhere,
payMoneyRequestViaPaypal,
setIOUSelectedCurrency,
setMoneyRequestDescription,
sendMoneyWithWallet,
payMoneyRequestWithWallet,
};
Loading