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", "slug": "imexmobile",
"version": "1.3.7", "version": "1.3.7",
"extra": { "extra": {
"expover": "1" "expover": "2"
}, },
"orientation": "default", "orientation": "default",
"icon": "./assets/logo192noa.png", "icon": "./assets/logo192noa.png",
"ios": { "ios": {
"supportsTablet": true, "supportsTablet": true,
"bundleIdentifier": "com.imex.imexmobile", "bundleIdentifier": "com.imex.imexmobile",
"buildNumber": "1", "buildNumber": "2",
"googleServicesFile": "./GoogleService-Info.plist" "googleServicesFile": "./GoogleService-Info.plist"
}, },
"android": { "android": {
"package": "com.imex.imexmobile", "package": "com.imex.imexmobile",
"versionCode": 1100014, "versionCode": 1100015,
"googleServicesFile": "./google-services.json" "googleServicesFile": "./google-services.json"
}, },
"splash": { "splash": {

View File

@@ -6,7 +6,6 @@ import i18n from "i18next";
import moment from "moment"; import moment from "moment";
import React, { useEffect } from "react"; import React, { useEffect } from "react";
import { Button } from "react-native-paper"; import { Button } from "react-native-paper";
import { SafeAreaView } from "react-native-safe-area-context";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { createStructuredSelector } from "reselect"; import { createStructuredSelector } from "reselect";
import { logImEXEvent } from "../../firebase/firebase.analytics"; import { logImEXEvent } from "../../firebase/firebase.analytics";

View File

@@ -1,8 +1,9 @@
import React from "react"; import React from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { ActivityIndicator, Image, StyleSheet, View } from "react-native"; 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 Logo from "../../assets/logo192.png";
import SignOutButton from "../sign-out-button/sign-out-button.component";
export default function ScreenSplash({ noAccess }) { export default function ScreenSplash({ noAccess }) {
const { t } = useTranslation(); const { t } = useTranslation();
@@ -18,6 +19,8 @@ export default function ScreenSplash({ noAccess }) {
<Subheading style={{ textAlign: "center" }}> <Subheading style={{ textAlign: "center" }}>
{t("app.nomobileaccess")} {t("app.nomobileaccess")}
</Subheading> </Subheading>
<Divider />
<SignOutButton />
</View> </View>
) : ( ) : (
<ActivityIndicator color="dodgerblue" size="large" /> <ActivityIndicator color="dodgerblue" size="large" />

View File

@@ -1,7 +1,6 @@
import { useApolloClient } from "@apollo/client"; import { useApolloClient } from "@apollo/client";
import * as FileSystem from "expo-file-system"; import * as FileSystem from "expo-file-system";
import * as MediaLibrary from "expo-media-library"; import * as MediaLibrary from "expo-media-library";
import _ from "lodash";
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { import {
@@ -9,12 +8,11 @@ import {
Alert, Alert,
Modal, Modal,
Platform, Platform,
ScrollView,
StyleSheet, StyleSheet,
Text, Text,
View, View,
} from "react-native"; } from "react-native";
import { ProgressBar } from "react-native-paper"; import { Divider, ProgressBar } from "react-native-paper";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { createStructuredSelector } from "reselect"; import { createStructuredSelector } from "reselect";
import { logImEXEvent } from "../../firebase/firebase.analytics"; import { logImEXEvent } from "../../firebase/firebase.analytics";
@@ -29,7 +27,6 @@ import {
} from "../../redux/user/user.selectors"; } from "../../redux/user/user.selectors";
import { formatBytes, handleUpload } from "../../util/document-upload.utility"; import { formatBytes, handleUpload } from "../../util/document-upload.utility";
import Toast from "react-native-toast-message"; import Toast from "react-native-toast-message";
import { validateArgCount } from "@firebase/util";
const mapStateToProps = createStructuredSelector({ const mapStateToProps = createStructuredSelector({
currentUser: selectCurrentUser, currentUser: selectCurrentUser,
@@ -122,6 +119,14 @@ export function UploadProgress({
} }
const onDone = async (selectedFiles) => { 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. //Validate to make sure the totals for the file sizes do not exceed the total on the job.
const data = []; const data = [];
const totalOfUploads = await selectedFiles.reduce(async (acc, val) => { const totalOfUploads = await selectedFiles.reduce(async (acc, val) => {
@@ -151,7 +156,7 @@ export function UploadProgress({
...progress, ...progress,
speed: 0, speed: 0,
action: null, action: null,
statusText: null,
uploadInProgress: false, uploadInProgress: false,
})); }));
Alert.alert( Alert.alert(
@@ -162,21 +167,17 @@ export function UploadProgress({
} }
} }
//We made it this far. We have enough space, so let's start uploading. //We made it this far. We have enough space, so let's start uploading.
setProgress((progress) => ({
setProgress((progress) => { ...progress,
return { totalToUpload: totalOfUploads,
...progress, totalUploaded: 0,
uploadInProgress: true, totalFilesCompleted: 0,
startTime: new Date(),
totalToUpload: totalOfUploads, totalFiles: data.length,
totalUploaded: 0, currentFile: null,
totalFilesCompleted: 0, statusText: null,
startTime: new Date(), files: {}, //uri is the key, value is progress
totalFiles: data.length, }));
currentFile: null,
files: {}, //uri is the key, value is progress
};
});
for (var i = 0; i < data.length + 4; i = i + 4) { for (var i = 0; i < data.length + 4; i = i + 4) {
//Reset the files. //Reset the files.
@@ -264,7 +265,16 @@ export function UploadProgress({
text: "Yes", text: "Yes",
onPress: () => { onPress: () => {
setUploads(null); setUploads(null);
setProgress(null); setProgress({
uploadInProgress: false,
totalToUpload: 0,
totalUploaded: 0,
totalFilesCompleted: 0,
startTime: null,
totalFiles: 0,
currentFile: null,
files: {},
});
}, },
}, },
{ text: "No" }, { text: "No" },
@@ -308,10 +318,20 @@ export function UploadProgress({
</View> </View>
))} ))}
<View style={styles.centeredView}> <View style={styles.centeredView}>
<Text>{`${progress.totalFilesCompleted} of ${progress.totalFiles} uploaded.`}</Text> {progress.statusText ? (
<Text>{`${formatBytes(progress.totalUploaded)} of ${formatBytes( <>
progress.totalToUpload <ActivityIndicator style={{ marginLeft: 12 }} />
)} uploaded.`}</Text> <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> </View>
</View> </View>