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

20354 money request participants selector list refactoring #32692

Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5737385
useEffects refactoring
lukemorawski Nov 29, 2023
fec08cf
logic refactoring
lukemorawski Nov 30, 2023
ddd5695
fixes
lukemorawski Dec 1, 2023
e101119
Merge branch 'main' into 20354-MoneyRequestParticipantsSelector_list_…
lukemorawski Dec 1, 2023
40c3b74
styling fixes
lukemorawski Dec 1, 2023
9c4b4b8
refactored to split button
lukemorawski Dec 6, 2023
e5489e9
ref refactoring
lukemorawski Dec 7, 2023
7bfc447
removed unnecessary import
lukemorawski Dec 7, 2023
c2f869e
removed comment
lukemorawski Dec 7, 2023
f36e36a
Merge branch 'main' into 20354-MoneyRequestParticipantsSelector_list_…
lukemorawski Dec 7, 2023
47812b1
Merge branch 'main' into 20354-MoneyRequestParticipantsSelector_list_…
lukemorawski Dec 8, 2023
ae3ed97
prettier
lukemorawski Dec 8, 2023
3b161c6
iouType from CONST
lukemorawski Dec 8, 2023
e294815
cleaner right hand side component rendering syntax
lukemorawski Dec 8, 2023
8b4d2e5
removed unused prop
lukemorawski Dec 8, 2023
2790197
offline message cleaner syntax
lukemorawski Dec 8, 2023
099049b
Update src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestPa…
lukemorawski Dec 8, 2023
6153e6a
Update src/components/SelectionList/BaseListItem.js
lukemorawski Dec 8, 2023
98ed390
lint
lukemorawski Dec 8, 2023
a9abe8e
removed comment
lukemorawski Dec 11, 2023
1406791
Merge branch 'main' into 20354-MoneyRequestParticipantsSelector_list_…
lukemorawski Dec 12, 2023
9c79b10
moving changes to MoneyTemporaryForRefactorRequestParticipantsSelector
lukemorawski Dec 12, 2023
43ca072
Merge branch 'main' into 20354-MoneyRequestParticipantsSelector_list_…
lukemorawski Dec 13, 2023
c60409d
Merge branch 'main' into 20354-MoneyRequestParticipantsSelector_list_…
lukemorawski Dec 14, 2023
e942f0d
removed doubled imports
lukemorawski Dec 14, 2023
cd96252
Merge branch 'main' into 20354-MoneyRequestParticipantsSelector_list_…
lukemorawski Dec 14, 2023
459b093
removed doubled imports
lukemorawski Dec 14, 2023
0b8701d
fixed useTheme imports
lukemorawski Dec 18, 2023
ad632c4
Merge remote-tracking branch 'origin/20354-MoneyRequestParticipantsSe…
lukemorawski Dec 18, 2023
6eb03d0
memoized list footer and fixed voucher cta padding
lukemorawski Dec 20, 2023
65d2710
send money referral program CTA layout fix
lukemorawski Jan 3, 2024
7a295ba
Merge branch 'main' into 20354-MoneyRequestParticipantsSelector_list_…
lukemorawski Jan 3, 2024
b232142
more refactoring
lukemorawski Jan 3, 2024
936a17d
linting
lukemorawski Jan 3, 2024
6ad3dcd
fix/selecting options upon search
lukemorawski Jan 8, 2024
55b2c46
Merge branch 'main' into 20354-MoneyRequestParticipantsSelector_list_…
lukemorawski Jan 10, 2024
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
9 changes: 7 additions & 2 deletions src/components/SelectionList/BaseListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function BaseListItem({
canSelectMultiple = false,
onSelectRow,
onDismissError = () => {},
rightHandSideComponent,
keyForList,
}) {
const theme = useTheme();
Expand Down Expand Up @@ -62,7 +63,10 @@ function BaseListItem({
]}
>
{canSelectMultiple && (
<View style={StyleUtils.getCheckboxPressableStyle()}>
<View
role={CONST.ACCESSIBILITY_ROLE.BUTTON}
style={StyleUtils.getCheckboxPressableStyle()}
>
<View
style={[
StyleUtils.getCheckboxContainerStyle(20),
Expand Down Expand Up @@ -97,7 +101,7 @@ function BaseListItem({
onSelectRow={onSelectRow}
showTooltip={showTooltip}
/>
{!canSelectMultiple && item.isSelected && (
{!canSelectMultiple && item.isSelected && !rightHandSideComponent && (
<View
style={[styles.flexRow, styles.alignItemsCenter, styles.ml3]}
accessible={false}
Expand All @@ -110,6 +114,7 @@ function BaseListItem({
</View>
</View>
)}
{!canSelectMultiple && !!rightHandSideComponent && typeof rightHandSideComponent === 'function' ? rightHandSideComponent(item) : rightHandSideComponent}
</View>
{Boolean(item.invitedSecondaryLogin) && (
<Text style={[styles.ml9, styles.ph5, styles.pb3, styles.textLabelSupporting]}>
Expand Down
6 changes: 6 additions & 0 deletions src/components/SelectionList/BaseSelectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function BaseSelectionList({
textInputLabel = '',
textInputPlaceholder = '',
textInputValue = '',
textInputHint = '',
textInputMaxLength,
inputMode = CONST.INPUT_MODE.TEXT,
onChangeText,
Expand All @@ -60,6 +61,8 @@ function BaseSelectionList({
children,
shouldStopPropagation = false,
shouldUseDynamicMaxToRenderPerBatch = false,
rightHandSideComponent,
onRightHandSideComponentPress,
}) {
const theme = useTheme();
const styles = useThemeStyles();
Expand Down Expand Up @@ -311,6 +314,8 @@ function BaseSelectionList({
onSelectRow={() => selectRow(item, true)}
onDismissError={onDismissError}
shouldPreventDefaultFocusOnSelectRow={shouldPreventDefaultFocusOnSelectRow}
rightHandSideComponent={rightHandSideComponent}
onRightHandSideComponentPress={onRightHandSideComponentPress}
keyForList={item.keyForList}
/>
);
Expand Down Expand Up @@ -407,6 +412,7 @@ function BaseSelectionList({
}}
label={textInputLabel}
accessibilityLabel={textInputLabel}
hint={textInputHint}
role={CONST.ACCESSIBILITY_ROLE.TEXT}
value={textInputValue}
placeholder={textInputPlaceholder}
Expand Down
5 changes: 4 additions & 1 deletion src/components/SelectionList/selectionListPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const commonListItemPropTypes = {
/** Whether to use the Checkbox (multiple selection) instead of the Checkmark (single selection) */
canSelectMultiple: PropTypes.bool,

/** Callback to fire when the item is pressed */
/** Callback to fire when the item is selected */
onSelectRow: PropTypes.func.isRequired,

/** Callback to fire when an error is dismissed */
Expand Down Expand Up @@ -191,6 +191,9 @@ const propTypes = {

/** Whether to use dynamic maxToRenderPerBatch depending on the visible number of elements */
shouldUseDynamicMaxToRenderPerBatch: PropTypes.bool,

/** Right hand side component to display in the list item. Function has list item passed as the param */
rightHandSideComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
};

export {propTypes, baseListItemPropTypes, radioListItemPropTypes, userListItemPropTypes};
2 changes: 2 additions & 0 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ function getParticipantsOption(participant, personalDetails) {
],
phoneNumber: lodashGet(detail, 'phoneNumber', ''),
selected: participant.selected,
isSelected: participant.selected,
searchText: participant.searchText,
};
}
Expand Down Expand Up @@ -578,6 +579,7 @@ function getPolicyExpenseReportOption(report) {
option.text = ReportUtils.getPolicyName(expenseReport);
option.alternateText = Localize.translateLocal('workspace.common.workspace');
option.selected = report.selected;
option.isSelected = report.selected;
return option;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import _ from 'lodash';
import lodashGet from 'lodash/get';
import lodashSize from 'lodash/size';
import PropTypes from 'prop-types';
import React, {useCallback, useEffect, useRef, useState} from 'react';
import React, {useCallback, useEffect, useMemo, useRef} from 'react';
import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
Expand Down Expand Up @@ -56,36 +56,35 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route, transaction}) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const prevMoneyRequestId = useRef(iou.id);
const optionsSelectorRef = useRef();
const iouType = useInitialValue(() => lodashGet(route, 'params.iouType', ''));
const reportID = useInitialValue(() => lodashGet(route, 'params.reportID', ''));
const isDistanceRequest = MoneyRequestUtils.isDistanceRequest(iouType, selectedTab);
const isSendRequest = iouType === CONST.IOU.TYPE.SEND;
const isScanRequest = MoneyRequestUtils.isScanRequest(selectedTab);
const isSplitRequest = iou.id === CONST.IOU.TYPE.SPLIT;
const [headerTitle, setHeaderTitle] = useState();
const waypoints = lodashGet(transaction, 'comment.waypoints', {});
const validatedWaypoints = TransactionUtils.getValidWaypoints(waypoints);
const isInvalidWaypoint = lodashSize(validatedWaypoints) < 2;
const headerTitle = useMemo(() => {

useEffect(() => {
if (isDistanceRequest) {
setHeaderTitle(translate('common.distance'));
return;
return translate('common.distance');
}

if (isSendRequest) {
setHeaderTitle(translate('common.send'));
return;
return translate('common.send');
}

if (isScanRequest) {
setHeaderTitle(translate('tabSelector.scan'));
return;
return translate('tabSelector.scan');
}

if (iou.isSplitRequest) {
return translate('iou.split');
}

setHeaderTitle(iou.isSplitRequest ? translate('iou.split') : translate('tabSelector.manual'));
}, [iou.isSplitRequest, isDistanceRequest, translate, isScanRequest, isSendRequest]);
return translate('tabSelector.manual');
}, [iou, isDistanceRequest, translate, isScanRequest, isSendRequest]);

const navigateToConfirmationStep = (moneyRequestType) => {
IOU.setMoneyRequestId(moneyRequestType);
Expand Down Expand Up @@ -130,7 +129,6 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route, transaction}) {
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
shouldEnableMaxHeight={DeviceCapabilities.canUseTouchScreen()}
onEntryTransitionEnd={() => optionsSelectorRef.current && optionsSelectorRef.current.focus()}
testID={MoneyRequestParticipantsPage.displayName}
>
{({safeAreaPaddingBottomStyle}) => (
Expand All @@ -140,7 +138,6 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route, transaction}) {
onBackButtonPress={navigateBack}
/>
<MoneyRequestParticipantsSelector
ref={(el) => (optionsSelectorRef.current = el)}
participants={iou.isSplitRequest ? iou.participants : []}
onAddParticipants={IOU.setMoneyRequestParticipants}
navigateToRequest={() => navigateToConfirmationStep(iouType)}
Expand Down
Loading
Loading