Files
react-native/Libraries/Utilities/Platform.android.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

42 lines
984 B
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 NativePlatformConstantsAndroid from './NativePlatformConstantsAndroid';
export type PlatformSelectSpec<A, D> = {
android?: A,
default?: D,
};
const Platform = {
OS: 'android',
get Version() {
return NativePlatformConstantsAndroid.getConstants().Version;
},
get constants() {
return NativePlatformConstantsAndroid.getConstants();
},
get isTesting(): boolean {
if (__DEV__) {
return NativePlatformConstantsAndroid.getConstants().isTesting;
}
return false;
},
get isTV(): boolean {
return NativePlatformConstantsAndroid.getConstants().uiMode === 'tv';
},
select: <A, D>(spec: PlatformSelectSpec<A, D>): A | D =>
'android' in spec ? spec.android : spec.default,
};
module.exports = Platform;