diff --git a/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js index d3a722dea6f974..98b754ce8012c7 100644 --- a/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +++ b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js @@ -181,7 +181,9 @@ class DrawerLayoutAndroid extends React.Component { ...props } = this.props; const drawStatusBar = - Platform.Version >= 21 && this.props.statusBarBackgroundColor != null; + Platform.OS === 'android' && + Platform.Version >= 21 && + this.props.statusBarBackgroundColor != null; const drawerViewWrapper = ( = { - android?: T, - native?: T, - default?: T, - ... -}; +import NativePlatformConstantsAndroid from './NativePlatformConstantsAndroid'; -const Platform = { +const Platform: PlatformType = { __constants: null, OS: 'android', // $FlowFixMe[unsafe-getters-setters] diff --git a/packages/react-native/Libraries/Utilities/Platform.flow.js b/packages/react-native/Libraries/Utilities/Platform.flow.js new file mode 100644 index 00000000000000..d4bc8147249e36 --- /dev/null +++ b/packages/react-native/Libraries/Utilities/Platform.flow.js @@ -0,0 +1,84 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict + * @format + */ + +export type PlatformSelectSpec = { + default?: T, + native?: T, + ios?: T, + android?: T, + ... +}; + +type IOSPlatform = { + __constants: null, + OS: $TEMPORARY$string<'ios'>, + // $FlowFixMe[unsafe-getters-setters] + get Version(): string, + // $FlowFixMe[unsafe-getters-setters] + get constants(): {| + forceTouchAvailable: boolean, + interfaceIdiom: string, + isTesting: boolean, + isDisableAnimations?: boolean, + osVersion: string, + reactNativeVersion: {| + major: number, + minor: number, + patch: number, + prerelease: ?number, + |}, + systemName: string, + |}, + // $FlowFixMe[unsafe-getters-setters] + get isPad(): boolean, + // $FlowFixMe[unsafe-getters-setters] + get isTV(): boolean, + // $FlowFixMe[unsafe-getters-setters] + get isTesting(): boolean, + // $FlowFixMe[unsafe-getters-setters] + get isDisableAnimations(): boolean, + select: (spec: PlatformSelectSpec) => T, +}; + +type AndroidPlatform = { + __constants: null, + OS: $TEMPORARY$string<'android'>, + // $FlowFixMe[unsafe-getters-setters] + get Version(): number, + // $FlowFixMe[unsafe-getters-setters] + get constants(): {| + isTesting: boolean, + isDisableAnimations?: boolean, + reactNativeVersion: {| + major: number, + minor: number, + patch: number, + prerelease: ?number, + |}, + Version: number, + Release: string, + Serial: string, + Fingerprint: string, + Model: string, + ServerHost?: string, + uiMode: string, + Brand: string, + Manufacturer: string, + |}, + // $FlowFixMe[unsafe-getters-setters] + get isTV(): boolean, + // $FlowFixMe[unsafe-getters-setters] + get isTesting(): boolean, + // $FlowFixMe[unsafe-getters-setters] + get isDisableAnimations(): boolean, + select: (spec: PlatformSelectSpec) => T, +}; + +export type Platform = IOSPlatform | AndroidPlatform; diff --git a/packages/react-native/Libraries/Utilities/Platform.ios.js b/packages/react-native/Libraries/Utilities/Platform.ios.js index 4d0217a80945f4..53371634e7d9f7 100644 --- a/packages/react-native/Libraries/Utilities/Platform.ios.js +++ b/packages/react-native/Libraries/Utilities/Platform.ios.js @@ -8,16 +8,14 @@ * @flow strict */ -import NativePlatformConstantsIOS from './NativePlatformConstantsIOS'; +import type { + Platform as PlatformType, + PlatformSelectSpec, +} from './Platform.flow'; -export type PlatformSelectSpec = { - default?: T, - native?: T, - ios?: T, - ... -}; +import NativePlatformConstantsIOS from './NativePlatformConstantsIOS'; -const Platform = { +const Platform: PlatformType = { __constants: null, OS: 'ios', // $FlowFixMe[unsafe-getters-setters]