-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[webview_flutter_wkwebview] Add support for WKUIDelegate
#4809
Conversation
WKUIDelegate
WKUIDelegate
if (!navigationAction.targetFrame.isMainFrame) { | ||
webView.loadRequest(navigationAction.request); | ||
} | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relevant code from current implementation:
https://github.com/flutter/plugins/blob/main/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FlutterWebView.m#L699
https://github.com/flutter/plugins/blob/main/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FlutterWebView.m#L121
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird. I'm surprised nobody has ever filed a bug about this behavior, because it's pretty surprising.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was surprised by this as well, but it looks like there's an integration test for it.
https://github.com/flutter/plugins/blob/main/packages/webview_flutter/webview_flutter_wkwebview/example/integration_test/webview_flutter_test.dart#L1100
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with nits
packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart
Show resolved
Hide resolved
packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart
Outdated
Show resolved
Hide resolved
packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart
Show resolved
Hide resolved
packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart
Outdated
Show resolved
Hide resolved
packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart
Show resolved
Hide resolved
/// Wraps [WKUIDelegate](https://developer.apple.com/documentation/webkit/wkuidelegate?language=objc). | ||
class WKUIDelegate { | ||
/// Indicates a new [WebView] was requested to be created with [configuration]. | ||
void setOnCreateWebView( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this a function named setFoo
rather than a set foo
? (This may apply to code from previous PRs and I just didn't notice it then.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's my mistake. It was supposed to have a Future<void>
. But, I suppose using set foo
IS more Darty. But it also would be an asynchronous function so I'm not sure which is better. I can't think of an instance where it would need to be awaited though.
if (!navigationAction.targetFrame.isMainFrame) { | ||
webView.loadRequest(navigationAction.request); | ||
} | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird. I'm surprised nobody has ever filed a bug about this behavior, because it's pretty surprising.
packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit_webview_widget_test.dart
Outdated
Show resolved
Hide resolved
* google/master: [webview_flutter_wkwebview] Add support for `WKUIDelegate` (flutter#4809) [camera] Restore compatibility with older Flutter (flutter#4885) [ci.yaml] Migrate to Cocoon scheduler (flutter#4884) Roll Flutter from adafd66 to 93c0c04 (6 revisions) (flutter#4880) [shared_preferences] upgraded ios to using pigeon (flutter#4732)
Add support for
WKUIDelegate
.No version change:
Part of flutter/flutter#93732 and doesn't make any changes to the current implementation.
No CHANGELOG change: Incremental unused code doesn't need to be noted in the CHANGELOG.
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.