Skip to content

Commit

Permalink
Use quotation marks
Browse files Browse the repository at this point in the history
  • Loading branch information
JosueEchandiaAsto committed Jun 28, 2022
1 parent 431727a commit 75e4731
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 31 deletions.
45 changes: 23 additions & 22 deletions src/pages/settings/Payments/PaymentMethodList.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,23 +151,6 @@ class PaymentMethodList extends Component {
});
}

if (!this.props.shouldShowAddPaymentMethodButton) {
return combinedPaymentMethods;
}

combinedPaymentMethods.push({
type: BUTTON,
text: this.props.translate('paymentMethodList.addPaymentMethod'),
icon: Expensicons.CreditCard,
style: [styles.mh4],
iconStyles: [styles.mr4],
onPress: e => this.props.onPress(e),
isDisabled: this.props.isLoadingPayments,
shouldShowRightIcon: true,
success: true,
key: 'addPaymentMethodButton',
});

return combinedPaymentMethods;
}

Expand Down Expand Up @@ -235,11 +218,29 @@ class PaymentMethodList extends Component {

render() {
return (
<FlatList
data={this.createPaymentMethodList()}
renderItem={this.renderItem}
keyExtractor={item => item.key}
/>
<>
<FlatList
bounces={false}
data={this.createPaymentMethodList()}
renderItem={this.renderItem}
keyExtractor={item => item.key}
/>
{
this.props.shouldShowAddPaymentMethodButton
&& (
<Button
text={this.props.translate('paymentMethodList.addPaymentMethod')}
icon={Expensicons.CreditCard}
onPress={e => this.props.onPress(e)}
isDisabled={this.props.isLoadingPayments}
style={[styles.mb4, styles.mh4]}
success
shouldShowRightIco
extraLarge
/>
)
}
</>
);
}
}
Expand Down
37 changes: 28 additions & 9 deletions src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class BasePaymentsPage extends React.Component {
selectedPaymentMethod: {},
formattedSelectedPaymentMethod: {},
anchorPositionTop: 0,
anchorPositionLeft: 0,
anchorPositionBottom: 0,
anchorPositionRigth: 0,
addPaymentMethodButton: null,
};

Expand Down Expand Up @@ -109,10 +110,24 @@ class BasePaymentsPage extends React.Component {
*/
setPositionAddPaymentMenu(position) {
this.setState({
anchorPositionTop: position.bottom,
anchorPositionTop: position.top + position.height,

// We want the position to be 13px to the right of the left border
anchorPositionLeft: position.left + 13,
anchorPositionRigth: (window.innerWidth - position.right) + 13,
});
}

/**
* Set position of the payment method menu
*
* @param {Object} position
*/
setPositionAddPaymentMethod(position) {
this.setState({
anchorPositionBottom: window.innerHeight - position.top,

// We want the position to be 5px to the right of the left border
anchorPositionRigth: (window.innerWidth - position.right) + 5,
});
}

Expand All @@ -129,6 +144,8 @@ class BasePaymentsPage extends React.Component {
this.setState({
addPaymentMethodButton: nativeEvent,
});

// The delete/default menu
if (accountType) {
let formattedSelectedPaymentMethod;
if (accountType === CONST.PAYMENT_METHODS.PAYPAL) {
Expand Down Expand Up @@ -166,7 +183,9 @@ class BasePaymentsPage extends React.Component {
this.setState({
shouldShowAddPaymentMenu: true,
});
this.setPositionAddPaymentMenu(position);

// Add payment method menu
this.setPositionAddPaymentMethod(position);
}

/**
Expand Down Expand Up @@ -305,8 +324,8 @@ class BasePaymentsPage extends React.Component {
isVisible={this.state.shouldShowAddPaymentMenu}
onClose={this.hideAddPaymentMenu}
anchorPosition={{
top: this.state.anchorPositionTop,
left: this.state.anchorPositionLeft,
bottom: this.state.anchorPositionBottom,
right: this.state.anchorPositionRigth,
}}
onItemSelected={method => this.addPaymentMethodTypePressed(method)}
/>
Expand All @@ -315,7 +334,7 @@ class BasePaymentsPage extends React.Component {
onClose={this.hideDefaultDeleteMenu}
anchorPosition={{
top: this.state.anchorPositionTop,
left: this.state.anchorPositionLeft,
right: this.state.anchorPositionRigth,
}}
>
<View
Expand Down Expand Up @@ -388,7 +407,7 @@ class BasePaymentsPage extends React.Component {
onClose={this.hidePasswordPrompt}
anchorPosition={{
top: this.state.anchorPositionTop,
left: this.state.anchorPositionLeft,
right: this.state.anchorPositionRigth,
}}
onSubmit={(password) => {
this.hidePasswordPrompt();
Expand All @@ -406,7 +425,7 @@ class BasePaymentsPage extends React.Component {
cancelText={this.props.translate('common.cancel')}
anchorPosition={{
top: this.state.anchorPositionTop,
left: this.state.anchorPositionLeft,
right: this.state.anchorPositionRigth,
}}
onConfirm={() => {
this.setState({
Expand Down

0 comments on commit 75e4731

Please sign in to comment.