2015-09-14 14:35:58 +00:00
|
|
|
/**
|
2018-09-11 22:27:47 +00:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2016-07-12 12:51:57 +00:00
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2016-07-12 12:51:57 +00:00
|
|
|
*
|
2018-05-11 20:32:37 +00:00
|
|
|
* @format
|
2018-08-08 17:39:16 +00:00
|
|
|
* @flow
|
2015-09-14 14:35:58 +00:00
|
|
|
*/
|
2018-05-11 20:32:37 +00:00
|
|
|
|
2015-09-14 14:35:58 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var ProgressBar = require('ProgressBarAndroid');
|
|
|
|
var React = require('React');
|
2017-07-07 21:24:25 +00:00
|
|
|
var createReactClass = require('create-react-class');
|
2017-05-06 03:50:47 +00:00
|
|
|
var RNTesterBlock = require('RNTesterBlock');
|
|
|
|
var RNTesterPage = require('RNTesterPage');
|
2015-09-14 14:35:58 +00:00
|
|
|
|
2017-07-07 21:24:25 +00:00
|
|
|
var MovingBar = createReactClass({
|
|
|
|
displayName: 'MovingBar',
|
2018-10-05 17:43:13 +00:00
|
|
|
_intervalID: (null: ?IntervalID),
|
2015-11-06 20:07:54 +00:00
|
|
|
|
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
2018-05-11 20:32:37 +00:00
|
|
|
progress: 0,
|
2015-11-06 20:07:54 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
componentDidMount: function() {
|
2018-10-05 17:43:13 +00:00
|
|
|
this._intervalID = setInterval(() => {
|
2018-05-11 20:32:37 +00:00
|
|
|
var progress = (this.state.progress + 0.02) % 1;
|
|
|
|
this.setState({progress: progress});
|
|
|
|
}, 50);
|
2015-11-06 20:07:54 +00:00
|
|
|
},
|
|
|
|
|
2018-10-05 17:43:13 +00:00
|
|
|
componentWillUnmount: function() {
|
|
|
|
if (this._intervalID != null) {
|
|
|
|
clearInterval(this._intervalID);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-11-06 20:07:54 +00:00
|
|
|
render: function() {
|
|
|
|
return <ProgressBar progress={this.state.progress} {...this.props} />;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2017-08-18 01:36:54 +00:00
|
|
|
class ProgressBarAndroidExample extends React.Component<{}> {
|
2016-07-26 08:00:02 +00:00
|
|
|
static title = '<ProgressBarAndroid>';
|
|
|
|
static description = 'Horizontal bar to show the progress of some operation.';
|
2015-09-14 14:35:58 +00:00
|
|
|
|
2016-07-26 08:00:02 +00:00
|
|
|
render() {
|
2015-09-14 14:35:58 +00:00
|
|
|
return (
|
2017-05-06 03:50:47 +00:00
|
|
|
<RNTesterPage title="ProgressBar Examples">
|
|
|
|
<RNTesterBlock title="Horizontal Indeterminate ProgressBar">
|
2018-08-13 18:14:35 +00:00
|
|
|
{/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was
|
|
|
|
* found when making Flow check .android.js files. */}
|
2015-11-06 20:07:54 +00:00
|
|
|
<ProgressBar styleAttr="Horizontal" />
|
2017-05-06 03:50:47 +00:00
|
|
|
</RNTesterBlock>
|
2015-11-06 20:07:54 +00:00
|
|
|
|
2017-05-06 03:50:47 +00:00
|
|
|
<RNTesterBlock title="Horizontal ProgressBar">
|
2015-11-06 20:07:54 +00:00
|
|
|
<MovingBar styleAttr="Horizontal" indeterminate={false} />
|
2017-05-06 03:50:47 +00:00
|
|
|
</RNTesterBlock>
|
2015-11-06 20:07:54 +00:00
|
|
|
|
2017-05-06 03:50:47 +00:00
|
|
|
<RNTesterBlock title="Horizontal Black Indeterminate ProgressBar">
|
2018-08-13 18:14:35 +00:00
|
|
|
{/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was
|
|
|
|
* found when making Flow check .android.js files. */}
|
2015-11-06 20:07:54 +00:00
|
|
|
<ProgressBar styleAttr="Horizontal" color="black" />
|
2017-05-06 03:50:47 +00:00
|
|
|
</RNTesterBlock>
|
2015-11-06 20:07:54 +00:00
|
|
|
|
2017-05-06 03:50:47 +00:00
|
|
|
<RNTesterBlock title="Horizontal Blue ProgressBar">
|
2018-05-11 20:32:37 +00:00
|
|
|
<MovingBar
|
|
|
|
styleAttr="Horizontal"
|
|
|
|
indeterminate={false}
|
|
|
|
color="blue"
|
|
|
|
/>
|
2017-05-06 03:50:47 +00:00
|
|
|
</RNTesterBlock>
|
|
|
|
</RNTesterPage>
|
2015-09-14 14:35:58 +00:00
|
|
|
);
|
2016-07-26 08:00:02 +00:00
|
|
|
}
|
|
|
|
}
|
2015-09-14 14:35:58 +00:00
|
|
|
|
|
|
|
module.exports = ProgressBarAndroidExample;
|