Major improvements to upload progress.
This commit is contained in:
@@ -7,6 +7,7 @@ import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||
import * as Application from "expo-application";
|
||||
import Constants from "expo-constants";
|
||||
import * as Notifications from "expo-notifications";
|
||||
import * as Updates from "expo-updates";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Alert, ScrollView, StyleSheet, View } from "react-native";
|
||||
@@ -182,6 +183,44 @@ function Tab({ bodyshop, currentUser, signOutStart }) {
|
||||
number: `${Constants.expoConfig.version}(${Application.nativeBuildVersion} - ${Constants.expoConfig.extra.expover})`,
|
||||
})}
|
||||
</Text>
|
||||
<Button
|
||||
mode="text"
|
||||
onPress={() => {
|
||||
Updates.checkForUpdateAsync()
|
||||
.then(async (update) => {
|
||||
if (update.isAvailable) {
|
||||
const reloaded = await Updates.fetchUpdateAsync();
|
||||
if (reloaded.isNew) {
|
||||
Alert.alert(
|
||||
"Update downloaded",
|
||||
"The app will now restart to apply the update.",
|
||||
[
|
||||
{
|
||||
text: "Restart Now",
|
||||
onPress: () => {
|
||||
Updates.reloadAsync();
|
||||
},
|
||||
},
|
||||
]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
Alert.alert(
|
||||
"No Update Available",
|
||||
"You are using the latest version of the app."
|
||||
);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
Alert.alert(
|
||||
"Update Error",
|
||||
`An error occurred while checking for updates: ${error.message}`
|
||||
);
|
||||
});
|
||||
}}
|
||||
>
|
||||
Check for Update
|
||||
</Button>
|
||||
</ScrollView>
|
||||
</SafeAreaView>
|
||||
);
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
import { useTheme } from "@/hooks";
|
||||
import { clearUploadError } from "@/redux/photos/photos.actions";
|
||||
import { cancelUploads, clearUploadError } from "@/redux/photos/photos.actions";
|
||||
import { formatBytes } from "@/util/uploadUtils";
|
||||
import { useMemo } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { ScrollView, StyleSheet, View } from "react-native";
|
||||
import { Divider, Modal, Portal, ProgressBar, Text } from "react-native-paper";
|
||||
import {
|
||||
Button,
|
||||
Divider,
|
||||
Modal,
|
||||
Portal,
|
||||
ProgressBar,
|
||||
Text,
|
||||
} from "react-native-paper";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import {
|
||||
@@ -20,6 +27,7 @@ const mapStateToProps = createStructuredSelector({
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
clearError: () => dispatch(clearUploadError()),
|
||||
cancelUploads: () => dispatch(cancelUploads()),
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(UploadProgress);
|
||||
@@ -29,6 +37,7 @@ export function UploadProgress({
|
||||
photoUploadProgress,
|
||||
uploadError,
|
||||
clearError,
|
||||
cancelUploads,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const theme = useTheme();
|
||||
@@ -42,6 +51,10 @@ export function UploadProgress({
|
||||
return completed / total;
|
||||
}, [photoUploadProgress]);
|
||||
|
||||
const handleCancelUploads = () => {
|
||||
cancelUploads();
|
||||
};
|
||||
|
||||
return (
|
||||
<Portal>
|
||||
<Modal
|
||||
@@ -78,10 +91,10 @@ export function UploadProgress({
|
||||
</Text>
|
||||
<View style={styles.progressBarContainer}>
|
||||
<ProgressBar
|
||||
progress={(photoUploadProgress[key].progress || 0) / 100}
|
||||
progress={photoUploadProgress[key].progress || 0}
|
||||
style={styles.progress}
|
||||
color={
|
||||
photoUploadProgress[key].progress === 100 ? "green" : "blue"
|
||||
photoUploadProgress[key].progress === 1 ? "green" : "blue"
|
||||
}
|
||||
/>
|
||||
<View style={styles.speedRow}>
|
||||
@@ -95,6 +108,9 @@ export function UploadProgress({
|
||||
</View>
|
||||
</View>
|
||||
))}
|
||||
<Button onPress={handleCancelUploads}>
|
||||
{t("general.actions.cancel")}
|
||||
</Button>
|
||||
</ScrollView>
|
||||
</Modal>
|
||||
</Portal>
|
||||
|
||||
Reference in New Issue
Block a user