Skip to content

Commit

Permalink
Remove ProgressBar from examples and fix XHRDownloadExample
Browse files Browse the repository at this point in the history
Summary:
Changelog: [Internal] - Remove usage of ProgressViewIOS and ProgressBarAndroid from RNTester

Note: Android example doesn't properly update progress. Filing an issue here: TODO

Reviewed By: yungsters

Differential Revision: D31328094

fbshipit-source-id: 5afa3bb1079b91bb98fa51587e96402fb1565f82
  • Loading branch information
Luna Wei authored and facebook-github-bot committed Oct 6, 2021
1 parent 046b026 commit 5280968
Showing 1 changed file with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions packages/rn-tester/js/examples/XHR/XHRExampleDownload.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ const React = require('react');

const {
Alert,
Platform,
ProgressBarAndroid,
ProgressViewIOS,
StyleSheet,
Switch,
Text,
Expand All @@ -31,21 +28,6 @@ function roundKilo(value: number): number {
return Math.round(value / 1000);
}

class ProgressBar extends React.Component<$FlowFixMeProps> {
render() {
if (Platform.OS === 'android') {
return (
<ProgressBarAndroid
progress={this.props.progress}
styleAttr="Horizontal"
indeterminate={false}
/>
);
}
return <ProgressViewIOS progress={this.props.progress} />;
}
}

class XHRExampleDownload extends React.Component<{...}, Object> {
state: Object = {
downloading: false,
Expand Down Expand Up @@ -126,7 +108,10 @@ class XHRExampleDownload extends React.Component<{...}, Object> {
Alert.alert('Error', xhr.responseText);
}
};
xhr.open('GET', 'http://aleph.gutenberg.org/cache/epub/100/pg100.txt.utf8');
xhr.open(
'GET',
'http://aleph.gutenberg.org/cache/epub/100/pg100-images.html.utf8',
);
// Avoid gzip so we can actually show progress
xhr.setRequestHeader('Accept-Encoding', '');
xhr.send();
Expand All @@ -149,7 +134,7 @@ class XHRExampleDownload extends React.Component<{...}, Object> {
) : (
<TouchableHighlight style={styles.wrapper} onPress={this._download}>
<View style={styles.button}>
<Text>Download 5MB Text File</Text>
<Text>Download 7MB Text File</Text>
</View>
</TouchableHighlight>
);
Expand All @@ -164,7 +149,6 @@ class XHRExampleDownload extends React.Component<{...}, Object> {
responseText: {roundKilo(responseLength)}/{roundKilo(contentLength)}
k chars
</Text>
<ProgressBar progress={responseLength / contentLength} />
</View>
);
}
Expand All @@ -176,7 +160,6 @@ class XHRExampleDownload extends React.Component<{...}, Object> {
onprogress: {roundKilo(progressLoaded)}/{roundKilo(progressTotal)}{' '}
KB
</Text>
<ProgressBar progress={progressLoaded / progressTotal} />
</View>
);
}
Expand Down

0 comments on commit 5280968

Please sign in to comment.