-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathOSIABWebViewCallbackHandler.swift
More file actions
35 lines (33 loc) · 2.01 KB
/
OSIABWebViewCallbackHandler.swift
File metadata and controls
35 lines (33 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import UIKit
/// Structure responsible for managing all WebView callbacks to its callers.
public struct OSIABWebViewCallbackHandler {
/// Callback to trigger when the an URL needs to be delegates to its callers.
let onDelegateURL: (URL) -> Void
/// Callback to trigger when the created `UIAlertController` is delegated to its callers.
let onDelegateAlertController: (UIAlertController) -> Void
/// Callback to trigger when the initial page load is performed.
let onBrowserPageLoad: () -> Void
/// Callback to trigger when the browser is closed. The boolean arguments indicates if the browser was already close or still needs to be.
let onBrowserClosed: (Bool) -> Void
/// Callback to trigger when the browser finishes navigation. The argument is the current URL.
let onBrowserPageNavigationCompleted: (String?) -> Void
/// Constructor method.
/// - Parameters:
/// - onDelegateURL: Callback to trigger when the an URL needs to be delegates to its callers.
/// - onDelegateAlertController: Callback to trigger when the created `UIAlertController` is delegated to its callers.
/// - onBrowserPageLoad: Callback to trigger when the initial page load is performed.
/// - onBrowserClosed: Callback to trigger when the browser is closed. The boolean arguments indicates if the browser was already close or still needs to be.
public init(
onDelegateURL: @escaping (URL) -> Void,
onDelegateAlertController: @escaping (UIAlertController) -> Void,
onBrowserPageLoad: @escaping () -> Void,
onBrowserClosed: @escaping (Bool) -> Void, // boolean indicates if the browser is already closed.
onBrowserPageNavigationCompleted: @escaping (String?) -> Void
) {
self.onDelegateURL = onDelegateURL
self.onDelegateAlertController = onDelegateAlertController
self.onBrowserPageLoad = onBrowserPageLoad
self.onBrowserClosed = onBrowserClosed
self.onBrowserPageNavigationCompleted = onBrowserPageNavigationCompleted
}
}