Merge branch 'master' into @salakar/bugfix/androidx-rn60
This commit is contained in:
commit
89f5117c08
|
@ -150,6 +150,25 @@
|
|||
"contributions": [
|
||||
"doc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "TMomemt",
|
||||
"name": "TMomemt",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/42024947?v=4",
|
||||
"profile": "https://github.com/TMomemt",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "ericlewis",
|
||||
"name": "Eric Lewis",
|
||||
"avatar_url": "https://avatars0.githubusercontent.com/u/674503?v=4",
|
||||
"profile": "http://www.try.com",
|
||||
"contributions": [
|
||||
"code",
|
||||
"doc"
|
||||
]
|
||||
}
|
||||
],
|
||||
"contributorsPerLine": 7
|
||||
|
|
|
@ -42,6 +42,7 @@ This document lays out the current public properties and methods for the React N
|
|||
- [`useWebKit`](Reference.md#usewebkit)
|
||||
- [`url`](Reference.md#url)
|
||||
- [`html`](Reference.md#html)
|
||||
- [`keyboardDisplayRequiresUserAction`](Reference.md#keyboardDisplayRequiresUserAction)
|
||||
- [`hideKeyboardAccessoryView`](Reference.md#hidekeyboardaccessoryview)
|
||||
- [`allowsBackForwardNavigationGestures`](Reference.md#allowsbackforwardnavigationgestures)
|
||||
- [`incognito`](Reference.md#incognito)
|
||||
|
@ -756,6 +757,16 @@ If true, use WKWebView instead of UIWebView.
|
|||
|
||||
---
|
||||
|
||||
### `keyboardDisplayRequiresUserAction`
|
||||
|
||||
If false, web content can programmatically display the keyboard when using the WKWebView. The default value is `true`.
|
||||
|
||||
| Type | Required | Platform |
|
||||
| ------- | -------- | -------- |
|
||||
| boolean | No | iOS |
|
||||
|
||||
---
|
||||
|
||||
### `hideKeyboardAccessoryView`
|
||||
|
||||
If true, this will hide the keyboard accessory view (< > and Done) when using the WKWebView.
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#endif
|
||||
@property (nonatomic, assign) UIEdgeInsets contentInset;
|
||||
@property (nonatomic, assign) BOOL automaticallyAdjustContentInsets;
|
||||
@property (nonatomic, assign) BOOL keyboardDisplayRequiresUserAction;
|
||||
@property (nonatomic, assign) BOOL hideKeyboardAccessoryView;
|
||||
@property (nonatomic, assign) BOOL allowsBackForwardNavigationGestures;
|
||||
@property (nonatomic, assign) BOOL incognito;
|
||||
|
|
|
@ -41,6 +41,13 @@ static NSURLCredential* clientAuthenticationCredential;
|
|||
{
|
||||
UIColor * _savedBackgroundColor;
|
||||
BOOL _savedHideKeyboardAccessoryView;
|
||||
BOOL _savedKeyboardDisplayRequiresUserAction;
|
||||
|
||||
// Workaround for StatusBar appearance bug for iOS 12
|
||||
// https://github.com/react-native-community/react-native-webview/issues/62
|
||||
BOOL _isFullScreenVideoOpen;
|
||||
UIStatusBarStyle _savedStatusBarStyle;
|
||||
BOOL _savedStatusBarHidden;
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
|
@ -54,11 +61,14 @@ static NSURLCredential* clientAuthenticationCredential;
|
|||
_directionalLockEnabled = YES;
|
||||
_automaticallyAdjustContentInsets = YES;
|
||||
_contentInset = UIEdgeInsetsZero;
|
||||
_savedKeyboardDisplayRequiresUserAction = YES;
|
||||
_savedStatusBarStyle = RCTSharedApplication().statusBarStyle;
|
||||
_savedStatusBarHidden = RCTSharedApplication().statusBarHidden;
|
||||
}
|
||||
|
||||
// Workaround for a keyboard dismissal bug present in iOS 12
|
||||
// https://openradar.appspot.com/radar?id=5018321736957952
|
||||
if (@available(iOS 12.0, *)) {
|
||||
// Workaround for a keyboard dismissal bug present in iOS 12
|
||||
// https://openradar.appspot.com/radar?id=5018321736957952
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(keyboardWillHide)
|
||||
|
@ -67,8 +77,12 @@ static NSURLCredential* clientAuthenticationCredential;
|
|||
addObserver:self
|
||||
selector:@selector(keyboardWillShow)
|
||||
name:UIKeyboardWillShowNotification object:nil];
|
||||
|
||||
// Workaround for StatusBar appearance bug for iOS 12
|
||||
// https://github.com/react-native-community/react-native-webview/issues/62
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(toggleFullScreenVideoStatusBars) name:@"_MRMediaRemotePlayerSupportedCommandsDidChangeNotification" object:nil];
|
||||
}
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -214,6 +228,7 @@ static NSURLCredential* clientAuthenticationCredential;
|
|||
|
||||
[self addSubview:_webView];
|
||||
[self setHideKeyboardAccessoryView: _savedHideKeyboardAccessoryView];
|
||||
[self setKeyboardDisplayRequiresUserAction: _savedKeyboardDisplayRequiresUserAction];
|
||||
[self visitSource];
|
||||
}
|
||||
}
|
||||
|
@ -238,6 +253,24 @@ static NSURLCredential* clientAuthenticationCredential;
|
|||
[super removeFromSuperview];
|
||||
}
|
||||
|
||||
-(void)toggleFullScreenVideoStatusBars
|
||||
{
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
if (!_isFullScreenVideoOpen) {
|
||||
_isFullScreenVideoOpen = YES;
|
||||
RCTUnsafeExecuteOnMainQueueSync(^{
|
||||
[RCTSharedApplication() setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
|
||||
});
|
||||
} else {
|
||||
_isFullScreenVideoOpen = NO;
|
||||
RCTUnsafeExecuteOnMainQueueSync(^{
|
||||
[RCTSharedApplication() setStatusBarHidden:_savedStatusBarHidden animated:YES];
|
||||
[RCTSharedApplication() setStatusBarStyle:_savedStatusBarStyle animated:YES];
|
||||
});
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
-(void)keyboardWillHide
|
||||
{
|
||||
keyboardTimer = [NSTimer scheduledTimerWithTimeInterval:0 target:self selector:@selector(keyboardDisplacementFix) userInfo:nil repeats:false];
|
||||
|
@ -364,6 +397,64 @@ static NSURLCredential* clientAuthenticationCredential;
|
|||
}
|
||||
}
|
||||
|
||||
-(void)setKeyboardDisplayRequiresUserAction:(BOOL)keyboardDisplayRequiresUserAction
|
||||
{
|
||||
if (_webView == nil) {
|
||||
_savedKeyboardDisplayRequiresUserAction = keyboardDisplayRequiresUserAction;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_savedKeyboardDisplayRequiresUserAction == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
UIView* subview;
|
||||
|
||||
for (UIView* view in _webView.scrollView.subviews) {
|
||||
if([[view.class description] hasPrefix:@"WK"])
|
||||
subview = view;
|
||||
}
|
||||
|
||||
if(subview == nil) return;
|
||||
|
||||
Class class = subview.class;
|
||||
|
||||
NSOperatingSystemVersion iOS_11_3_0 = (NSOperatingSystemVersion){11, 3, 0};
|
||||
NSOperatingSystemVersion iOS_12_2_0 = (NSOperatingSystemVersion){12, 2, 0};
|
||||
|
||||
Method method;
|
||||
IMP override;
|
||||
|
||||
if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_12_2_0]) {
|
||||
// iOS 12.2.0 - Future
|
||||
SEL selector = sel_getUid("_elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:");
|
||||
method = class_getInstanceMethod(class, selector);
|
||||
IMP original = method_getImplementation(method);
|
||||
override = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, BOOL arg3, id arg4) {
|
||||
((void (*)(id, SEL, void*, BOOL, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3, arg4);
|
||||
});
|
||||
}
|
||||
else if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_11_3_0]) {
|
||||
// iOS 11.3.0 - 12.2.0
|
||||
SEL selector = sel_getUid("_startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:");
|
||||
method = class_getInstanceMethod(class, selector);
|
||||
IMP original = method_getImplementation(method);
|
||||
override = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, BOOL arg3, id arg4) {
|
||||
((void (*)(id, SEL, void*, BOOL, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3, arg4);
|
||||
});
|
||||
} else {
|
||||
// iOS 9.0 - 11.3.0
|
||||
SEL selector = sel_getUid("_startAssistingNode:userIsInteracting:blurPreviousNode:userObject:");
|
||||
method = class_getInstanceMethod(class, selector);
|
||||
IMP original = method_getImplementation(method);
|
||||
override = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, id arg3) {
|
||||
((void (*)(id, SEL, void*, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3);
|
||||
});
|
||||
}
|
||||
|
||||
method_setImplementation(method, override);
|
||||
}
|
||||
|
||||
-(void)setHideKeyboardAccessoryView:(BOOL)hideKeyboardAccessoryView
|
||||
{
|
||||
if (_webView == nil) {
|
||||
|
@ -460,7 +551,7 @@ static NSURLCredential* clientAuthenticationCredential;
|
|||
{
|
||||
NSDictionary *event = @{
|
||||
@"url": _webView.URL.absoluteString ?: @"",
|
||||
@"title": _webView.title,
|
||||
@"title": _webView.title ?: @"",
|
||||
@"loading" : @(_webView.loading),
|
||||
@"canGoBack": @(_webView.canGoBack),
|
||||
@"canGoForward" : @(_webView.canGoForward)
|
||||
|
|
|
@ -101,6 +101,10 @@ RCT_CUSTOM_VIEW_PROPERTY(showsVerticalScrollIndicator, BOOL, RNCWKWebView) {
|
|||
view.showsVerticalScrollIndicator = json == nil ? true : [RCTConvert BOOL: json];
|
||||
}
|
||||
|
||||
RCT_CUSTOM_VIEW_PROPERTY(keyboardDisplayRequiresUserAction, BOOL, RNCWKWebView) {
|
||||
view.keyboardDisplayRequiresUserAction = json == nil ? true : [RCTConvert BOOL: json];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(injectJavaScript:(nonnull NSNumber *)reactTag script:(NSString *)script)
|
||||
{
|
||||
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCWKWebView *> *viewRegistry) {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
"Thibault Malbranche <malbranche.thibault@gmail.com>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"version": "5.7.0",
|
||||
"version": "5.8.1",
|
||||
"homepage": "https://github.com/react-native-community/react-native-webview#readme",
|
||||
"scripts": {
|
||||
"ci": "CI=true && yarn lint && yarn test",
|
||||
|
|
|
@ -91,7 +91,7 @@ export interface WebViewNativeEvent {
|
|||
lockIdentifier: number;
|
||||
}
|
||||
|
||||
export interface WebViewProgressEvent extends WebViewNativeEvent {
|
||||
export interface WebViewNativeProgressEvent extends WebViewNativeEvent {
|
||||
progress: number;
|
||||
}
|
||||
|
||||
|
@ -122,6 +122,8 @@ export interface WebViewError extends WebViewNativeEvent {
|
|||
|
||||
export type WebViewEvent = NativeSyntheticEvent<WebViewNativeEvent>;
|
||||
|
||||
export type WebViewProgressEvent = NativeSyntheticEvent<WebViewNativeProgressEvent>;
|
||||
|
||||
export type WebViewNavigationEvent = NativeSyntheticEvent<WebViewNavigation>;
|
||||
|
||||
export type WebViewMessageEvent = NativeSyntheticEvent<WebViewMessage>;
|
||||
|
@ -401,6 +403,18 @@ export interface IOSWebViewProps extends WebViewSharedProps {
|
|||
*/
|
||||
directionalLockEnabled?: boolean;
|
||||
|
||||
/**
|
||||
* A Boolean value indicating whether web content can programmatically display the keyboard.
|
||||
*
|
||||
* When this property is set to true, the user must explicitly tap the elements in the
|
||||
* web view to display the keyboard (or other relevant input view) for that element.
|
||||
* When set to false, a focus event on an element causes the input view to be displayed
|
||||
* and associated with that element automatically.
|
||||
*
|
||||
* The default value is `true`.
|
||||
* @platform ios
|
||||
*/
|
||||
keyboardDisplayRequiresUserAction?: boolean;
|
||||
}
|
||||
|
||||
export interface AndroidWebViewProps extends WebViewSharedProps {
|
||||
|
|
Loading…
Reference in New Issue