From 7ba64ea55304a3aa853cf00ef321e00d75b5763b Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Thu, 23 Jun 2022 09:16:54 -0700 Subject: [PATCH] 1.3.7-2 - Test Build - Added progress for fetching file size. --- app.json | 6 +- .../screen-main/screen-main.component.jsx | 1 - .../screen-splash/screen-splash.component.jsx | 5 +- .../upload-progress.component.jsx | 70 ++++++++++++------- 4 files changed, 52 insertions(+), 30 deletions(-) diff --git a/app.json b/app.json index 5fa8264..efd10d5 100644 --- a/app.json +++ b/app.json @@ -4,19 +4,19 @@ "slug": "imexmobile", "version": "1.3.7", "extra": { - "expover": "1" + "expover": "2" }, "orientation": "default", "icon": "./assets/logo192noa.png", "ios": { "supportsTablet": true, "bundleIdentifier": "com.imex.imexmobile", - "buildNumber": "1", + "buildNumber": "2", "googleServicesFile": "./GoogleService-Info.plist" }, "android": { "package": "com.imex.imexmobile", - "versionCode": 1100014, + "versionCode": 1100015, "googleServicesFile": "./google-services.json" }, "splash": { diff --git a/components/screen-main/screen-main.component.jsx b/components/screen-main/screen-main.component.jsx index 07975d2..605a1fd 100644 --- a/components/screen-main/screen-main.component.jsx +++ b/components/screen-main/screen-main.component.jsx @@ -6,7 +6,6 @@ import i18n from "i18next"; import moment from "moment"; import React, { useEffect } from "react"; import { Button } from "react-native-paper"; -import { SafeAreaView } from "react-native-safe-area-context"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { logImEXEvent } from "../../firebase/firebase.analytics"; diff --git a/components/screen-splash/screen-splash.component.jsx b/components/screen-splash/screen-splash.component.jsx index 3b97f8d..0f138d0 100644 --- a/components/screen-splash/screen-splash.component.jsx +++ b/components/screen-splash/screen-splash.component.jsx @@ -1,8 +1,9 @@ import React from "react"; import { useTranslation } from "react-i18next"; import { ActivityIndicator, Image, StyleSheet, View } from "react-native"; -import { Title, Subheading } from "react-native-paper"; +import { Title, Subheading, Divider } from "react-native-paper"; import Logo from "../../assets/logo192.png"; +import SignOutButton from "../sign-out-button/sign-out-button.component"; export default function ScreenSplash({ noAccess }) { const { t } = useTranslation(); @@ -18,6 +19,8 @@ export default function ScreenSplash({ noAccess }) { {t("app.nomobileaccess")} + + ) : ( diff --git a/components/upload-progress/upload-progress.component.jsx b/components/upload-progress/upload-progress.component.jsx index 23ff355..fe25a65 100644 --- a/components/upload-progress/upload-progress.component.jsx +++ b/components/upload-progress/upload-progress.component.jsx @@ -1,7 +1,6 @@ import { useApolloClient } from "@apollo/client"; import * as FileSystem from "expo-file-system"; import * as MediaLibrary from "expo-media-library"; -import _ from "lodash"; import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { @@ -9,12 +8,11 @@ import { Alert, Modal, Platform, - ScrollView, StyleSheet, Text, View, } from "react-native"; -import { ProgressBar } from "react-native-paper"; +import { Divider, ProgressBar } from "react-native-paper"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { logImEXEvent } from "../../firebase/firebase.analytics"; @@ -29,7 +27,6 @@ import { } from "../../redux/user/user.selectors"; import { formatBytes, handleUpload } from "../../util/document-upload.utility"; import Toast from "react-native-toast-message"; -import { validateArgCount } from "@firebase/util"; const mapStateToProps = createStructuredSelector({ currentUser: selectCurrentUser, @@ -122,6 +119,14 @@ export function UploadProgress({ } const onDone = async (selectedFiles) => { + setProgress((progress) => { + return { + ...progress, + uploadInProgress: true, + statusText: "Preparing upload...", + }; + }); + //Validate to make sure the totals for the file sizes do not exceed the total on the job. const data = []; const totalOfUploads = await selectedFiles.reduce(async (acc, val) => { @@ -151,7 +156,7 @@ export function UploadProgress({ ...progress, speed: 0, action: null, - + statusText: null, uploadInProgress: false, })); Alert.alert( @@ -162,21 +167,17 @@ export function UploadProgress({ } } //We made it this far. We have enough space, so let's start uploading. - - setProgress((progress) => { - return { - ...progress, - uploadInProgress: true, - - totalToUpload: totalOfUploads, - totalUploaded: 0, - totalFilesCompleted: 0, - startTime: new Date(), - totalFiles: data.length, - currentFile: null, - files: {}, //uri is the key, value is progress - }; - }); + setProgress((progress) => ({ + ...progress, + totalToUpload: totalOfUploads, + totalUploaded: 0, + totalFilesCompleted: 0, + startTime: new Date(), + totalFiles: data.length, + currentFile: null, + statusText: null, + files: {}, //uri is the key, value is progress + })); for (var i = 0; i < data.length + 4; i = i + 4) { //Reset the files. @@ -264,7 +265,16 @@ export function UploadProgress({ text: "Yes", onPress: () => { setUploads(null); - setProgress(null); + setProgress({ + uploadInProgress: false, + totalToUpload: 0, + totalUploaded: 0, + totalFilesCompleted: 0, + startTime: null, + totalFiles: 0, + currentFile: null, + files: {}, + }); }, }, { text: "No" }, @@ -308,10 +318,20 @@ export function UploadProgress({ ))} - {`${progress.totalFilesCompleted} of ${progress.totalFiles} uploaded.`} - {`${formatBytes(progress.totalUploaded)} of ${formatBytes( - progress.totalToUpload - )} uploaded.`} + {progress.statusText ? ( + <> + + {progress.statusText} + + + ) : ( + <> + {`${progress.totalFilesCompleted} of ${progress.totalFiles} uploaded.`} + {`${formatBytes(progress.totalUploaded)} of ${formatBytes( + progress.totalToUpload + )} uploaded.`} + + )}