|
| 1 | +# react-native-google-analytics |
| 2 | + |
| 3 | +An animated progress bar for React Native. |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +## Getting started |
| 8 | + |
| 9 | +1. `npm install react-native-progress-bar@latest --save` |
| 10 | + |
| 11 | +## Example usage |
| 12 | + |
| 13 | +```javascript |
| 14 | +var React = require('react-native'); |
| 15 | +var { |
| 16 | + AppRegistry, |
| 17 | + StyleSheet, |
| 18 | + Text, |
| 19 | + View, |
| 20 | +} = React; |
| 21 | +var ProgressBar = require('react-native-progress-bar'); |
| 22 | + |
| 23 | +var rnsandbox = React.createClass({ |
| 24 | + |
| 25 | + getInitialState() { |
| 26 | + return { |
| 27 | + progress: 0 |
| 28 | + }; |
| 29 | + }, |
| 30 | + |
| 31 | + render() { |
| 32 | + |
| 33 | + setTimeout((function() { |
| 34 | + this.setState({ progress: this.state.progress + (0.4 * Math.random())}); |
| 35 | + }).bind(this), 1000); |
| 36 | + |
| 37 | + return ( |
| 38 | + <View style={styles.container}> |
| 39 | + <Text style={styles.welcome}> |
| 40 | + Welcome to React Native! |
| 41 | + </Text> |
| 42 | + <Text style={styles.instructions}> |
| 43 | + To get started, edit index.ios.js |
| 44 | + </Text> |
| 45 | + <Text style={styles.instructions}> |
| 46 | + Press Cmd+R to reload,{'\n'} |
| 47 | + Cmd+Control+Z for dev menu |
| 48 | + </Text> |
| 49 | + <ProgressBar |
| 50 | + fillStyle={{}} |
| 51 | + backgroundStyle={{backgroundColor: '#cccccc', borderRadius: 2}} |
| 52 | + style={{marginTop: 10, width: 300}} |
| 53 | + progress={this.state.progress} |
| 54 | + /> |
| 55 | + </View> |
| 56 | + ); |
| 57 | + } |
| 58 | +}); |
| 59 | + |
| 60 | +var styles = StyleSheet.create({ |
| 61 | + container: { |
| 62 | + flex: 1, |
| 63 | + justifyContent: 'center', |
| 64 | + alignItems: 'center', |
| 65 | + backgroundColor: '#F5FCFF', |
| 66 | + }, |
| 67 | + welcome: { |
| 68 | + fontSize: 20, |
| 69 | + textAlign: 'center', |
| 70 | + margin: 10, |
| 71 | + }, |
| 72 | + instructions: { |
| 73 | + textAlign: 'center', |
| 74 | + color: '#333333', |
| 75 | + marginBottom: 5, |
| 76 | + }, |
| 77 | +}); |
| 78 | + |
| 79 | +AppRegistry.registerComponent('rnsandbox', () => rnsandbox); |
| 80 | + |
| 81 | +``` |
| 82 | + |
| 83 | +## Properties |
| 84 | + |
| 85 | +#### `progress` |
| 86 | + |
| 87 | +The progress value for the progress bar. Ranges from `0..1`. |
| 88 | + |
| 89 | +#### `fillStyle` |
| 90 | + |
| 91 | +The style for the progress bar fill. |
| 92 | + |
| 93 | +#### `backgroundStyle` |
| 94 | + |
| 95 | +The style for the progress bar's background. |
| 96 | + |
| 97 | +#### `style` |
| 98 | + |
| 99 | +The style for the entire component. This doesn't really differ from the `backgroundStyle` property. You must set `width` either here or in `backgroundStyle` in order to make sure the component works properly. |
| 100 | + |
| 101 | + |
| 102 | +## Component methods |
| 103 | + |
| 104 | +#### `update(progress)` |
| 105 | + |
| 106 | +The recommended way to update the progress of the progress bar is to use the `progress` property. If you prefer, you can use this `update` method to update the progress directly. To access this method, set the `ref` property on the `<ProgressBar>` and call `this.refs.progressBarName.update(0.3)` |
0 commit comments