mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-26 23:05:00 +08:00
Merge AndroidConstants and IOSConstants into PlatformConstants
Reviewed By: AaaChiuuu Differential Revision: D4597790 fbshipit-source-id: 0a54598d6e9cadb75efff4ac17c13899d6785f9b
This commit is contained in:
committed by
Facebook Github Bot
parent
68135d90a4
commit
dba133a291
@@ -12,14 +12,16 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeModules = require('NativeModules');
|
||||
|
||||
const Platform = {
|
||||
OS: 'android',
|
||||
get Version() {
|
||||
const AndroidConstants = require('NativeModules').AndroidConstants;
|
||||
return AndroidConstants && AndroidConstants.Version;
|
||||
const constants = NativeModules.PlatformConstants;
|
||||
return constants && constants.Version;
|
||||
},
|
||||
get isTesting(): boolean {
|
||||
const constants = require('NativeModules').AndroidConstants;
|
||||
const constants = NativeModules.PlatformConstants;
|
||||
return constants && constants.isTesting;
|
||||
},
|
||||
select: (obj: Object) => 'android' in obj ? obj.android : obj.default,
|
||||
|
||||
@@ -12,18 +12,24 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeModules = require('NativeModules');
|
||||
|
||||
const Platform = {
|
||||
OS: 'ios',
|
||||
get Version() {
|
||||
const constants = require('NativeModules').IOSConstants;
|
||||
return constants ? constants.osVersion : '';
|
||||
const constants = NativeModules.PlatformConstants;
|
||||
return constants && constants.osVersion;
|
||||
},
|
||||
get isPad() {
|
||||
const constants = NativeModules.PlatformConstants;
|
||||
return constants ? constants.interfaceIdiom === 'pad' : false;
|
||||
},
|
||||
get isTVOS() {
|
||||
const constants = require('NativeModules').IOSConstants;
|
||||
return constants ? (constants.interfaceIdiom === 'tv') : false;
|
||||
const constants = NativeModules.PlatformConstants;
|
||||
return constants ? constants.interfaceIdiom === 'tv' : false;
|
||||
},
|
||||
get isTesting(): boolean {
|
||||
const constants = require('NativeModules').IOSConstants;
|
||||
const constants = NativeModules.PlatformConstants;
|
||||
return constants && constants.isTesting;
|
||||
},
|
||||
select: (obj: Object) => 'ios' in obj ? obj.ios : obj.default,
|
||||
|
||||
Reference in New Issue
Block a user