Browse Source

we already have totalProgress from uppy, so using that

Artur Paikin 6 years ago
parent
commit
916dccba45
2 changed files with 7 additions and 10 deletions
  1. 3 4
      examples/react-native-expo/App.js
  2. 4 6
      examples/react-native-expo/ProgressBar.js

+ 3 - 4
examples/react-native-expo/App.js

@@ -75,6 +75,7 @@ export default class App extends React.Component {
       this.setState({
         progress: progress.bytesUploaded,
         total: progress.bytesTotal,
+        totalProgress: this.uppy.state.totalProgress,
         uploadStarted: true
       })
     })
@@ -163,10 +164,8 @@ export default class App extends React.Component {
           : null
         }
 
-        <ProgressBar
-          progress={this.state.progress}
-          total={this.state.total}
-        />
+        <ProgressBar progress={this.state.totalProgress} />
+
         <PauseResumeButton
           isPaused={this.state.isPaused}
           onPress={this.togglePauseResume}

+ 4 - 6
examples/react-native-expo/ProgressBar.js

@@ -2,9 +2,7 @@ import React from 'react' // eslint-disable-line no-unused-vars
 import { View, Text } from 'react-native'
 
 export default function ProgressBar (props) {
-  const progress = props.progress || 0
-  const total = props.total || 0
-  const percentage = Math.round(progress / total * 100)
+  const progress = props.progress
 
   const colorGreen = '#0b8600'
   const colorBlue = '#006bb7'
@@ -22,11 +20,11 @@ export default function ProgressBar (props) {
         }}>
         <View style={{
           height: 5,
-          backgroundColor: percentage === 100 ? colorGreen : colorBlue,
-          width: percentage + '%'
+          backgroundColor: progress === 100 ? colorGreen : colorBlue,
+          width: progress + '%'
         }} />
       </View>
-      <Text>{percentage ? percentage + '%' : null}</Text>
+      <Text>{progress ? progress + '%' : null}</Text>
     </View>
   )
 }