|
| 1 | +/** |
| 2 | + * Copyright (c) Facebook, Inc. and its affiliates. |
| 3 | + * |
| 4 | + * This source code is licensed under the MIT license found in the |
| 5 | + * LICENSE file in the root directory of this source tree. |
| 6 | + * |
| 7 | + * @flow |
| 8 | + * @format |
| 9 | + */ |
| 10 | + |
| 11 | +'use strict'; |
| 12 | + |
| 13 | +const React = require('React'); |
| 14 | + |
| 15 | +const ProgressBarAndroidNativeComponent = require('ProgressBarAndroidNativeComponent'); |
| 16 | + |
| 17 | +import type {ViewProps} from 'ViewPropTypes'; |
| 18 | + |
| 19 | +export type ProgressBarAndroidProps = $ReadOnly<{| |
| 20 | + ...ViewProps, |
| 21 | + |
| 22 | + /** |
| 23 | + * Style of the ProgressBar and whether it shows indeterminate progress (e.g. spinner). |
| 24 | + * |
| 25 | + * `indeterminate` can only be false if `styleAttr` is Horizontal, and requires a |
| 26 | + * `progress` value. |
| 27 | + */ |
| 28 | + ... |
| 29 | + | {| |
| 30 | + styleAttr: 'Horizontal', |
| 31 | + indeterminate: false, |
| 32 | + progress: number, |
| 33 | + |} |
| 34 | + | {| |
| 35 | + typeAttr: |
| 36 | + | 'Horizontal' |
| 37 | + | 'Normal' |
| 38 | + | 'Small' |
| 39 | + | 'Large' |
| 40 | + | 'Inverse' |
| 41 | + | 'SmallInverse' |
| 42 | + | 'LargeInverse', |
| 43 | + indeterminate: true, |
| 44 | + |}, |
| 45 | + /** |
| 46 | + * Whether to show the ProgressBar (true, the default) or hide it (false). |
| 47 | + */ |
| 48 | + animating?: ?boolean, |
| 49 | + /** |
| 50 | + * Color of the progress bar. |
| 51 | + */ |
| 52 | + color?: ?string, |
| 53 | + /** |
| 54 | + * Used to locate this view in end-to-end tests. |
| 55 | + */ |
| 56 | + testID?: ?string, |
| 57 | +|}>; |
| 58 | + |
| 59 | +/** |
| 60 | + * React component that wraps the Android-only `ProgressBar`. This component is |
| 61 | + * used to indicate that the app is loading or there is activity in the app. |
| 62 | + * |
| 63 | + * Example: |
| 64 | + * |
| 65 | + * ``` |
| 66 | + * render: function() { |
| 67 | + * var progressBar = |
| 68 | + * <View style={styles.container}> |
| 69 | + * <ProgressBar styleAttr="Inverse" /> |
| 70 | + * </View>; |
| 71 | +
|
| 72 | + * return ( |
| 73 | + * <MyLoadingComponent |
| 74 | + * componentView={componentView} |
| 75 | + * loadingView={progressBar} |
| 76 | + * style={styles.loadingComponent} |
| 77 | + * /> |
| 78 | + * ); |
| 79 | + * }, |
| 80 | + * ``` |
| 81 | + */ |
| 82 | +const ProgressBarAndroid = ( |
| 83 | + props: ProgressBarAndroidProps, |
| 84 | + forwardedRef: ?React.Ref<typeof ProgressBarAndroidNativeComponent>, |
| 85 | +) => { |
| 86 | + return <ProgressBarAndroidNativeComponent {...props} ref={forwardedRef} />; |
| 87 | +}; |
| 88 | + |
| 89 | +const ProgressBarAndroidToExport = React.forwardRef(ProgressBarAndroid); |
| 90 | + |
| 91 | +/* $FlowFixMe(>=0.89.0 site=react_native_android_fb) This comment suppresses an |
| 92 | + * error found when Flow v0.89 was deployed. To see the error, delete this |
| 93 | + * comment and run Flow. */ |
| 94 | +ProgressBarAndroidToExport.defaultProps = { |
| 95 | + styleAttr: 'Normal', |
| 96 | + indeterminate: true, |
| 97 | + animating: true, |
| 98 | +}; |
| 99 | + |
| 100 | +/* $FlowFixMe(>=0.89.0 site=react_native_android_fb) This comment suppresses an |
| 101 | + * error found when Flow v0.89 was deployed. To see the error, delete this |
| 102 | + * comment and run Flow. */ |
| 103 | +module.exports = (ProgressBarAndroidToExport: ProgressBarAndroidNativeComponent); |
0 commit comments