mirror of
https://github.com/status-im/react-native.git
synced 2025-01-13 11:05:21 +00:00
Gate usage of WebKit 10.0 APIs
Reviewed By: mmmulani Differential Revision: D9362001 fbshipit-source-id: 62cde6bcc1f190c168973b173ce55c029328bfbf
This commit is contained in:
parent
28b058c341
commit
33b353c97c
@ -71,7 +71,7 @@ typedef NSURL RCTFileURL;
|
||||
+ (UIDataDetectorTypes)UIDataDetectorTypes:(id)json;
|
||||
#endif
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
#if TARGET_OS_IPHONE && WEBKIT_IOS_10_APIS_AVAILABLE
|
||||
+ (WKDataDetectorTypes)WKDataDetectorTypes:(id)json;
|
||||
#endif
|
||||
|
||||
|
@ -362,6 +362,7 @@ RCT_MULTI_ENUM_CONVERTER(UIDataDetectorTypes, (@{
|
||||
@"all": @(UIDataDetectorTypeAll),
|
||||
}), UIDataDetectorTypePhoneNumber, unsignedLongLongValue)
|
||||
|
||||
#if WEBKIT_IOS_10_APIS_AVAILABLE
|
||||
RCT_MULTI_ENUM_CONVERTER(WKDataDetectorTypes, (@{
|
||||
@"phoneNumber": @(WKDataDetectorTypePhoneNumber),
|
||||
@"link": @(WKDataDetectorTypeLink),
|
||||
@ -373,7 +374,9 @@ RCT_MULTI_ENUM_CONVERTER(WKDataDetectorTypes, (@{
|
||||
@"none": @(WKDataDetectorTypeNone),
|
||||
@"all": @(WKDataDetectorTypeAll),
|
||||
}), WKDataDetectorTypePhoneNumber, unsignedLongLongValue)
|
||||
#endif
|
||||
#endif // WEBKIT_IOS_10_APIS_AVAILABLE
|
||||
|
||||
#endif // !TARGET_OS_TV
|
||||
|
||||
RCT_ENUM_CONVERTER(UIKeyboardAppearance, (@{
|
||||
@"default": @(UIKeyboardAppearanceDefault),
|
||||
|
@ -125,3 +125,8 @@ _Pragma("clang diagnostic ignored \"-Wunused-parameter\"") \
|
||||
RCT_EXTERN NSException *_RCTNotImplementedException(SEL, Class); \
|
||||
method NS_UNAVAILABLE { @throw _RCTNotImplementedException(_cmd, [self class]); } \
|
||||
_Pragma("clang diagnostic pop")
|
||||
|
||||
/**
|
||||
* Check if WebKit iOS 10.0 APIs are available.
|
||||
*/
|
||||
#define WEBKIT_IOS_10_APIS_AVAILABLE __has_include(<WebKit/WKAudiovisualMediaTypes.h>)
|
||||
|
@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#import <React/RCTView.h>
|
||||
#import <React/RCTDefines.h>
|
||||
#import <WebKit/WebKit.h>
|
||||
|
||||
@class RCTWKWebView;
|
||||
@ -31,7 +32,9 @@ shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
|
||||
@property (nonatomic, assign) BOOL allowsInlineMediaPlayback;
|
||||
@property (nonatomic, assign) BOOL bounces;
|
||||
@property (nonatomic, assign) BOOL mediaPlaybackRequiresUserAction;
|
||||
#if WEBKIT_IOS_10_APIS_AVAILABLE
|
||||
@property (nonatomic, assign) WKDataDetectorTypes dataDetectorTypes;
|
||||
#endif
|
||||
@property (nonatomic, assign) UIEdgeInsets contentInset;
|
||||
@property (nonatomic, assign) BOOL automaticallyAdjustContentInsets;
|
||||
|
||||
|
@ -65,10 +65,12 @@ static NSString *const MessageHanderName = @"ReactNative";
|
||||
wkWebViewConfig.userContentController = [WKUserContentController new];
|
||||
[wkWebViewConfig.userContentController addScriptMessageHandler: self name: MessageHanderName];
|
||||
wkWebViewConfig.allowsInlineMediaPlayback = _allowsInlineMediaPlayback;
|
||||
#if WEBKIT_IOS_10_APIS_AVAILABLE
|
||||
wkWebViewConfig.mediaTypesRequiringUserActionForPlayback = _mediaPlaybackRequiresUserAction
|
||||
? WKAudiovisualMediaTypeAll
|
||||
: WKAudiovisualMediaTypeNone;
|
||||
wkWebViewConfig.dataDetectorTypes = _dataDetectorTypes;
|
||||
#endif
|
||||
|
||||
_webView = [[WKWebView alloc] initWithFrame:self.bounds configuration: wkWebViewConfig];
|
||||
_webView.scrollView.delegate = self;
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#import "RCTUIManager.h"
|
||||
#import "RCTWKWebView.h"
|
||||
#import <React/RCTDefines.h>
|
||||
|
||||
@interface RCTWKWebViewManager () <RCTWKWebViewDelegate>
|
||||
@end
|
||||
@ -29,7 +30,9 @@ RCT_EXPORT_VIEW_PROPERTY(onShouldStartLoadWithRequest, RCTDirectEventBlock)
|
||||
RCT_EXPORT_VIEW_PROPERTY(injectedJavaScript, NSString)
|
||||
RCT_EXPORT_VIEW_PROPERTY(allowsInlineMediaPlayback, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(mediaPlaybackRequiresUserAction, BOOL)
|
||||
#if WEBKIT_IOS_10_APIS_AVAILABLE
|
||||
RCT_EXPORT_VIEW_PROPERTY(dataDetectorTypes, WKDataDetectorTypes)
|
||||
#endif
|
||||
RCT_EXPORT_VIEW_PROPERTY(contentInset, UIEdgeInsets)
|
||||
RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets, BOOL)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user