Skip to content

Commit 45f5e38

Browse files
authored
Merge pull request #7374 from parasharrajat/menu-highlight
Highlight the 💳 Payment Method on the PaymentMethod list when its menu is active
2 parents cfb98ff + 459b242 commit 45f5e38

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/pages/settings/Payments/PaymentMethodList.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ const propTypes = {
6060
walletLinkedAccountType: PropTypes.string,
6161
}),
6262

63+
/** Type of active/highlighted payment method */
64+
actionPaymentMethodType: PropTypes.oneOf([..._.values(CONST.PAYMENT_METHODS), '']),
65+
66+
/** ID of active/highlighted payment method */
67+
activePaymentMethodID: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
68+
6369
/** ID of selected payment method */
6470
selectedMethodID: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
6571

@@ -78,6 +84,8 @@ const defaultProps = {
7884
isAddPaymentMenuActive: false,
7985
shouldShowAddPaymentMethodButton: true,
8086
filterType: '',
87+
actionPaymentMethodType: '',
88+
activePaymentMethodID: '',
8189
selectedMethodID: '',
8290
};
8391

@@ -104,6 +112,8 @@ class PaymentMethodList extends Component {
104112
...paymentMethod,
105113
type: MENU_ITEM,
106114
onPress: e => this.props.onPress(e, paymentMethod.accountType, paymentMethod.accountData),
115+
iconFill: this.isPaymentMethodActive(paymentMethod) ? StyleUtils.getIconFillColor(CONST.BUTTON_STATES.PRESSED) : null,
116+
wrapperStyle: this.isPaymentMethodActive(paymentMethod) ? [StyleUtils.getButtonBackgroundColorStyle(CONST.BUTTON_STATES.PRESSED)] : null,
107117
}));
108118

109119
// If we have not added any payment methods, show a default empty state
@@ -132,6 +142,16 @@ class PaymentMethodList extends Component {
132142
return combinedPaymentMethods;
133143
}
134144

145+
/**
146+
* @param {Object} paymentMethod
147+
* @param {String|Number} paymentMethod.methodID
148+
* @param {String} paymentMethod.accountType
149+
* @return {Boolean}
150+
*/
151+
isPaymentMethodActive(paymentMethod) {
152+
return paymentMethod.accountType === this.props.actionPaymentMethodType && paymentMethod.methodID === this.props.activePaymentMethodID;
153+
}
154+
135155
/**
136156
* Create a menuItem for each passed paymentMethod
137157
*

src/pages/settings/Payments/PaymentsPage.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,18 @@ class PaymentsPage extends React.Component {
8282
PaymentMethods.getPaymentMethods();
8383
}
8484

85+
getSelectedPaymentMethodID() {
86+
if (this.state.selectedPaymentMethodType === CONST.PAYMENT_METHODS.PAYPAL) {
87+
return CONST.PAYMENT_METHODS.PAYPAL;
88+
}
89+
if (this.state.selectedPaymentMethodType === CONST.PAYMENT_METHODS.BANK_ACCOUNT) {
90+
return this.state.selectedPaymentMethod.bankAccountID;
91+
}
92+
if (this.state.selectedPaymentMethodType === CONST.PAYMENT_METHODS.DEBIT_CARD) {
93+
return this.state.selectedPaymentMethod.fundID;
94+
}
95+
}
96+
8597
/**
8698
* Display the delete/default menu, or the add payment method menu
8799
*
@@ -247,6 +259,12 @@ class PaymentsPage extends React.Component {
247259
style={[styles.flex4]}
248260
isLoadingPayments={this.props.isLoadingPaymentMethods}
249261
isAddPaymentMenuActive={this.state.shouldShowAddPaymentMenu}
262+
actionPaymentMethodType={this.state.shouldShowDefaultDeleteMenu || this.state.shouldShowPasswordPrompt || this.state.shouldShowConfirmPopover
263+
? this.state.selectedPaymentMethodType
264+
: ''}
265+
activePaymentMethodID={this.state.shouldShowDefaultDeleteMenu || this.state.shouldShowPasswordPrompt || this.state.shouldShowConfirmPopover
266+
? this.getSelectedPaymentMethodID()
267+
: ''}
250268
/>
251269
</View>
252270
<AddPaymentMethodMenu

0 commit comments

Comments
 (0)