mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
7fd08e1461
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
42 lines
984 B
JavaScript
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;
|