Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
103 changes: 49 additions & 54 deletions src/pages/iou/request/step/IOURequestStepDestination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import Button from '@components/Button';
import DestinationPicker from '@components/DestinationPicker';
import FixedFooter from '@components/FixedFooter';
import * as Illustrations from '@components/Icon/Illustrations';
import ScreenWrapper from '@components/ScreenWrapper';
import type {ListItem} from '@components/SelectionListWithSections/types';
import WorkspaceEmptyStateSection from '@components/WorkspaceEmptyStateSection';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
Expand Down Expand Up @@ -144,62 +143,58 @@ function IOURequestStepDestination({
const keyboardVerticalOffset = openedFromStartPage ? variables.contentHeaderHeight + top + variables.tabSelectorButtonHeight + variables.tabSelectorButtonPadding : 0;

return (
<ScreenWrapper
includePaddingTop={false}
<StepScreenWrapper
headerTitle={backTo ? translate('common.destination') : tabTitles[iouType]}
onBackButtonPress={navigateBack}
shouldShowWrapper
shouldShowNotFoundPage={shouldShowNotFoundPage}
testID={IOURequestStepDestination.displayName}
keyboardVerticalOffset={keyboardVerticalOffset}
testID={`${IOURequestStepDestination.displayName}-container`}
shouldShowHeader={!openedFromStartPage}
>
<StepScreenWrapper
headerTitle={backTo ? translate('common.destination') : tabTitles[iouType]}
onBackButtonPress={navigateBack}
shouldShowWrapper={!openedFromStartPage}
shouldShowNotFoundPage={shouldShowNotFoundPage}
testID={IOURequestStepDestination.displayName}
>
{isLoading && (
<ActivityIndicator
size={CONST.ACTIVITY_INDICATOR_SIZE.LARGE}
style={[styles.flex1]}
{isLoading && (
<ActivityIndicator
size={CONST.ACTIVITY_INDICATOR_SIZE.LARGE}
style={[styles.flex1]}
/>
)}
{shouldShowOfflineView && <FullPageOfflineBlockingView>{null}</FullPageOfflineBlockingView>}
{shouldShowEmptyState && (
<View style={[styles.flex1]}>
<WorkspaceEmptyStateSection
shouldStyleAsCard={false}
icon={Illustrations.EmptyStateExpenses}
title={translate('workspace.perDiem.emptyList.title')}
subtitle={translate('workspace.perDiem.emptyList.subtitle')}
containerStyle={[styles.flex1, styles.justifyContentCenter]}
/>
)}
{shouldShowOfflineView && <FullPageOfflineBlockingView>{null}</FullPageOfflineBlockingView>}
{shouldShowEmptyState && (
<View style={[styles.flex1]}>
<WorkspaceEmptyStateSection
shouldStyleAsCard={false}
icon={Illustrations.EmptyStateExpenses}
title={translate('workspace.perDiem.emptyList.title')}
subtitle={translate('workspace.perDiem.emptyList.subtitle')}
containerStyle={[styles.flex1, styles.justifyContentCenter]}
/>
{isPolicyAdmin(policy) && !!policy?.areCategoriesEnabled && (
<FixedFooter style={[styles.mtAuto, styles.pt5]}>
<Button
large
success
style={[styles.w100]}
onPress={() => {
// eslint-disable-next-line @typescript-eslint/no-deprecated
InteractionManager.runAfterInteractions(() => {
Navigation.navigate(ROUTES.WORKSPACE_PER_DIEM.getRoute(policy.id, Navigation.getActiveRoute()));
});
}}
text={translate('workspace.perDiem.editPerDiemRates')}
pressOnEnter
/>
</FixedFooter>
)}
</View>
)}
{!shouldShowEmptyState && !isLoading && !shouldShowOfflineView && !!policy?.id && (
<DestinationPicker
selectedDestination={selectedDestination}
policyID={policy.id}
onSubmit={updateDestination}
/>
)}
</StepScreenWrapper>
</ScreenWrapper>
{isPolicyAdmin(policy) && !!policy?.areCategoriesEnabled && (
<FixedFooter style={[styles.mtAuto, styles.pt5]}>
<Button
large
success
style={[styles.w100]}
onPress={() => {
// eslint-disable-next-line @typescript-eslint/no-deprecated
InteractionManager.runAfterInteractions(() => {
Navigation.navigate(ROUTES.WORKSPACE_PER_DIEM.getRoute(policy.id, Navigation.getActiveRoute()));
});
}}
text={translate('workspace.perDiem.editPerDiemRates')}
pressOnEnter
/>
</FixedFooter>
)}
</View>
)}
{!shouldShowEmptyState && !isLoading && !shouldShowOfflineView && !!policy?.id && (
<DestinationPicker
selectedDestination={selectedDestination}
policyID={policy.id}
onSubmit={updateDestination}
/>
)}
</StepScreenWrapper>
);
}

Expand Down
18 changes: 14 additions & 4 deletions src/pages/iou/request/step/StepScreenWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ type StepScreenWrapperProps = {

/** Flag to indicate if the keyboard avoiding view should be enabled */
shouldEnableKeyboardAvoidingView?: boolean;
keyboardVerticalOffset?: number;
includePaddingTop?: boolean;
shouldShowHeader?: boolean;
};

function StepScreenWrapper({
Expand All @@ -52,6 +55,9 @@ function StepScreenWrapper({
includeSafeAreaPaddingBottom,
shouldShowOfflineIndicator = true,
shouldEnableKeyboardAvoidingView = true,
includePaddingTop = true,
keyboardVerticalOffset = 0,
shouldShowHeader = true,
}: StepScreenWrapperProps) {
const styles = useThemeStyles();

Expand All @@ -67,14 +73,18 @@ function StepScreenWrapper({
shouldEnableMaxHeight={canUseTouchScreen()}
shouldShowOfflineIndicator={shouldShowOfflineIndicator}
shouldEnableKeyboardAvoidingView={shouldEnableKeyboardAvoidingView}
keyboardVerticalOffset={keyboardVerticalOffset}
includePaddingTop={includePaddingTop}
>
{({insets, safeAreaPaddingBottomStyle, didScreenTransitionEnd}) => (
<FullPageNotFoundView shouldShow={shouldShowNotFoundPage}>
<View style={[styles.flex1]}>
<HeaderWithBackButton
title={headerTitle}
onBackButtonPress={onBackButtonPress}
/>
{shouldShowHeader && (
<HeaderWithBackButton
title={headerTitle}
onBackButtonPress={onBackButtonPress}
/>
)}
{
// If props.children is a function, call it to provide the insets to the children
callOrReturn(children, {insets, safeAreaPaddingBottomStyle, didScreenTransitionEnd})
Expand Down