Guest User

Untitled

a guest
Oct 18th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { ActivityIndicator, ProgressBarAndroid, Platform, StyleSheet, Text, View } from 'react-native';
  3.  
  4. export default class App extends Component<{}> {
  5. render() {
  6. return (
  7. <View style={styles.container}>
  8. <ActivityIndicator size="small" color="green" />
  9. <ActivityIndicator size="large" color="purple" />
  10. <ProgressBarAndroid styleAttr="Inverse" />
  11. <ProgressBarAndroid styleAttr="Large" size="small" />
  12. <ProgressBarAndroid styleAttr="Horizontal" />
  13. <ProgressBarExample initialProgress={0} />
  14. <ProgressBarExample progressTintColor="red" initialProgress={0.4} />
  15. <ProgressBarExample progressTintColor="red" initialProgress={0.4} />
  16. <ProgressBarExample progressTintColor="orange" initialProgress={0.6} />
  17. <ProgressBarExample progressTintColor="yellow" initialProgress={0.8} />
  18.  
  19. <ProgressBarAndroid
  20. styleAttr="Normal"
  21. color="red"
  22. progress={0.5}
  23. />
  24. </View>
  25. );
  26. }
  27. }
  28.  
  29. class ProgressBarExample extends React.Component {
  30. constructor(props) {
  31. super(props);
  32.  
  33. this.state = {
  34. progress: props.initialProgress,
  35. };
  36. }
  37.  
  38. componentDidMount() {
  39. this.progressLoop();
  40. }
  41.  
  42. progressLoop() {
  43. setTimeout(() => {
  44. this.setState({
  45. progress:
  46. this.state.progress === 1
  47. ? 0
  48. : Math.min(1, this.state.progress + 0.01),
  49. });
  50.  
  51. this.progressLoop();
  52. }, 17 * 2);
  53. }
  54.  
  55. render() {
  56. const progressStyle = { marginTop: 20, height: 50, width: 300 };
  57.  
  58. return (
  59. <ProgressBarAndroid
  60. styleAttr="Horizontal"
  61. animating={true}
  62. style={progressStyle}
  63. color={this.props.progressTintColor}
  64. progress={this.state.progress}
  65. />
  66. );
  67. }
  68. }
  69.  
  70. const styles = StyleSheet.create({
  71. container: {
  72. flex: 1,
  73. backgroundColor: '#F5FCFF',
  74. },
  75. });
Add Comment
Please, Sign In to add comment