Skip to content

Commit

Permalink
move loading modal to outside
Browse files Browse the repository at this point in the history
  • Loading branch information
nkdengineer committed Aug 12, 2024
1 parent f4ce42f commit 3206131
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions src/pages/iou/request/step/IOURequestStepScan/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,6 @@ function IOURequestStepScan({

const mobileCameraView = () => (
<>
{isLoadingReceipt && <FullScreenLoadingIndicator />}
<View style={[styles.cameraView]}>
{PDFThumbnailView}
{((cameraPermissionState === 'prompt' && !isQueriedPermissionState) || (cameraPermissionState === 'granted' && isEmptyObject(videoConstraints))) && (
Expand Down Expand Up @@ -650,7 +649,6 @@ function IOURequestStepScan({

const desktopUploadView = () => (
<>
{isLoadingReceipt && <FullScreenLoadingIndicator />}
{PDFThumbnailView}
<View onLayout={({nativeEvent}) => setReceiptImageTopPosition(PixelRatio.roundToNearestPixel((nativeEvent.layout as DOMRect).top))}>
<ReceiptUpload
Expand Down Expand Up @@ -702,28 +700,31 @@ function IOURequestStepScan({
testID={IOURequestStepScan.displayName}
>
{(isDraggingOverWrapper) => (
<View style={[styles.flex1, !Browser.isMobile() && styles.uploadReceiptView(isSmallScreenWidth)]}>
{!(isDraggingOver ?? isDraggingOverWrapper) && (Browser.isMobile() ? mobileCameraView() : desktopUploadView())}
<ReceiptDropUI
onDrop={(e) => {
const file = e?.dataTransfer?.files[0];
if (file) {
file.uri = URL.createObjectURL(file);
setReceiptAndNavigate(file);
}
}}
receiptImageTopPosition={receiptImageTopPosition}
/>
<ConfirmModal
title={attachmentInvalidReasonTitle ? translate(attachmentInvalidReasonTitle) : ''}
onConfirm={hideRecieptModal}
onCancel={hideRecieptModal}
isVisible={isAttachmentInvalid}
prompt={attachmentInvalidReason ? translate(attachmentInvalidReason) : ''}
confirmText={translate('common.close')}
shouldShowCancelButton={false}
/>
</View>
<>
{isLoadingReceipt && <FullScreenLoadingIndicator />}
<View style={[styles.flex1, !Browser.isMobile() && styles.uploadReceiptView(isSmallScreenWidth)]}>
{!(isDraggingOver ?? isDraggingOverWrapper) && (Browser.isMobile() ? mobileCameraView() : desktopUploadView())}
<ReceiptDropUI
onDrop={(e) => {
const file = e?.dataTransfer?.files[0];
if (file) {
file.uri = URL.createObjectURL(file);
setReceiptAndNavigate(file);
}
}}
receiptImageTopPosition={receiptImageTopPosition}
/>
<ConfirmModal
title={attachmentInvalidReasonTitle ? translate(attachmentInvalidReasonTitle) : ''}
onConfirm={hideRecieptModal}
onCancel={hideRecieptModal}
isVisible={isAttachmentInvalid}
prompt={attachmentInvalidReason ? translate(attachmentInvalidReason) : ''}
confirmText={translate('common.close')}
shouldShowCancelButton={false}
/>
</View>
</>
)}
</StepScreenDragAndDropWrapper>
);
Expand Down

0 comments on commit 3206131

Please sign in to comment.