@capgo/inappbrowser 1.2.4 → 1.2.8

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.
package/README.md CHANGED
@@ -229,6 +229,9 @@ Remove all listeners for this plugin.
229
229
  | **`closeModalDescription`** | <code>string</code> | CloseModalDescription: description of the confirm when user clicks on close button, only on IOS | <code>'Are you sure you want to close this window?'</code> | 1.1.0 |
230
230
  | **`closeModalOk`** | <code>string</code> | CloseModalOk: text of the confirm button when user clicks on close button, only on IOS | <code>'Close'</code> | 1.1.0 |
231
231
  | **`closeModalCancel`** | <code>string</code> | CloseModalCancel: text of the cancel button when user clicks on close button, only on IOS | <code>'Cancel'</code> | 1.1.0 |
232
+ | **`visibleTitle`** | <code>boolean</code> | visibleTitle: if true the website title would be shown else shown empty | <code>true</code> | 1.2.5 |
233
+ | **`toolbarColor`** | <code>string</code> | toolbarColor: color of the toolbar in hex format | <code>'#ffffff''</code> | 1.2.5 |
234
+ | **`showArrow`** | <code>boolean</code> | showArrow: if true an arrow would be shown instead of cross for closing the window | <code>false</code> | 1.2.5 |
232
235
 
233
236
 
234
237
  #### DisclaimerOptions
@@ -4,6 +4,7 @@ import android.content.ComponentName;
4
4
  import android.content.Intent;
5
5
  import android.content.pm.PackageManager;
6
6
  import android.content.pm.ResolveInfo;
7
+ import android.graphics.Color;
7
8
  import android.net.Uri;
8
9
  import android.os.Bundle;
9
10
  import android.text.TextUtils;
