ProgressBarAndroid.android.js 2.7 KB

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