import { formatBytes } from "@/util/uploadUtils"; import { ActivityIndicator, StyleSheet, Text, View } from "react-native"; import { ProgressBar } from "react-native-paper"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { selectPhotos, selectUploadProgress, } from "../../redux/photos/photos.selectors"; const mapStateToProps = createStructuredSelector({ photos: selectPhotos, photoUploadProgress: selectUploadProgress, }); export default connect(mapStateToProps, null)(UploadProgress); export function UploadProgress({ photos, photoUploadProgress }) { if (photos?.length === 0) return null; return ( {Object.keys(photoUploadProgress).map((key) => ( {photoUploadProgress[key].fileName} {`${formatBytes( photoUploadProgress[key].loaded / (((photoUploadProgress[key].uploadEnd || new Date()) - photoUploadProgress[key].uploadStart) / 1000) )}/sec`} {photoUploadProgress[key].percent === 1 && ( <> Processing... )} ))} { // progress.statusText ? ( // <> // // {progress.statusText} // // // ) : ( // <> // {`${progress.totalFilesCompleted} of ${progress.totalFiles} uploaded.`} // {`${formatBytes(progress.totalUploaded)} of ${formatBytes( // progress.totalToUpload // )} uploaded.`} // // ) } ); } const styles = StyleSheet.create({ modalContainer: { display: "flex", flex: 1, justifyContent: "center", }, modal: { //flex: 1, display: "flex", marginLeft: 20, marginRight: 20, backgroundColor: "white", borderRadius: 20, padding: 18, shadowColor: "#000", shadowOffset: { width: 0, height: 2, }, shadowOpacity: 0.25, shadowRadius: 4, elevation: 5, }, centeredView: { justifyContent: "center", alignItems: "center", marginTop: 22, }, progressItem: { display: "flex", flexDirection: "row", alignItems: "center", marginBottom: 12, marginLeft: 12, marginRight: 12, }, progressText: { flex: 1, }, progressBarContainer: { flex: 3, marginLeft: 12, marginRight: 12, }, });