2
2
// Use of this source code is governed by a BSD-style license that can be
3
3
// found in the LICENSE file.
4
4
5
+ import 'package:flutter/foundation.dart' ;
6
+
7
+ import '../foundation/foundation.dart' ;
8
+
5
9
/// Times at which to inject script content into a webpage.
6
10
///
7
11
/// Wraps [WKUserScriptInjectionTime] (https://developer.apple.com/documentation/webkit/wkuserscriptinjectiontime?language=objc).
@@ -42,12 +46,43 @@ enum WKAudiovisualMediaType {
42
46
all,
43
47
}
44
48
49
+ /// An object that contains information about an action that causes navigation to occur.
50
+ ///
51
+ /// Wraps [WKNavigationAction] (https://developer.apple.com/documentation/webkit/wknavigationaction?language=objc).
52
+ @immutable
53
+ class WKNavigationAction {
54
+ /// Constructs a [WKNavigationAction] .
55
+ const WKNavigationAction ({required this .request, required this .targetFrame});
56
+
57
+ /// The URL request object associated with the navigation action.
58
+ final NSUrlRequest request;
59
+
60
+ /// The frame in which to display the new content.
61
+ final WKFrameInfo targetFrame;
62
+ }
63
+
64
+ /// An object that contains information about a frame on a webpage.
65
+ ///
66
+ /// An instance of this class is a transient, data-only object; it does not
67
+ /// uniquely identify a frame across multiple delegate method calls.
68
+ ///
69
+ /// Wraps [WKFrameInfo] (https://developer.apple.com/documentation/webkit/wkframeinfo?language=objc).
70
+ @immutable
71
+ class WKFrameInfo {
72
+ /// Construct a [WKFrameInfo] .
73
+ const WKFrameInfo ({required this .isMainFrame});
74
+
75
+ /// Indicates whether the frame is the web site's main frame or a subframe.
76
+ final bool isMainFrame;
77
+ }
78
+
45
79
/// A script that the web view injects into a webpage.
46
80
///
47
81
/// Wraps [WKUserScript] (https://developer.apple.com/documentation/webkit/wkuserscript?language=objc).
82
+ @immutable
48
83
class WKUserScript {
49
84
/// Constructs a [UserScript] .
50
- WKUserScript (
85
+ const WKUserScript (
51
86
this .source,
52
87
this .injectionTime, {
53
88
required this .isMainFrameOnly,
@@ -66,9 +101,10 @@ class WKUserScript {
66
101
/// An object that encapsulates a message sent by JavaScript code from a webpage.
67
102
///
68
103
/// Wraps [WKScriptMessage] (https://developer.apple.com/documentation/webkit/wkscriptmessage?language=objc).
104
+ @immutable
69
105
class WKScriptMessage {
70
106
/// Constructs a [WKScriptMessage] .
71
- WKScriptMessage ({required this .name, this .body});
107
+ const WKScriptMessage ({required this .name, this .body});
72
108
73
109
/// The name of the message handler to which the message is sent.
74
110
final String name;
@@ -88,7 +124,7 @@ class WKScriptMessageHandler {
88
124
/// Use this method to respond to a message sent from the webpage’s
89
125
/// JavaScript code. Use the [message] parameter to get the message contents and
90
126
/// to determine the originating web view.
91
- Future < void > setDidReceiveScriptMessage (
127
+ set didReceiveScriptMessage (
92
128
void Function (
93
129
WKUserContentController userContentController,
94
130
WKScriptMessage message,
@@ -169,7 +205,7 @@ class WKUserContentController {
169
205
170
206
/// A collection of properties that you use to initialize a web view.
171
207
///
172
- /// Wraps [WKWebViewConfiguration] (https://developer.apple.com/documentation/webkit/wkwebviewconfiguration?language=objc)
208
+ /// Wraps [WKWebViewConfiguration] (https://developer.apple.com/documentation/webkit/wkwebviewconfiguration?language=objc).
173
209
class WKWebViewConfiguration {
174
210
/// Constructs a [WKWebViewConfiguration] .
175
211
WKWebViewConfiguration ({required this .userContentController});
@@ -202,6 +238,22 @@ class WKWebViewConfiguration {
202
238
}
203
239
}
204
240
241
+ /// The methods for presenting native user interface elements on behalf of a webpage.
242
+ ///
243
+ /// Wraps [WKUIDelegate] (https://developer.apple.com/documentation/webkit/wkuidelegate?language=objc).
244
+ class WKUIDelegate {
245
+ /// Indicates a new [WebView] was requested to be created with [configuration] .
246
+ set onCreateWebView (
247
+ void Function (
248
+ WKWebViewConfiguration configuration,
249
+ WKNavigationAction navigationAction,
250
+ )
251
+ onCreateeWebView,
252
+ ) {
253
+ throw UnimplementedError ();
254
+ }
255
+ }
256
+
205
257
/// Object that displays interactive web content, such as for an in-app browser.
206
258
///
207
259
/// Wraps [WKWebView] (https://developer.apple.com/documentation/webkit/wkwebview?language=objc).
@@ -232,4 +284,17 @@ class WKWebView {
232
284
/// property contains a default configuration object.
233
285
late final WKWebViewConfiguration configuration =
234
286
WKWebViewConfiguration ._fromWebView (this );
287
+
288
+ /// Used to integrate custom user interface elements into web view interactions.
289
+ set uiDelegate (WKUIDelegate delegate) {
290
+ throw UnimplementedError ();
291
+ }
292
+
293
+ /// Loads the web content referenced by the specified URL request object and navigates to it.
294
+ ///
295
+ /// Use this method to load a page from a local or network-based URL. For
296
+ /// example, you might use it to navigate to a network-based webpage.
297
+ Future <void > loadRequest (NSUrlRequest request) {
298
+ throw UnimplementedError ();
299
+ }
235
300
}
0 commit comments