|
10 | 10 |
|
11 | 11 | 'use strict';
|
12 | 12 |
|
13 |
| -const DeprecatedViewPropTypes = require('DeprecatedViewPropTypes'); |
14 |
| -const Image = require('Image'); |
15 |
| -const NativeMethodsMixin = require('NativeMethodsMixin'); |
16 |
| -const PropTypes = require('prop-types'); |
17 | 13 | const React = require('React');
|
18 |
| -const ReactNative = require('ReactNative'); |
19 | 14 | const StyleSheet = require('StyleSheet');
|
20 | 15 |
|
21 | 16 | const createReactClass = require('create-react-class');
|
22 | 17 | const requireNativeComponent = require('requireNativeComponent');
|
23 | 18 |
|
| 19 | +import type {NativeComponent} from 'ReactNative'; |
24 | 20 | import type {ImageSource} from 'ImageSource';
|
25 | 21 | import type {ColorValue} from 'StyleSheetTypes';
|
26 | 22 | import type {ViewProps} from 'ViewPropTypes';
|
27 | 23 |
|
28 |
| -const RCTProgressView = requireNativeComponent('RCTProgressView'); |
29 |
| - |
30 | 24 | type Props = $ReadOnly<{|
|
31 | 25 | ...ViewProps,
|
| 26 | + |
| 27 | + /** |
| 28 | + * The progress bar style. |
| 29 | + */ |
32 | 30 | progressViewStyle?: ?('default' | 'bar'),
|
| 31 | + |
| 32 | + /** |
| 33 | + * The progress value (between 0 and 1). |
| 34 | + */ |
33 | 35 | progress?: ?number,
|
| 36 | + |
| 37 | + /** |
| 38 | + * The tint color of the progress bar itself. |
| 39 | + */ |
34 | 40 | progressTintColor?: ?ColorValue,
|
35 |
| - trackTintColor?: ?string, |
| 41 | + |
| 42 | + /** |
| 43 | + * The tint color of the progress bar track. |
| 44 | + */ |
| 45 | + trackTintColor?: ?ColorValue, |
| 46 | + |
| 47 | + /** |
| 48 | + * A stretchable image to display as the progress bar. |
| 49 | + */ |
36 | 50 | progressImage?: ?ImageSource,
|
| 51 | + |
| 52 | + /** |
| 53 | + * A stretchable image to display behind the progress bar. |
| 54 | + */ |
37 | 55 | trackImage?: ?ImageSource,
|
38 | 56 | |}>;
|
39 | 57 |
|
| 58 | +type NativeProgressViewIOS = Class<NativeComponent<Props>>; |
| 59 | + |
| 60 | +const RCTProgressView = ((requireNativeComponent( |
| 61 | + 'RCTProgressView', |
| 62 | +): any): NativeProgressViewIOS); |
| 63 | + |
40 | 64 | /**
|
41 | 65 | * Use `ProgressViewIOS` to render a UIProgressView on iOS.
|
42 | 66 | */
|
43 |
| -const ProgressViewIOS = createReactClass({ |
44 |
| - displayName: 'ProgressViewIOS', |
45 |
| - mixins: [NativeMethodsMixin], |
46 |
| - |
47 |
| - propTypes: { |
48 |
| - ...DeprecatedViewPropTypes, |
49 |
| - /** |
50 |
| - * The progress bar style. |
51 |
| - */ |
52 |
| - progressViewStyle: PropTypes.oneOf(['default', 'bar']), |
53 |
| - |
54 |
| - /** |
55 |
| - * The progress value (between 0 and 1). |
56 |
| - */ |
57 |
| - progress: PropTypes.number, |
58 |
| - |
59 |
| - /** |
60 |
| - * The tint color of the progress bar itself. |
61 |
| - */ |
62 |
| - progressTintColor: PropTypes.string, |
63 |
| - |
64 |
| - /** |
65 |
| - * The tint color of the progress bar track. |
66 |
| - */ |
67 |
| - trackTintColor: PropTypes.string, |
68 |
| - |
69 |
| - /** |
70 |
| - * A stretchable image to display as the progress bar. |
71 |
| - */ |
72 |
| - progressImage: Image.propTypes.source, |
73 |
| - |
74 |
| - /** |
75 |
| - * A stretchable image to display behind the progress bar. |
76 |
| - */ |
77 |
| - trackImage: Image.propTypes.source, |
78 |
| - }, |
79 |
| - |
80 |
| - render: function() { |
81 |
| - return ( |
82 |
| - <RCTProgressView |
83 |
| - {...this.props} |
84 |
| - style={[styles.progressView, this.props.style]} |
85 |
| - /> |
86 |
| - ); |
87 |
| - }, |
88 |
| -}); |
| 67 | +const ProgressViewIOS = ( |
| 68 | + props: Props, |
| 69 | + forwardedRef?: ?React.Ref<typeof RCTProgressView>, |
| 70 | +) => ( |
| 71 | + <RCTProgressView |
| 72 | + {...props} |
| 73 | + style={[styles.progressView, props.style]} |
| 74 | + ref={forwardedRef} |
| 75 | + /> |
| 76 | +); |
89 | 77 |
|
90 | 78 | const styles = StyleSheet.create({
|
91 | 79 | progressView: {
|
92 | 80 | height: 2,
|
93 | 81 | },
|
94 | 82 | });
|
95 | 83 |
|
96 |
| -module.exports = ((ProgressViewIOS: any): Class< |
97 |
| - ReactNative.NativeComponent<Props>, |
98 |
| ->); |
| 84 | +// $FlowFixMe - TODO T29156721 `React.forwardRef` is not defined in Flow, yet. |
| 85 | +const ProgressViewIOSWithRef = React.forwardRef(ProgressViewIOS); |
| 86 | + |
| 87 | +module.exports = (ProgressViewIOSWithRef: NativeProgressViewIOS); |
0 commit comments