1.3.7-2 - Test Build - Added progress for fetching file size.

This commit is contained in:
Patrick Fic
2022-06-23 09:16:54 -07:00
parent 9eb8a43884
commit 7ba64ea553
4 changed files with 52 additions and 30 deletions

View File

@@ -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": {

View File

@@ -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";

View File

@@ -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 }) {
<Subheading style={{ textAlign: "center" }}>
{t("app.nomobileaccess")}
</Subheading>
<Divider />
<SignOutButton />
</View>
) : (
<ActivityIndicator color="dodgerblue" size="large" />

View File

@@ -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({
</View>
))}
<View style={styles.centeredView}>
<Text>{`${progress.totalFilesCompleted} of ${progress.totalFiles} uploaded.`}</Text>
<Text>{`${formatBytes(progress.totalUploaded)} of ${formatBytes(
progress.totalToUpload
)} uploaded.`}</Text>
{progress.statusText ? (
<>
<ActivityIndicator style={{ marginLeft: 12 }} />
<Text style={{ marginLeft: 4 }}>{progress.statusText}</Text>
<Divider />
</>
) : (
<>
<Text>{`${progress.totalFilesCompleted} of ${progress.totalFiles} uploaded.`}</Text>
<Text>{`${formatBytes(progress.totalUploaded)} of ${formatBytes(
progress.totalToUpload
)} uploaded.`}</Text>
</>
)}
</View>
</View>
</View>