Skip to content

Commit 0aaed18

Browse files
authored
Merge pull request #24097 from s77rt/no-nested-screenwrappers
[CP Staging] MoneyRequest: use ScreenWrapper only if editing
2 parents 4bcb2d6 + 08bbe41 commit 0aaed18

File tree

1 file changed

+70
-60
lines changed

1 file changed

+70
-60
lines changed

src/pages/iou/steps/MoneyRequestAmount.js

Lines changed: 70 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -419,69 +419,79 @@ function MoneyRequestAmount(props) {
419419
const formattedAmount = replaceAllDigits(amount, toLocaleDigit);
420420
const buttonText = isEditing.current ? translate('common.save') : translate('common.next');
421421

422-
return (
423-
<FullPageNotFoundView shouldShow={!IOUUtils.isValidMoneyRequestType(iouType.current)}>
424-
<ScreenWrapper
425-
includeSafeAreaPaddingBottom={false}
426-
onEntryTransitionEnd={focusTextInput}
422+
const content = (
423+
<>
424+
<View
425+
nativeID={amountViewID}
426+
onMouseDown={(event) => onMouseDown(event, [amountViewID])}
427+
style={[styles.flex1, styles.flexRow, styles.w100, styles.alignItemsCenter, styles.justifyContentCenter]}
428+
>
429+
<TextInputWithCurrencySymbol
430+
formattedAmount={formattedAmount}
431+
onChangeAmount={updateAmount}
432+
onCurrencyButtonPress={navigateToCurrencySelectionPage}
433+
placeholder={numberFormat(0)}
434+
ref={(el) => (textInput.current = el)}
435+
selectedCurrencyCode={selectedCurrencyCode}
436+
selection={selection}
437+
onSelectionChange={(e) => {
438+
if (!shouldUpdateSelection) {
439+
return;
440+
}
441+
setSelection(e.nativeEvent.selection);
442+
}}
443+
/>
444+
</View>
445+
<View
446+
onMouseDown={(event) => onMouseDown(event, [numPadContainerViewID, numPadViewID])}
447+
style={[styles.w100, styles.justifyContentEnd, styles.pageWrapper]}
448+
nativeID={numPadContainerViewID}
427449
>
428-
{({safeAreaPaddingBottomStyle}) => (
450+
{DeviceCapabilities.canUseTouchScreen() ? (
451+
<BigNumberPad
452+
nativeID={numPadViewID}
453+
numberPressed={updateAmountNumberPad}
454+
longPressHandlerStateChanged={updateLongPressHandlerState}
455+
/>
456+
) : (
457+
<View />
458+
)}
459+
460+
<Button
461+
success
462+
style={[styles.w100, styles.mt5]}
463+
onPress={navigateToNextPage}
464+
pressOnEnter
465+
isDisabled={!amount.length || parseFloat(amount) < 0.01}
466+
text={buttonText}
467+
/>
468+
</View>
469+
</>
470+
);
471+
472+
// ScreenWrapper is only needed in edit mode because we have a dedicated route for the edit amount page (MoneyRequestEditAmountPage).
473+
// The rest of the cases this component is rendered through <MoneyRequestSelectorPage /> which has it's own ScreenWrapper
474+
if (!isEditing.current) {
475+
return content;
476+
}
477+
478+
return (
479+
<ScreenWrapper
480+
includeSafeAreaPaddingBottom={false}
481+
onEntryTransitionEnd={focusTextInput}
482+
>
483+
{({safeAreaPaddingBottomStyle}) => (
484+
<FullPageNotFoundView shouldShow={!IOUUtils.isValidMoneyRequestType(iouType.current)}>
429485
<View style={[styles.flex1, safeAreaPaddingBottomStyle]}>
430-
{isEditing.current && (
431-
<HeaderWithBackButton
432-
title={titleForStep}
433-
onBackButtonPress={navigateBack}
434-
/>
435-
)}
436-
<View
437-
nativeID={amountViewID}
438-
onMouseDown={(event) => onMouseDown(event, [amountViewID])}
439-
style={[styles.flex1, styles.flexRow, styles.w100, styles.alignItemsCenter, styles.justifyContentCenter]}
440-
>
441-
<TextInputWithCurrencySymbol
442-
formattedAmount={formattedAmount}
443-
onChangeAmount={updateAmount}
444-
onCurrencyButtonPress={navigateToCurrencySelectionPage}
445-
placeholder={numberFormat(0)}
446-
ref={(el) => (textInput.current = el)}
447-
selectedCurrencyCode={selectedCurrencyCode}
448-
selection={selection}
449-
onSelectionChange={(e) => {
450-
if (!shouldUpdateSelection) {
451-
return;
452-
}
453-
setSelection(e.nativeEvent.selection);
454-
}}
455-
/>
456-
</View>
457-
<View
458-
onMouseDown={(event) => onMouseDown(event, [numPadContainerViewID, numPadViewID])}
459-
style={[styles.w100, styles.justifyContentEnd, styles.pageWrapper]}
460-
nativeID={numPadContainerViewID}
461-
>
462-
{DeviceCapabilities.canUseTouchScreen() ? (
463-
<BigNumberPad
464-
nativeID={numPadViewID}
465-
numberPressed={updateAmountNumberPad}
466-
longPressHandlerStateChanged={updateLongPressHandlerState}
467-
/>
468-
) : (
469-
<View />
470-
)}
471-
472-
<Button
473-
success
474-
style={[styles.w100, styles.mt5]}
475-
onPress={navigateToNextPage}
476-
pressOnEnter
477-
isDisabled={!amount.length || parseFloat(amount) < 0.01}
478-
text={buttonText}
479-
/>
480-
</View>
486+
<HeaderWithBackButton
487+
title={titleForStep}
488+
onBackButtonPress={navigateBack}
489+
/>
490+
{content}
481491
</View>
482-
)}
483-
</ScreenWrapper>
484-
</FullPageNotFoundView>
492+
</FullPageNotFoundView>
493+
)}
494+
</ScreenWrapper>
485495
);
486496
}
487497

0 commit comments

Comments
 (0)