@capgo/capacitor-inappbrowser 8.10.2 → 8.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -115,6 +115,42 @@ enum ProxyResponseRoutingSupport {
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
|
|
119
|
+
enum StatusBarBackgroundLayoutSupport {
|
|
120
|
+
enum Placement: Equatable {
|
|
121
|
+
case skip
|
|
122
|
+
case host(pinToNavigationBar: Bool)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/// Decide where/how to pin the status-bar chrome without painting a PassThroughView gap.
|
|
126
|
+
static func placement(
|
|
127
|
+
isPassThroughOverlay: Bool,
|
|
128
|
+
blankNavigationTab: Bool,
|
|
129
|
+
navigationBarInHostHierarchy: Bool
|
|
130
|
+
) -> Placement {
|
|
131
|
+
if isPassThroughOverlay && blankNavigationTab {
|
|
132
|
+
// Custom-frame blank overlays must stay transparent in the y-offset gap.
|
|
133
|
+
return .skip
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if blankNavigationTab || !navigationBarInHostHierarchy {
|
|
137
|
+
return .host(pinToNavigationBar: false)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return .host(pinToNavigationBar: true)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
static func hostView(
|
|
144
|
+
navigationControllerView: UIView,
|
|
145
|
+
framedContentView: UIView?
|
|
146
|
+
) -> UIView? {
|
|
147
|
+
if let passThrough = navigationControllerView as? PassThroughView {
|
|
148
|
+
return framedContentView ?? passThrough.framedContentView
|
|
149
|
+
}
|
|
150
|
+
return navigationControllerView
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
118
154
|
enum CustomWebViewFrameSupport {
|
|
119
155
|
static func resolvedFrame(
|
|
120
156
|
width: CGFloat?,
|
|
@@ -162,7 +198,7 @@ public class CapgoInAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
162
198
|
case aware = "AWARE"
|
|
163
199
|
case fakeVisible = "FAKE_VISIBLE"
|
|
164
200
|
}
|
|
165
|
-
private let pluginVersion: String = "8.10.
|
|
201
|
+
private let pluginVersion: String = "8.10.3"
|
|
166
202
|
public let identifier = "CapgoInAppBrowserPlugin"
|
|
167
203
|
public let jsName = "CapgoInAppBrowser"
|
|
168
204
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
@@ -1583,14 +1619,10 @@ public class CapgoInAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
1583
1619
|
// Apply status bar background color via the special view
|
|
1584
1620
|
webViewController.setupStatusBarBackground(color: color)
|
|
1585
1621
|
|
|
1586
|
-
//
|
|
1622
|
+
// Color the webview controller only — never paint PassThroughView or the
|
|
1623
|
+
// y-offset gap would hide the host Capacitor app.
|
|
1587
1624
|
webViewController.view.backgroundColor = color
|
|
1588
|
-
self.
|
|
1589
|
-
|
|
1590
|
-
// Apply status bar background color
|
|
1591
|
-
if let navController = self.navigationWebViewController {
|
|
1592
|
-
navController.view.backgroundColor = color
|
|
1593
|
-
}
|
|
1625
|
+
self.applyBlankToolbarBackground(color, to: self.navigationWebViewController)
|
|
1594
1626
|
} else {
|
|
1595
1627
|
// Follow system appearance if no specific color
|
|
1596
1628
|
let isDarkMode = UITraitCollection.current.userInterfaceStyle == .dark
|
|
@@ -1601,10 +1633,7 @@ public class CapgoInAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
1601
1633
|
// Apply status bar background color via the special view
|
|
1602
1634
|
webViewController.setupStatusBarBackground(color: backgroundColor)
|
|
1603
1635
|
|
|
1604
|
-
|
|
1605
|
-
if let navController = self.navigationWebViewController {
|
|
1606
|
-
navController.view.backgroundColor = backgroundColor
|
|
1607
|
-
}
|
|
1636
|
+
self.applyBlankToolbarBackground(backgroundColor, to: self.navigationWebViewController)
|
|
1608
1637
|
}
|
|
1609
1638
|
|
|
1610
1639
|
}
|
|
@@ -2052,6 +2081,20 @@ public class CapgoInAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
2052
2081
|
}
|
|
2053
2082
|
}
|
|
2054
2083
|
|
|
2084
|
+
|
|
2085
|
+
/// Keep PassThroughView clear so custom y-offsets show the host app behind the gap.
|
|
2086
|
+
private func applyBlankToolbarBackground(_ color: UIColor, to navigationController: UINavigationController?) {
|
|
2087
|
+
guard let navigationController else { return }
|
|
2088
|
+
|
|
2089
|
+
if let passThrough = navigationController.view as? PassThroughView {
|
|
2090
|
+
passThrough.backgroundColor = .clear
|
|
2091
|
+
passThrough.framedContentView?.backgroundColor = color
|
|
2092
|
+
return
|
|
2093
|
+
}
|
|
2094
|
+
|
|
2095
|
+
navigationController.view.backgroundColor = color
|
|
2096
|
+
}
|
|
2097
|
+
|
|
2055
2098
|
private func normalizedAuthorizedHosts(from links: [String]) -> [String] {
|
|
2056
2099
|
links.compactMap { link in
|
|
2057
2100
|
guard let host = URLComponents(string: link)?.host?.lowercased() else {
|
|
@@ -1101,7 +1101,7 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
|
|
|
1101
1101
|
open var statusBarStyle: UIStatusBarStyle = .default
|
|
1102
1102
|
|
|
1103
1103
|
// Status bar background view
|
|
1104
|
-
|
|
1104
|
+
var statusBarBackgroundView: UIView?
|
|
1105
1105
|
|
|
1106
1106
|
// Status bar height
|
|
1107
1107
|
private var statusBarHeight: CGFloat {
|
|
@@ -1151,25 +1151,60 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
|
|
|
1151
1151
|
// Make status bar background with colored view underneath
|
|
1152
1152
|
open func setupStatusBarBackground(color: UIColor) {
|
|
1153
1153
|
statusBarBackgroundView?.removeFromSuperview()
|
|
1154
|
-
statusBarBackgroundView =
|
|
1154
|
+
statusBarBackgroundView = nil
|
|
1155
1155
|
|
|
1156
|
-
guard let navController = navigationController
|
|
1157
|
-
let navView = navController.view,
|
|
1158
|
-
let statusBarBackgroundView else {
|
|
1156
|
+
guard let navController = navigationController else {
|
|
1159
1157
|
return
|
|
1160
1158
|
}
|
|
1161
|
-
navView.insertSubview(statusBarBackgroundView, at: 0)
|
|
1162
|
-
statusBarBackgroundView.translatesAutoresizingMaskIntoConstraints = false
|
|
1163
|
-
statusBarBackgroundView.backgroundColor = color
|
|
1164
1159
|
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1160
|
+
if let passThrough = navController.view as? PassThroughView {
|
|
1161
|
+
// Never paint the full-screen overlay — that fills the custom y-offset gap.
|
|
1162
|
+
passThrough.backgroundColor = .clear
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
let navigationBar = navController.navigationBar
|
|
1166
|
+
let hostCandidate = StatusBarBackgroundLayoutSupport.hostView(
|
|
1167
|
+
navigationControllerView: navController.view,
|
|
1168
|
+
framedContentView: (navController.view as? PassThroughView)?.framedContentView
|
|
1169
|
+
)
|
|
1170
|
+
let navigationBarInHost = hostCandidate.map { navigationBar.isDescendant(of: $0) } ?? false
|
|
1171
|
+
let placement = StatusBarBackgroundLayoutSupport.placement(
|
|
1172
|
+
isPassThroughOverlay: navController.view is PassThroughView,
|
|
1173
|
+
blankNavigationTab: blankNavigationTab,
|
|
1174
|
+
navigationBarInHostHierarchy: navigationBarInHost
|
|
1175
|
+
)
|
|
1176
|
+
|
|
1177
|
+
guard case .host(let pinToNavigationBar) = placement,
|
|
1178
|
+
let hostView = hostCandidate else {
|
|
1179
|
+
return
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
let backgroundView = UIView()
|
|
1183
|
+
statusBarBackgroundView = backgroundView
|
|
1184
|
+
hostView.insertSubview(backgroundView, at: 0)
|
|
1185
|
+
backgroundView.translatesAutoresizingMaskIntoConstraints = false
|
|
1186
|
+
backgroundView.backgroundColor = color
|
|
1187
|
+
|
|
1188
|
+
var constraints = [
|
|
1189
|
+
backgroundView.topAnchor.constraint(equalTo: hostView.topAnchor),
|
|
1190
|
+
backgroundView.leadingAnchor.constraint(equalTo: hostView.leadingAnchor),
|
|
1191
|
+
backgroundView.trailingAnchor.constraint(equalTo: hostView.trailingAnchor)
|
|
1192
|
+
]
|
|
1193
|
+
|
|
1194
|
+
if pinToNavigationBar {
|
|
1195
|
+
constraints.append(
|
|
1196
|
+
backgroundView.bottomAnchor.constraint(equalTo: navigationBar.bottomAnchor, constant: 1)
|
|
1197
|
+
)
|
|
1198
|
+
applyNavigationBarBackground(color: color)
|
|
1199
|
+
} else {
|
|
1200
|
+
// Blank toolbar / detached nav bar: cover status-bar height only.
|
|
1201
|
+
// Avoid pinning to a hidden UINavigationBar (removed from hierarchy → crash).
|
|
1202
|
+
constraints.append(
|
|
1203
|
+
backgroundView.heightAnchor.constraint(equalToConstant: max(statusBarHeight, 20))
|
|
1204
|
+
)
|
|
1205
|
+
}
|
|
1171
1206
|
|
|
1172
|
-
|
|
1207
|
+
NSLayoutConstraint.activate(constraints)
|
|
1173
1208
|
}
|
|
1174
1209
|
|
|
1175
1210
|
// Override to use our custom status bar style
|