2015-09-14 14:35:58 +00:00
|
|
|
/**
|
2018-09-11 22:27:47 +00:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2015-09-14 14:35:58 +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.
|
2015-09-14 14:35:58 +00:00
|
|
|
*
|
2018-08-08 17:39:16 +00:00
|
|
|
* @flow
|
2018-05-09 22:18:18 +00:00
|
|
|
* @format
|
2015-09-14 14:35:58 +00:00
|
|
|
*/
|
2018-05-09 22:18:18 +00:00
|
|
|
|
2015-09-14 14:35:58 +00:00
|
|
|
'use strict';
|
|
|
|
|
2017-09-19 06:45:19 +00:00
|
|
|
const React = require('React');
|
2015-09-14 14:35:58 +00:00
|
|
|
|
2017-10-18 23:50:41 +00:00
|
|
|
const requireNativeComponent = require('requireNativeComponent');
|
|
|
|
|
2018-06-19 21:13:03 +00:00
|
|
|
import type {NativeComponent} from 'ReactNative';
|
|
|
|
import type {ViewProps} from 'ViewPropTypes';
|
2015-09-14 14:35:58 +00:00
|
|
|
|
2018-06-19 21:13:03 +00:00
|
|
|
const AndroidProgressBar = requireNativeComponent('AndroidProgressBar');
|
2015-11-06 20:07:54 +00:00
|
|
|
|
2018-06-19 21:13:03 +00:00
|
|
|
type Props = $ReadOnly<{|
|
|
|
|
...ViewProps,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Style of the ProgressBar and whether it shows indeterminate progress (e.g. spinner).
|
|
|
|
*
|
|
|
|
* `indeterminate` can only be false if `styleAttr` is Horizontal, and requires a
|
|
|
|
* `progress` value.
|
|
|
|
*/
|
|
|
|
...
|
|
|
|
| {|
|
|
|
|
styleAttr: 'Horizontal',
|
|
|
|
indeterminate: false,
|
|
|
|
progress: number,
|
|
|
|
|}
|
|
|
|
| {|
|
|
|
|
typeAttr:
|
|
|
|
| 'Horizontal'
|
|
|
|
| 'Normal'
|
|
|
|
| 'Small'
|
|
|
|
| 'Large'
|
|
|
|
| 'Inverse'
|
|
|
|
| 'SmallInverse'
|
|
|
|
| 'LargeInverse',
|
|
|
|
indeterminate: true,
|
|
|
|
|},
|
|
|
|
/**
|
|
|
|
* Whether to show the ProgressBar (true, the default) or hide it (false).
|
|
|
|
*/
|
|
|
|
animating?: ?boolean,
|
|
|
|
/**
|
|
|
|
* Color of the progress bar.
|
|
|
|
*/
|
|
|
|
color?: ?string,
|
|
|
|
/**
|
|
|
|
* Used to locate this view in end-to-end tests.
|
|
|
|
*/
|
|
|
|
testID?: ?string,
|
|
|
|
|}>;
|
2015-11-06 20:07:54 +00:00
|
|
|
|
2015-09-14 14:35:58 +00:00
|
|
|
/**
|
2018-05-09 22:18:18 +00:00
|
|
|
* React component that wraps the Android-only `ProgressBar`. This component is
|
|
|
|
* used to indicate that the app is loading or there is activity in the app.
|
2015-09-14 14:35:58 +00:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
* render: function() {
|
|
|
|
* var progressBar =
|
|
|
|
* <View style={styles.container}>
|
|
|
|
* <ProgressBar styleAttr="Inverse" />
|
|
|
|
* </View>;
|
|
|
|
|
|
|
|
* return (
|
|
|
|
* <MyLoadingComponent
|
|
|
|
* componentView={componentView}
|
|
|
|
* loadingView={progressBar}
|
|
|
|
* style={styles.loadingComponent}
|
|
|
|
* />
|
|
|
|
* );
|
|
|
|
* },
|
|
|
|
* ```
|
|
|
|
*/
|
2018-06-19 21:13:03 +00:00
|
|
|
const ProgressBarAndroid = (
|
|
|
|
props: Props,
|
|
|
|
forwardedRef: ?React.Ref<'AndroidProgressBar'>,
|
|
|
|
) => {
|
|
|
|
return <AndroidProgressBar {...props} ref={forwardedRef} />;
|
|
|
|
};
|
2018-06-12 03:44:49 +00:00
|
|
|
|
2018-06-19 21:13:03 +00:00
|
|
|
// $FlowFixMe - TODO T29156721 `React.forwardRef` is not defined in Flow, yet.
|
|
|
|
const ProgressBarAndroidToExport = React.forwardRef(ProgressBarAndroid);
|
2018-06-12 03:44:49 +00:00
|
|
|
|
2018-06-19 21:13:03 +00:00
|
|
|
ProgressBarAndroidToExport.defaultProps = {
|
|
|
|
styleAttr: 'Normal',
|
|
|
|
indeterminate: true,
|
|
|
|
animating: true,
|
|
|
|
};
|
2017-10-18 23:50:41 +00:00
|
|
|
|
2018-06-19 21:13:03 +00:00
|
|
|
module.exports = (ProgressBarAndroidToExport: Class<NativeComponent<Props>>);
|