Files
react-native/Libraries/Utilities/NativeDeviceInfo.js
T
Emily Janzer 96a5001024 Add spec for DeviceInfo module
Summary: Adding flow types for DeviceInfo module and migrating our codebase over to using `DeviceInfo.getConstants()`

Reviewed By: fkgozali

Differential Revision: D14645744

fbshipit-source-id: e30a060c6dc92938cd1420ba11a1d837c79d1e32
2019-05-29 16:37:15 -07:00

48 lines
1.0 KiB
JavaScript

/**
* Copyright (c) Facebook, Inc. and its 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-local
* @format
*/
'use strict';
import type {TurboModule} from 'RCTExport';
import * as TurboModuleRegistry from 'TurboModuleRegistry';
type DisplayMetricsAndroid = {|
width: number,
height: number,
scale: number,
fontScale: number,
densityDpi: number,
|};
type DisplayMetricsIOS = {|
width: number,
height: number,
scale: number,
fontScale: number,
|};
export interface Spec extends TurboModule {
+getConstants: () => {|
+Dimensions: {
window?: DisplayMetricsIOS,
screen?: DisplayMetricsIOS,
windowPhysicalPixels?: DisplayMetricsAndroid,
screenPhysicalPixels?: DisplayMetricsAndroid,
},
+isIPhoneX_deprecated?: boolean,
|};
}
const NativeModule = TurboModuleRegistry.getEnforcing<Spec>('DeviceInfo');
const NativeDeviceInfo = NativeModule;
export default NativeDeviceInfo;