mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
e883197807
Summary: A reland of https://github.com/facebook/react-native/commit/f26ffbf5618d88b93fb84dd560303fe2e215cb2d Reviewed By: sammy-SC Differential Revision: D16091073 fbshipit-source-id: 09660ba987c3035333eac55e6bb94373fad9252b
76 lines
1.8 KiB
Plaintext
76 lines
1.8 KiB
Plaintext
/**
|
|
* 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.
|
|
*/
|
|
|
|
#import <UIKit/UIKit.h>
|
|
|
|
#import <FBReactNativeSpec/FBReactNativeSpec.h>
|
|
#import <React/RCTPlatform.h>
|
|
#import <React/RCTUtils.h>
|
|
#import <React/RCTVersion.h>
|
|
|
|
#import "CoreModulesPlugins.h"
|
|
|
|
using namespace facebook::react;
|
|
|
|
static NSString *interfaceIdiom(UIUserInterfaceIdiom idiom) {
|
|
switch(idiom) {
|
|
case UIUserInterfaceIdiomPhone:
|
|
return @"phone";
|
|
case UIUserInterfaceIdiomPad:
|
|
return @"pad";
|
|
case UIUserInterfaceIdiomTV:
|
|
return @"tv";
|
|
case UIUserInterfaceIdiomCarPlay:
|
|
return @"carplay";
|
|
default:
|
|
return @"unknown";
|
|
}
|
|
}
|
|
|
|
@interface RCTPlatform () <NativePlatformConstantsIOSSpec>
|
|
@end
|
|
|
|
@implementation RCTPlatform
|
|
|
|
RCT_EXPORT_MODULE(PlatformConstants)
|
|
|
|
+ (BOOL)requiresMainQueueSetup
|
|
{
|
|
return YES;
|
|
}
|
|
|
|
// TODO: Use the generated struct return type.
|
|
- (NSDictionary<NSString *, id> *)constantsToExport
|
|
{
|
|
return [self getConstants];
|
|
}
|
|
|
|
// TODO: Use the generated struct return type.
|
|
- (NSDictionary<NSString *, id> *)getConstants
|
|
{
|
|
UIDevice *device = [UIDevice currentDevice];
|
|
return @{
|
|
@"forceTouchAvailable": @(RCTForceTouchAvailable()),
|
|
@"osVersion": [device systemVersion],
|
|
@"systemName": [device systemName],
|
|
@"interfaceIdiom": interfaceIdiom([device userInterfaceIdiom]),
|
|
@"isTesting": @(RCTRunningInTestEnvironment()),
|
|
@"reactNativeVersion": RCTGetReactNativeVersion(),
|
|
};
|
|
}
|
|
|
|
- (std::shared_ptr<TurboModule>)getTurboModuleWithJsInvoker:(std::shared_ptr<JSCallInvoker>)jsInvoker
|
|
{
|
|
return std::make_shared<NativePlatformConstantsIOSSpecJSI>(self, jsInvoker);
|
|
}
|
|
|
|
@end
|
|
|
|
Class RCTPlatformCls(void) {
|
|
return RCTPlatform.class;
|
|
}
|