Skip to content

Commit 96ad253

Browse files
j-piaseckigabrieldonadel
authored andcommitted
Align ProgressBarAndroid types with OSS (facebook#49663)
Summary: Pull Request resolved: facebook#49663 Changelog: [Internal] Reviewed By: huntie Differential Revision: D70176068 fbshipit-source-id: 0a1febb390affc2a3123e49e88b039b390a34387
1 parent cfa274f commit 96ad253

File tree

6 files changed

+104
-56
lines changed

6 files changed

+104
-56
lines changed

packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ const ActivityIndicator = (
112112
// $FlowFixMe[prop-missing] Flow doesn't know when this is the android component
113113
<PlatformActivityIndicator {...nativeProps} {...androidProps} />
114114
) : (
115-
/* $FlowFixMe[prop-missing] (>=0.106.0 site=react_native_android_fb) This comment
115+
/* $FlowFixMe[incompatible-type] (>=0.106.0 site=react_native_android_fb) This comment
116116
* suppresses an error found when Flow v0.106 was deployed. To see the
117117
* error, delete this comment and run Flow. */
118118
<PlatformActivityIndicator {...nativeProps} />

packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -8,52 +8,13 @@
88
* @format
99
*/
1010

11-
import type {ColorValue} from '../../StyleSheet/StyleSheet';
12-
import type {ViewProps} from '../View/ViewPropTypes';
11+
import type {ProgressBarAndroidProps} from './ProgressBarAndroidTypes';
1312

1413
import ProgressBarAndroidNativeComponent from './ProgressBarAndroidNativeComponent';
1514

1615
const React = require('react');
1716

18-
export type ProgressBarAndroidProps = $ReadOnly<{
19-
...ViewProps,
20-
21-
/**
22-
* Style of the ProgressBar and whether it shows indeterminate progress (e.g. spinner).
23-
*
24-
* `indeterminate` can only be false if `styleAttr` is Horizontal, and requires a
25-
* `progress` value.
26-
*/
27-
...
28-
| {
29-
styleAttr: 'Horizontal',
30-
indeterminate: false,
31-
progress: number,
32-
}
33-
| {
34-
typeAttr:
35-
| 'Horizontal'
36-
| 'Normal'
37-
| 'Small'
38-
| 'Large'
39-
| 'Inverse'
40-
| 'SmallInverse'
41-
| 'LargeInverse',
42-
indeterminate: true,
43-
},
44-
/**
45-
* Whether to show the ProgressBar (true, the default) or hide it (false).
46-
*/
47-
animating?: ?boolean,
48-
/**
49-
* Color of the progress bar.
50-
*/
51-
color?: ?ColorValue,
52-
/**
53-
* Used to locate this view in end-to-end tests.
54-
*/
55-
testID?: ?string,
56-
}>;
17+
export type {ProgressBarAndroidProps};
5718

5819
/**
5920
* React component that wraps the Android-only `ProgressBar`. This component is
@@ -79,7 +40,7 @@ export type ProgressBarAndroidProps = $ReadOnly<{
7940
* ```
8041
*/
8142
const ProgressBarAndroidWithForwardedRef: component(
82-
ref: React.RefSetter<
43+
ref?: React.RefSetter<
8344
React.ElementRef<typeof ProgressBarAndroidNativeComponent>,
8445
>,
8546
...props: ProgressBarAndroidProps
@@ -106,7 +67,4 @@ const ProgressBarAndroidWithForwardedRef: component(
10667
);
10768
});
10869

109-
export default /* $FlowFixMe(>=0.89.0 site=react_native_android_fb) This comment suppresses an
110-
* error found when Flow v0.89 was deployed. To see the error, delete this
111-
* comment and run Flow. */
112-
(ProgressBarAndroidWithForwardedRef: typeof ProgressBarAndroidNativeComponent);
70+
export default ProgressBarAndroidWithForwardedRef;

packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@
1010

1111
'use strict';
1212

13-
import typeof UnimplementedViewType from '../UnimplementedViews/UnimplementedView';
1413
import typeof ProgressBarAndroidNativeComponentType from './ProgressBarAndroidNativeComponent';
14+
import type {ProgressBarAndroidProps} from './ProgressBarAndroidTypes';
1515

16-
export type {ProgressBarAndroidProps} from './ProgressBarAndroid.android';
16+
export type {ProgressBarAndroidProps};
1717

18-
export default require('../UnimplementedViews/UnimplementedView').default as
19-
| UnimplementedViewType
20-
| ProgressBarAndroidNativeComponentType;
18+
export default require('../UnimplementedViews/UnimplementedView')
19+
.default as $FlowFixMe as component(
20+
ref?: React.RefSetter<
21+
React.ElementRef<ProgressBarAndroidNativeComponentType>,
22+
>,
23+
...props: ProgressBarAndroidProps
24+
);
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and 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+
11+
import type {ColorValue} from '../../StyleSheet/StyleSheet';
12+
import type {ViewProps} from '../View/ViewPropTypes';
13+
14+
/**
15+
* Style of the ProgressBar and whether it shows indeterminate progress (e.g. spinner).
16+
*
17+
* `indeterminate` can only be false if `styleAttr` is Horizontal, and requires a
18+
* `progress` value.
19+
*/
20+
type ProgressBarAndroidStyleAttrProp =
21+
| {
22+
styleAttr: 'Horizontal',
23+
indeterminate: false,
24+
progress: number,
25+
}
26+
| {
27+
styleAttr:
28+
| 'Horizontal'
29+
| 'Normal'
30+
| 'Small'
31+
| 'Large'
32+
| 'Inverse'
33+
| 'SmallInverse'
34+
| 'LargeInverse',
35+
indeterminate: true,
36+
};
37+
38+
export type ProgressBarAndroidProps = $ReadOnly<{
39+
...ViewProps,
40+
...ProgressBarAndroidStyleAttrProp,
41+
42+
/**
43+
* Whether to show the ProgressBar (true, the default) or hide it (false).
44+
*/
45+
animating?: ?boolean,
46+
/**
47+
* Color of the progress bar.
48+
*/
49+
color?: ?ColorValue,
50+
/**
51+
* Used to locate this view in end-to-end tests.
52+
*/
53+
testID?: ?string,
54+
}>;

packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,10 +1754,13 @@ declare export default function useAndroidRippleForView(
17541754
`;
17551755

17561756
exports[`public API should not change unintentionally Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js 1`] = `
1757-
"export type { ProgressBarAndroidProps } from \\"./ProgressBarAndroid.android\\";
1758-
declare export default
1759-
| UnimplementedViewType
1760-
| ProgressBarAndroidNativeComponentType;
1757+
"export type { ProgressBarAndroidProps };
1758+
declare export default component(
1759+
ref?: React.RefSetter<
1760+
React.ElementRef<ProgressBarAndroidNativeComponentType>,
1761+
>,
1762+
...props: ProgressBarAndroidProps
1763+
);
17611764
"
17621765
`;
17631766

@@ -1767,6 +1770,34 @@ declare export default typeof ProgressBarAndroidNativeComponent;
17671770
"
17681771
`;
17691772

1773+
exports[`public API should not change unintentionally Libraries/Components/ProgressBarAndroid/ProgressBarAndroidTypes.js 1`] = `
1774+
"type ProgressBarAndroidStyleAttrProp =
1775+
| {
1776+
styleAttr: \\"Horizontal\\",
1777+
indeterminate: false,
1778+
progress: number,
1779+
}
1780+
| {
1781+
styleAttr:
1782+
| \\"Horizontal\\"
1783+
| \\"Normal\\"
1784+
| \\"Small\\"
1785+
| \\"Large\\"
1786+
| \\"Inverse\\"
1787+
| \\"SmallInverse\\"
1788+
| \\"LargeInverse\\",
1789+
indeterminate: true,
1790+
};
1791+
export type ProgressBarAndroidProps = $ReadOnly<{
1792+
...ViewProps,
1793+
...ProgressBarAndroidStyleAttrProp,
1794+
animating?: ?boolean,
1795+
color?: ?ColorValue,
1796+
testID?: ?string,
1797+
}>;
1798+
"
1799+
`;
1800+
17701801
exports[`public API should not change unintentionally Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent.js 1`] = `
17711802
"export * from \\"../../../src/private/specs_DEPRECATED/components/AndroidSwipeRefreshLayoutNativeComponent\\";
17721803
declare export default typeof AndroidSwipeRefreshLayoutNativeComponent;

scripts/build/build-types/buildTypes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const ENTRY_POINTS = [
4444
'packages/react-native/Libraries/Components/Keyboard/Keyboard.js',
4545
'packages/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js',
4646
'packages/react-native/Libraries/Components/Pressable/Pressable.js',
47+
'packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js',
4748
'packages/react-native/Libraries/Components/ToastAndroid/ToastAndroid.js',
4849
'packages/react-native/Libraries/Components/ScrollView/ScrollView.js',
4950
'packages/react-native/Libraries/Interaction/InteractionManager.js',

0 commit comments

Comments
 (0)