@@ -151,7 +152,14 @@ public class InAppBrowserPlugin extends Plugin {
151
152
  options.setUrl(url);
152
153
  options.setHeaders(call.getObject("headers"));
153
154
  options.setShowReloadButton(call.getBoolean("showReloadButton", false));
154
- options.setTitle(call.getString("title", "New Window"));
155
+ if (Boolean.TRUE.equals(call.getBoolean("visibleTitle", true))) {
156
+ options.setTitle(call.getString("title", "New Window"));
157
+ } else {
158
+ options.setTitle(call.getString("title", ""));
159
+ }
160
+ options.setToolbarColor(call.getString("toolbarColor", "#ffffff"));
161
+ options.setArrow(Boolean.TRUE.equals(call.getBoolean("showArrow", false)));
162
+
155
163
  options.setShareDisclaimer(call.getObject("shareDisclaimer", null));
156
164
  options.setShareSubject(call.getString("shareSubject", null));
157
165
  options.setToolbarType(call.getString("toolbarType", ""));
@@ -19,6 +19,9 @@ public class Options {
19
19
  private boolean isPresentAfterPageLoad;
20
20
  private WebViewCallbacks callbacks;
21
21
  private PluginCall pluginCall;
22
+ private boolean VisibleTitle;
23
+ private String ToolbarColor;
24
+ private boolean ShowArrow;
22
25
 
23
26
  public PluginCall getPluginCall() {
24
27
  return pluginCall;
@@ -141,4 +144,28 @@ public class Options {
141
144
  public void setCallbacks(WebViewCallbacks callbacks) {
142
145
  this.callbacks = callbacks;
143
146
  }
147
+
148
+ public boolean getVisibleTitle() {
149
+ return VisibleTitle;
150
+ }
151
+
152
+ public void setVisibleTitle(boolean _visibleTitle) {
153
+ this.VisibleTitle = _visibleTitle;
154
+ }
155
+
156
+ public String getToolbarColor() {
157
+ return ToolbarColor;
158
+ }
159
+
160
+ public void setToolbarColor(String toolbarColor) {
161
+ this.ToolbarColor = toolbarColor;
162
+ }
163
+
164
+ public boolean showArrow() {
165
+ return ShowArrow;
166
+ }
167
+
168
+ public void setArrow(boolean _showArrow) {
169
+ this.ShowArrow = _showArrow;
170
+ }
144
171
  }
@@ -5,6 +5,7 @@ import android.app.Dialog;
5
5
  import android.content.Context;
6
6
  import android.content.DialogInterface;
7
7
  import android.graphics.Bitmap;
8
+ import android.graphics.Color;
8
9
  import android.text.TextUtils;
9
10
  import android.view.View;
10
11
  import android.view.Window;
@@ -69,7 +70,7 @@ public class WebViewDialog extends Dialog {
69
70
  Iterator<String> keys = _options.getHeaders().keys();
70
71
  while (keys.hasNext()) {
71
72
  String key = keys.next();
72
- if (TextUtils.equals(key, "User-Agent")) {
73
+ if (TextUtils.equals(key.toLowerCase(), "user-agent")) {
73
74
  _webView
74
75
  .getSettings()
75
76
  .setUserAgentString(_options.getHeaders().getString(key));
@@ -98,7 +99,7 @@ public class WebViewDialog extends Dialog {
98
99
  Iterator<String> keys = _options.getHeaders().keys();
99
100
  while (keys.hasNext()) {
100
101
  String key = keys.next();
101
- if (TextUtils.equals(key, "User-Agent")) {
102
+ if (TextUtils.equals(key.toLowerCase(), "user-agent")) {
102
103
  _webView
103
104
  .getSettings()
104
105
  .setUserAgentString(_options.getHeaders().getString(key));
@@ -112,11 +113,27 @@ public class WebViewDialog extends Dialog {
112
113
 
113
114
  private void setTitle(String newTitleText) {
114
115
  TextView textView = (TextView) _toolbar.findViewById(R.id.titleText);
115
- textView.setText(newTitleText);
116
+ if (_options.getVisibleTitle()) {
117
+ textView.setText(newTitleText);
118
+ } else {
119
+ textView.setText("");
120
+ }
116
121
  }
117
122
 
118
123
  private void setupToolbar() {
119
124
  _toolbar = this.findViewById(R.id.tool_bar);
125
+ int color = Color.parseColor("#ffffff");
126
+ try {
127
+ color = Color.parseColor(_options.getToolbarColor());
128
+ } catch (IllegalArgumentException e) {
129
+ // Do nothing
130
+ }
131
+ _toolbar.setBackgroundColor(color);
132
+ _toolbar.findViewById(R.id.backButton).setBackgroundColor(color);
133
+ _toolbar.findViewById(R.id.forwardButton).setBackgroundColor(color);
134
+ _toolbar.findViewById(R.id.closeButton).setBackgroundColor(color);
135
+ _toolbar.findViewById(R.id.reloadButton).setBackgroundColor(color);
136
+
120
137
  if (!TextUtils.isEmpty(_options.getTitle())) {
121
138
  this.setTitle(_options.getTitle());
122
139
  } else {
@@ -182,6 +199,10 @@ public class WebViewDialog extends Dialog {
182
199
  }
183
200
  );
184
201
 
202
+ if (_options.showArrow()) {
203
+ closeButton.setBackgroundResource(R.drawable.arrow_forward_enabled);
204
+ }
205
+
185
206
  if (_options.getShowReloadButton()) {
186
207
  View reloadButton = _toolbar.findViewById(R.id.reloadButton);
187
208
  reloadButton.setVisibility(View.VISIBLE);
@@ -21,6 +21,7 @@
21
21
  android:layout_height="wrap_content"
22
22
  android:layout_gravity="end"
23
23
  android:background="#eeeeef"
24
+ android:paddingRight="10dp"
24
25
  android:contentDescription="@string/reload_button"
25
26
  android:src="@drawable/ic_refresh"
26
27
  android:visibility="gone" />
@@ -43,7 +44,6 @@
43
44
  android:layout_gravity="end"
44
45
  android:background="#eeeeef"
45
46
  android:contentDescription="@string/forward_button"
46
- android:paddingLeft="10dp"
47
47
  android:paddingRight="10dp"
48
48
  android:src="@drawable/arrow_forward_disabled" />
49
49
 
package/dist/docs.json CHANGED
@@ -482,6 +482,54 @@
482
482
  "docs": "CloseModalCancel: text of the cancel button when user clicks on close button, only on IOS",
483
483
  "complexTypes": [],
484
484
  "type": "string | undefined"
485
+ },
486
+ {
487
+ "name": "visibleTitle",
488
+ "tags": [
489
+ {
490
+ "text": "1.2.5",
491
+ "name": "since"
492
+ },
493
+ {
494
+ "text": "true",
495
+ "name": "default"
496
+ }
497
+ ],
498
+ "docs": "visibleTitle: if true the website title would be shown else shown empty",
499
+ "complexTypes": [],
500
+ "type": "boolean | undefined"
501
+ },
502
+ {
503
+ "name": "toolbarColor",
504
+ "tags": [
505
+ {
506
+ "text": "1.2.5",
507
+ "name": "since"
508
+ },
509
+ {
510
+ "text": "'#ffffff''",
511
+ "name": "default"
512
+ }
513
+ ],
514
+ "docs": "toolbarColor: color of the toolbar in hex format",
515
+ "complexTypes": [],
516
+ "type": "string | undefined"
517
+ },
518
+ {
519
+ "name": "showArrow",
520
+ "tags": [
521
+ {
522
+ "text": "1.2.5",
523
+ "name": "since"
524
+ },
525
+ {
526
+ "text": "false",
527
+ "name": "default"
528
+ }
529
+ ],
530
+ "docs": "showArrow: if true an arrow would be shown instead of cross for closing the window",
531
+ "complexTypes": [],
532
+ "type": "boolean | undefined"
485
533
  }
486
534
  ]
487
535
  },
@@ -142,6 +142,27 @@ export interface OpenWebViewOptions {
142
142
  * @default 'Cancel'
143
143
  */
144
144
  closeModalCancel?: string;
145
+ /**
146
+ * visibleTitle: if true the website title would be shown else shown empty
147
+ *
148
+ * @since 1.2.5
149
+ * @default true
150
+ */
151
+ visibleTitle?: boolean;
152
+ /**
153
+ * toolbarColor: color of the toolbar in hex format
154
+ *
155
+ * @since 1.2.5
156
+ * @default '#ffffff''
157
+ */
158
+ toolbarColor?: string;
159
+ /**
160
+ * showArrow: if true an arrow would be shown instead of cross for closing the window
161
+ *
162
+ * @since 1.2.5
163
+ * @default false
164
+ */
165
+ showArrow?: boolean;
145
166
  }
146
167
  export interface InAppBrowserPlugin {
147
168
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAsBA,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,kCAAe,CAAA;IACf,kCAAe,CAAA;AACjB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AACD,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,oCAAqB,CAAA;IACrB,wCAAyB,CAAA;IACzB,8BAAe,CAAA;IACf,2BAAY,CAAA;AACd,CAAC,EALW,WAAW,KAAX,WAAW,QAKtB","sourcesContent":["import type { PluginListenerHandle } from \"@capacitor/core\";\n\nexport interface UrlEvent {\n /**\n * Emit when the url changes\n *\n * @since 0.0.1\n */\n url: string;\n}\nexport interface BtnEvent {\n /**\n * Emit when a button is clicked.\n *\n * @since 0.0.1\n */\n url: string;\n}\n\nexport type UrlChangeListener = (state: UrlEvent) => void;\nexport type ConfirmBtnListener = (state: BtnEvent) => void;\n\nexport enum BackgroundColor {\n WHITE = \"white\",\n BLACK = \"black\",\n}\nexport enum ToolBarType {\n ACTIVITY = \"activity\",\n NAVIGATION = \"navigation\",\n BLANK = \"blank\",\n DEFAULT = \"\",\n}\n\nexport interface Headers {\n [key: string]: string;\n}\n\nexport interface OpenOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n */\n headers?: Headers;\n /**\n * if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.\n * @since 0.1.0\n */\n isPresentAfterPageLoad?: boolean;\n preventDeeplink?: boolean;\n}\n\nexport interface DisclaimerOptions {\n title: string;\n message: string;\n confirmBtn: string;\n cancelBtn: string;\n}\n\nexport interface OpenWebViewOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n */\n headers?: Headers;\n /**\n * share options\n * @since 0.1.0\n */\n shareDisclaimer?: DisclaimerOptions;\n /**\n * Toolbar type\n * @since 0.1.0\n * @default ToolBarType.DEFAULT\n */\n toolbarType?: ToolBarType;\n /**\n * Share subject\n * @since 0.1.0\n */\n shareSubject?: string;\n /**\n * Title of the browser\n * @since 0.1.0\n * @default 'New Window'\n */\n title: string;\n /**\n * Background color of the browser, only on IOS\n * @since 0.1.0\n * @default BackgroundColor.BLACK\n */\n backgroundColor?: BackgroundColor;\n /**\n * Open url in a new window fullscreen\n *\n * isPresentAfterPageLoad: if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.\n * @since 0.1.0\n * @default false\n */\n isPresentAfterPageLoad?: boolean;\n /**\n * Shows a reload button that reloads the web page\n * @since 1.0.15\n * @default false\n */\n showReloadButton?: boolean;\n /**\n * CloseModal: if true a confirm will be displayed when user clicks on close button, if false the browser will be closed immediately.\n *\n * @since 1.1.0\n * @default false\n */\n closeModal?: boolean;\n /**\n * CloseModalTitle: title of the confirm when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Close'\n */\n closeModalTitle?: string;\n /**\n * CloseModalDescription: description of the confirm when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Are you sure you want to close this window?'\n */\n closeModalDescription?: string;\n /**\n * CloseModalOk: text of the confirm button when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Close'\n */\n closeModalOk?: string;\n /**\n * CloseModalCancel: text of the cancel button when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Cancel'\n */\n closeModalCancel?: string;\n}\n\n// CapBrowser.addListener(\"urlChangeEvent\", (info: any) => {\n// console.log(info.url)\n// })\n\n// CapBrowser.addListener(\"confirmBtnClicked\", (info: any) => {\n// // will be triggered when user clicks on confirm button when disclaimer is required, works only on iOS\n// console.log(info.url)\n// })\nexport interface InAppBrowserPlugin {\n /**\n * Open url in a new window fullscreen\n *\n * @since 0.1.0\n */\n open(options: OpenOptions): Promise<any>;\n\n /**\n * Clear all cookies\n *\n * @since 0.5.0\n */\n clearCookies(): Promise<any>;\n close(): Promise<any>;\n /**\n * Open url in a new webview with toolbars\n *\n * @since 0.1.0\n */\n openWebView(options: OpenWebViewOptions): Promise<any>;\n setUrl(options: { url: string }): Promise<any>;\n /**\n * Listen for url change, only for openWebView\n *\n * @since 0.0.1\n */\n addListener(\n eventName: \"urlChangeEvent\",\n listenerFunc: UrlChangeListener\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n /**\n * Listen for close click only for openWebView\n *\n * @since 0.4.0\n */\n addListener(\n eventName: \"closeEvent\",\n listenerFunc: UrlChangeListener\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n /**\n * Will be triggered when user clicks on confirm button when disclaimer is required, works only on iOS\n *\n * @since 0.0.1\n */\n addListener(\n eventName: \"confirmBtnClicked\",\n listenerFunc: ConfirmBtnListener\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n /**\n * Remove all listeners for this plugin.\n *\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAsBA,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,kCAAe,CAAA;IACf,kCAAe,CAAA;AACjB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AACD,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,oCAAqB,CAAA;IACrB,wCAAyB,CAAA;IACzB,8BAAe,CAAA;IACf,2BAAY,CAAA;AACd,CAAC,EALW,WAAW,KAAX,WAAW,QAKtB","sourcesContent":["import type { PluginListenerHandle } from \"@capacitor/core\";\n\nexport interface UrlEvent {\n /**\n * Emit when the url changes\n *\n * @since 0.0.1\n */\n url: string;\n}\nexport interface BtnEvent {\n /**\n * Emit when a button is clicked.\n *\n * @since 0.0.1\n */\n url: string;\n}\n\nexport type UrlChangeListener = (state: UrlEvent) => void;\nexport type ConfirmBtnListener = (state: BtnEvent) => void;\n\nexport enum BackgroundColor {\n WHITE = \"white\",\n BLACK = \"black\",\n}\nexport enum ToolBarType {\n ACTIVITY = \"activity\",\n NAVIGATION = \"navigation\",\n BLANK = \"blank\",\n DEFAULT = \"\",\n}\n\nexport interface Headers {\n [key: string]: string;\n}\n\nexport interface OpenOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n */\n headers?: Headers;\n /**\n * if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.\n * @since 0.1.0\n */\n isPresentAfterPageLoad?: boolean;\n preventDeeplink?: boolean;\n}\n\nexport interface DisclaimerOptions {\n title: string;\n message: string;\n confirmBtn: string;\n cancelBtn: string;\n}\n\nexport interface OpenWebViewOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n */\n headers?: Headers;\n /**\n * share options\n * @since 0.1.0\n */\n shareDisclaimer?: DisclaimerOptions;\n /**\n * Toolbar type\n * @since 0.1.0\n * @default ToolBarType.DEFAULT\n */\n toolbarType?: ToolBarType;\n /**\n * Share subject\n * @since 0.1.0\n */\n shareSubject?: string;\n /**\n * Title of the browser\n * @since 0.1.0\n * @default 'New Window'\n */\n title: string;\n /**\n * Background color of the browser, only on IOS\n * @since 0.1.0\n * @default BackgroundColor.BLACK\n */\n backgroundColor?: BackgroundColor;\n /**\n * Open url in a new window fullscreen\n *\n * isPresentAfterPageLoad: if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.\n * @since 0.1.0\n * @default false\n */\n isPresentAfterPageLoad?: boolean;\n /**\n * Shows a reload button that reloads the web page\n * @since 1.0.15\n * @default false\n */\n showReloadButton?: boolean;\n /**\n * CloseModal: if true a confirm will be displayed when user clicks on close button, if false the browser will be closed immediately.\n *\n * @since 1.1.0\n * @default false\n */\n closeModal?: boolean;\n /**\n * CloseModalTitle: title of the confirm when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Close'\n */\n closeModalTitle?: string;\n /**\n * CloseModalDescription: description of the confirm when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Are you sure you want to close this window?'\n */\n closeModalDescription?: string;\n /**\n * CloseModalOk: text of the confirm button when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Close'\n */\n closeModalOk?: string;\n /**\n * CloseModalCancel: text of the cancel button when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Cancel'\n */\n closeModalCancel?: string;\n /**\n * visibleTitle: if true the website title would be shown else shown empty\n *\n * @since 1.2.5\n * @default true\n */\n visibleTitle?: boolean;\n /**\n * toolbarColor: color of the toolbar in hex format\n *\n * @since 1.2.5\n * @default '#ffffff''\n */\n toolbarColor?: string;\n /**\n * showArrow: if true an arrow would be shown instead of cross for closing the window\n *\n * @since 1.2.5\n * @default false\n */\n showArrow?: boolean;\n}\n\n// CapBrowser.addListener(\"urlChangeEvent\", (info: any) => {\n// console.log(info.url)\n// })\n\n// CapBrowser.addListener(\"confirmBtnClicked\", (info: any) => {\n// // will be triggered when user clicks on confirm button when disclaimer is required, works only on iOS\n// console.log(info.url)\n// })\nexport interface InAppBrowserPlugin {\n /**\n * Open url in a new window fullscreen\n *\n * @since 0.1.0\n */\n open(options: OpenOptions): Promise<any>;\n\n /**\n * Clear all cookies\n *\n * @since 0.5.0\n */\n clearCookies(): Promise<any>;\n close(): Promise<any>;\n /**\n * Open url in a new webview with toolbars\n *\n * @since 0.1.0\n */\n openWebView(options: OpenWebViewOptions): Promise<any>;\n setUrl(options: { url: string }): Promise<any>;\n /**\n * Listen for url change, only for openWebView\n *\n * @since 0.0.1\n */\n addListener(\n eventName: \"urlChangeEvent\",\n listenerFunc: UrlChangeListener\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n /**\n * Listen for close click only for openWebView\n *\n * @since 0.4.0\n */\n addListener(\n eventName: \"closeEvent\",\n listenerFunc: UrlChangeListener\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n /**\n * Will be triggered when user clicks on confirm button when disclaimer is required, works only on iOS\n *\n * @since 0.0.1\n */\n addListener(\n eventName: \"confirmBtnClicked\",\n listenerFunc: ConfirmBtnListener\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n /**\n * Remove all listeners for this plugin.\n *\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n}\n"]}
@@ -1,6 +1,21 @@
1
1
  import Foundation
2
2
  import Capacitor
3
3
 
4
+ extension UIColor {
5
+
6
+ convenience init(hexString: String) {
7
+ let hex = hexString.trimmingCharacters(in: CharacterSet.alphanumerics.inverted)
8
+ var int = UInt64()
9
+ Scanner(string: hex).scanHexInt64(&int)
10
+ let components = (
11
+ R: CGFloat((int >> 16) & 0xff) / 255,
12
+ G: CGFloat((int >> 08) & 0xff) / 255,
13
+ B: CGFloat((int >> 00) & 0xff) / 255
14
+ )
15
+ self.init(red: components.R, green: components.G, blue: components.B, alpha: 1)
16
+ }
17
+
18
+ }
4
19
  /**
5
20
  * Please read the Capacitor iOS Plugin Development Guide
6
21
  * here: https://capacitorjs.com/docs/plugins/ios
@@ -84,10 +99,15 @@ public class InAppBrowserPlugin: CAPPlugin {
84
99
  self.webViewController?.leftNavigaionBarItemTypes = self.getToolbarItems(toolbarType: toolbarType)
85
100
  self.webViewController?.toolbarItemTypes = []
86
101
  self.webViewController?.doneBarButtonItemPosition = .right
102
+ if call.getBool("showArrow", false) {
103
+ self.webViewController?.stopBarButtonItemImage = UIImage(named: "Forward@3x", in: Bundle(for: InAppBrowserPlugin.self), compatibleWith: nil)
104
+ }
105
+
87
106
  self.webViewController?.capBrowserPlugin = self
88
107
  self.webViewController?.title = call.getString("title", "New Window")
89
108
  self.webViewController?.shareSubject = call.getString("shareSubject")
90
109
  self.webViewController?.shareDisclaimer = disclaimerContent
110
+ self.webViewController?.websiteTitleInNavigationBar = call.getBool("visibleTitle", true)
91
111
  if closeModal {
92
112
  self.webViewController?.closeModal = true
93
113
  self.webViewController?.closeModalTitle = closeModalTitle
@@ -134,6 +154,22 @@ public class InAppBrowserPlugin: CAPPlugin {
134
154
  call.resolve()
135
155
  }
136
156
 
157
+ func isHexColorCode(_ input: String) -> Bool {
158
+ let hexColorRegex = "^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$"
159
+
160
+ do {
161
+ let regex = try NSRegularExpression(pattern: hexColorRegex)
162
+ let range = NSRange(location: 0, length: input.utf16.count)
163
+ if let _ = regex.firstMatch(in: input, options: [], range: range) {
164
+ return true
165
+ }
166
+ } catch {
167
+ print("Error creating regular expression: \(error)")
168
+ }
169
+
170
+ return false
171
+ }
172
+
137
173
  @objc func open(_ call: CAPPluginCall) {
138
174
  if !self.isSetupDone {
139
175
  self.setup()
@@ -174,7 +210,14 @@ public class InAppBrowserPlugin: CAPPlugin {
174
210
  self.navigationWebViewController?.navigationBar.isTranslucent = false
175
211
  self.navigationWebViewController?.toolbar.isTranslucent = false
176
212
  self.navigationWebViewController?.navigationBar.backgroundColor = .white
177
- self.navigationWebViewController?.toolbar.backgroundColor = .white
213
+ var inputString: String = call.getString("toolbarColor", "#ffffff")
214
+ var color: UIColor = UIColor(hexString: "#ffffff")
215
+ if self.isHexColorCode(inputString) {
216
+ color = UIColor(hexString: inputString)
217
+ } else {
218
+ print("\(inputString) is not a valid hex color code.")
219
+ }
220
+ self.navigationWebViewController?.toolbar.backgroundColor = color
178
221
  self.navigationWebViewController?.modalPresentationStyle = .fullScreen
179
222
  if !self.isPresentAfterPageLoad {
180
223
  self.presentView()
@@ -28,6 +28,16 @@ private struct UrlsHandledByApp {
28
28
  @objc optional func webViewController(_ controller: WKWebViewController, decidePolicy url: URL, navigationType: NavigationType) -> Bool
29
29
  }
30
30
 
31
+ extension Dictionary {
32
+ func mapKeys<T>(_ transform: (Key) throws -> T) rethrows -> [T: Value] {
33
+ var dictionary = [T: Value]()
34
+ for (key, value) in self {
35
+ dictionary[try transform(key)] = value
36
+ }
37
+ return dictionary
38
+ }
39
+ }
40
+
31
41
  open class WKWebViewController: UIViewController {
32
42
 
33
43
  public init() {
@@ -82,9 +92,12 @@ open class WKWebViewController: UIViewController {
82
92
 
83
93
  func setHeaders(headers: [String: String]) {
84
94
  self.headers = headers
85
- let userAgent = self.headers?["User-Agent"]
95
+ let lowercasedHeaders = headers.mapKeys { $0.lowercased() }
96
+ let userAgent = lowercasedHeaders["user-agent"]
86
97
  self.headers?.removeValue(forKey: "User-Agent")
87
- if userAgent != nil {
98
+ self.headers?.removeValue(forKey: "user-agent")
99
+
100
+ if let userAgent = userAgent {
88
101
  self.customUserAgent = userAgent
89
102
  }
90
103
  }
@@ -248,7 +261,7 @@ open class WKWebViewController: UIViewController {
248
261
  var topPadding = CGFloat(0.0)
249
262
  if #available(iOS 11.0, *) {
250
263
  let window = UIApplication.shared.keyWindow
251
- bottomPadding = (window?.safeAreaInsets.bottom)!
264
+ bottomPadding = window?.safeAreaInsets.bottom ?? 0.0
252
265
  topPadding = (window?.safeAreaInsets.top)!
253
266
  }
254
267
  if UIDevice.current.orientation.isPortrait {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/inappbrowser",
3
- "version": "1.2.4",
3
+ "version": "1.2.8",
4
4
  "description": "Capacitor plugin in app browser",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -45,7 +45,7 @@
45
45
  "prepublishOnly": "npm run build"
46
46
  },
47
47
  "devDependencies": {
48
- "@capacitor/android": "^5.0.3",
48
+ "@capacitor/android": "^5.3.0",
49
49
  "@capacitor/cli": "^5.0.3",
50
50
  "@capacitor/core": "^5.0.3",
51
51
  "@capacitor/docgen": "^0.2.1",