Files
react-native/Libraries/Utilities/Platform.ios.js
T
Tom Sanderson 7fd08e1461 add spec for PlatformConstants (#24928)
Summary:
part of #24875.

## Changelog

[General] [Added] - add TM spec for PlatformConstants
Pull Request resolved: https://github.com/facebook/react-native/pull/24928

Reviewed By: RSNara

Differential Revision: D15551340

Pulled By: fkgozali

fbshipit-source-id: 9de15ff4cfe717f963332868bd873d5147a37506
2019-05-30 14:29:42 -07:00

51 lines
1.1 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.
*
* @format
* @flow
*/
'use strict';
import NativePlatformConstantsIOS from './NativePlatformConstantsIOS';
export type PlatformSelectSpec<D, I> = {
default?: D,
ios?: I,
};
const Platform = {
OS: 'ios',
get Version() {
return NativePlatformConstantsIOS.getConstants().osVersion;
},
get constants() {
return NativePlatformConstantsIOS.getConstants();
},
get isPad() {
return NativePlatformConstantsIOS.getConstants().interfaceIdiom === 'pad';
},
/**
* Deprecated, use `isTV` instead.
*/
get isTVOS() {
return Platform.isTV;
},
get isTV() {
return NativePlatformConstantsIOS.getConstants().interfaceIdiom === 'tv';
},
get isTesting(): boolean {
if (__DEV__) {
return NativePlatformConstantsIOS.getConstants().isTesting;
}
return false;
},
select: <D, I>(spec: PlatformSelectSpec<D, I>): D | I =>
'ios' in spec ? spec.ios : spec.default,
};
module.exports = Platform;