-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Allow specifying a navigation delegate (iOS implementation). #1323
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| <plist version="1.0"> | ||
| <dict> | ||
| <key>IDEDidComputeMac32BitWarning</key> | ||
| <true/> | ||
| </dict> | ||
| </plist> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| <plist version="1.0"> | ||
| <dict> | ||
| <key>BuildSystemType</key> | ||
| <string>Original</string> | ||
| </dict> | ||
| </plist> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Copyright 2018 The Chromium Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #import <Flutter/Flutter.h> | ||
| #import <WebKit/WebKit.h> | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| @interface FLTWKNavigationDelegate : NSObject <WKNavigationDelegate> | ||
|
|
||
| - (instancetype)initWithChannel:(FlutterMethodChannel*)channel; | ||
|
|
||
| /** | ||
| * Whether to delegate navigation decisions over the method channel. | ||
| */ | ||
| @property(nonatomic, assign) BOOL hasDartNavigationDelegate; | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,39 @@ | ||||||
| // Copyright 2018 The Chromium Authors. All rights reserved. | ||||||
cyanglaz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| // Use of this source code is governed by a BSD-style license that can be | ||||||
| // found in the LICENSE file. | ||||||
|
|
||||||
| #import "FLTWKNavigationDelegate.h" | ||||||
|
|
||||||
| @implementation FLTWKNavigationDelegate { | ||||||
| FlutterMethodChannel* _methodChannel; | ||||||
| } | ||||||
|
|
||||||
| - (instancetype)initWithChannel:(FlutterMethodChannel*)channel { | ||||||
| self = [super init]; | ||||||
| if (self) { | ||||||
| _methodChannel = channel; | ||||||
| } | ||||||
| return self; | ||||||
| } | ||||||
|
|
||||||
| - (void)webView:(WKWebView*)webView | ||||||
| decidePolicyForNavigationAction:(WKNavigationAction*)navigationAction | ||||||
| decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { | ||||||
| if (!self.hasDartNavigationDelegate) { | ||||||
| decisionHandler(WKNavigationActionPolicyAllow); | ||||||
| return; | ||||||
| } | ||||||
| NSDictionary* arguments = @{ | ||||||
| @"url" : navigationAction.request.URL.absoluteString, | ||||||
| @"isMainFrame" : [NSNumber numberWithBool:navigationAction.targetFrame.isMainFrame] | ||||||
|
||||||
| @"isMainFrame" : [NSNumber numberWithBool:navigationAction.targetFrame.isMainFrame] | |
| @"isMainFrame" : @(navigationAction.targetFrame.isMainFrame) |
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.
sweet!
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.
Is there a possibility for the dart side code to fail and the result block not getting triggered?
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.
good catch, it shouldn't ever happen, but added some better logging in case it does.
Uh oh!
There was an error while loading. Please reload this page.