react-native/RNTester/js/ProgressBarAndroidExample.android.js
nd-02110114 3d31bebbeb Remove TimerMixin on ProgressBarAndroidExample.android.js (#21501)
Summary:
Related to #21485.
Removed TimerMixin from the `RNTester/js/ProgressBarAndroidExample.android.js` since it is currently not used.

- [x] npm run prettier
- [x] npm run flow-check-ios
- [x] npm run flow-check-android

In progress 🙇

[GENERAL] [ENHANCEMENT] [RNTester/js/ProgressBarAndroidExample.android.js] - remove TimerMixin dependency
Pull Request resolved: https://github.com/facebook/react-native/pull/21501

Reviewed By: TheSavior

Differential Revision: D10218375

Pulled By: RSNara

fbshipit-source-id: c4c12f65855452bc2485f034a0560afd204512f4
2018-10-05 10:50:21 -07:00

83 lines
2.3 KiB
JavaScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow
*/
'use strict';
var ProgressBar = require('ProgressBarAndroid');
var React = require('React');
var createReactClass = require('create-react-class');
var RNTesterBlock = require('RNTesterBlock');
var RNTesterPage = require('RNTesterPage');
var MovingBar = createReactClass({
displayName: 'MovingBar',
_intervalID: (null: ?IntervalID),
getInitialState: function() {
return {
progress: 0,
};
},
componentDidMount: function() {
this._intervalID = setInterval(() => {
var progress = (this.state.progress + 0.02) % 1;
this.setState({progress: progress});
}, 50);
},
componentWillUnmount: function() {
if (this._intervalID != null) {
clearInterval(this._intervalID);
}
},
render: function() {
return <ProgressBar progress={this.state.progress} {...this.props} />;
},
});
class ProgressBarAndroidExample extends React.Component<{}> {
static title = '<ProgressBarAndroid>';
static description = 'Horizontal bar to show the progress of some operation.';
render() {
return (
<RNTesterPage title="ProgressBar Examples">
<RNTesterBlock title="Horizontal Indeterminate ProgressBar">
{/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was
* found when making Flow check .android.js files. */}
<ProgressBar styleAttr="Horizontal" />
</RNTesterBlock>
<RNTesterBlock title="Horizontal ProgressBar">
<MovingBar styleAttr="Horizontal" indeterminate={false} />
</RNTesterBlock>
<RNTesterBlock title="Horizontal Black Indeterminate ProgressBar">
{/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was
* found when making Flow check .android.js files. */}
<ProgressBar styleAttr="Horizontal" color="black" />
</RNTesterBlock>
<RNTesterBlock title="Horizontal Blue ProgressBar">
<MovingBar
styleAttr="Horizontal"
indeterminate={false}
color="blue"
/>
</RNTesterBlock>
</RNTesterPage>
);
}
}
module.exports = ProgressBarAndroidExample;