@capgo/inappbrowser 1.0.13 → 1.2.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.
- package/README.md +16 -10
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java +12 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/Options.java +55 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java +49 -3
- package/android/src/main/res/drawable/ic_refresh.xml +9 -0
- package/android/src/main/res/layout/tool_bar.xml +9 -0
- package/android/src/main/res/values/strings.xml +1 -0
- package/dist/docs.json +96 -0
- package/dist/esm/definitions.d.ts +41 -0
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Plugin/InAppBrowserPlugin.swift +17 -0
- package/ios/Plugin/WKWebViewController.swift +21 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -213,16 +213,22 @@ Remove all listeners for this plugin.
|
|
|
213
213
|
|
|
214
214
|
#### OpenWebViewOptions
|
|
215
215
|
|
|
216
|
-
| Prop | Type | Description | Default
|
|
217
|
-
| ---------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
218
|
-
| **`url`** | <code>string</code> | Target URL to load. |
|
|
219
|
-
| **`headers`** | <code><a href="#headers">Headers</a></code> | <a href="#headers">Headers</a> to send with the request. |
|
|
220
|
-
| **`shareDisclaimer`** | <code><a href="#disclaimeroptions">DisclaimerOptions</a></code> | share options |
|
|
221
|
-
| **`toolbarType`** | <code><a href="#toolbartype">ToolBarType</a></code> | Toolbar type | <code>ToolBarType.DEFAULT</code>
|
|
222
|
-
| **`shareSubject`** | <code>string</code> | Share subject |
|
|
223
|
-
| **`title`** | <code>string</code> | Title of the browser | <code>'New Window'</code>
|
|
224
|
-
| **`backgroundColor`** | <code><a href="#backgroundcolor">BackgroundColor</a></code> | Background color of the browser, only on IOS | <code>BackgroundColor.BLACK</code>
|
|
225
|
-
| **`isPresentAfterPageLoad`** | <code>boolean</code> | Open url in a new window fullscreen isPresentAfterPageLoad: if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately. | <code>false</code>
|
|
216
|
+
| Prop | Type | Description | Default | Since |
|
|
217
|
+
| ---------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- | ------ |
|
|
218
|
+
| **`url`** | <code>string</code> | Target URL to load. | | 0.1.0 |
|
|
219
|
+
| **`headers`** | <code><a href="#headers">Headers</a></code> | <a href="#headers">Headers</a> to send with the request. | | 0.1.0 |
|
|
220
|
+
| **`shareDisclaimer`** | <code><a href="#disclaimeroptions">DisclaimerOptions</a></code> | share options | | 0.1.0 |
|
|
221
|
+
| **`toolbarType`** | <code><a href="#toolbartype">ToolBarType</a></code> | Toolbar type | <code>ToolBarType.DEFAULT</code> | 0.1.0 |
|
|
222
|
+
| **`shareSubject`** | <code>string</code> | Share subject | | 0.1.0 |
|
|
223
|
+
| **`title`** | <code>string</code> | Title of the browser | <code>'New Window'</code> | 0.1.0 |
|
|
224
|
+
| **`backgroundColor`** | <code><a href="#backgroundcolor">BackgroundColor</a></code> | Background color of the browser, only on IOS | <code>BackgroundColor.BLACK</code> | 0.1.0 |
|
|
225
|
+
| **`isPresentAfterPageLoad`** | <code>boolean</code> | Open url in a new window fullscreen isPresentAfterPageLoad: if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately. | <code>false</code> | 0.1.0 |
|
|
226
|
+
| **`showReloadButton`** | <code>boolean</code> | Shows a reload button that reloads the web page | <code>false</code> | 1.0.15 |
|
|
227
|
+
| **`closeModal`** | <code>boolean</code> | CloseModal: if true a confirm will be displayed when user clicks on close button, if false the browser will be closed immediately. | <code>false</code> | 1.1.0 |
|
|
228
|
+
| **`closeModalTitle`** | <code>string</code> | CloseModalTitle: title of the confirm when user clicks on close button, only on IOS | <code>'Close'</code> | 1.1.0 |
|
|
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
|
+
| **`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
|
+
| **`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 |
|
|
226
232
|
|
|
227
233
|
|
|
228
234
|
#### DisclaimerOptions
|
|
@@ -150,6 +150,7 @@ public class InAppBrowserPlugin extends Plugin {
|
|
|
150
150
|
final Options options = new Options();
|
|
151
151
|
options.setUrl(url);
|
|
152
152
|
options.setHeaders(call.getObject("headers"));
|
|
153
|
+
options.setShowReloadButton(call.getBoolean("showReloadButton", false));
|
|
153
154
|
options.setTitle(call.getString("title", "New Window"));
|
|
154
155
|
options.setShareDisclaimer(call.getObject("shareDisclaimer", null));
|
|
155
156
|
options.setShareSubject(call.getString("shareSubject", null));
|
|
@@ -157,6 +158,17 @@ public class InAppBrowserPlugin extends Plugin {
|
|
|
157
158
|
options.setPresentAfterPageLoad(
|
|
158
159
|
call.getBoolean("isPresentAfterPageLoad", false)
|
|
159
160
|
);
|
|
161
|
+
if (call.getBoolean("closeModal", false)) {
|
|
162
|
+
options.setCloseModal(true);
|
|
163
|
+
options.setCloseModalTitle(call.getString("closeModalTitle", "Close"));
|
|
164
|
+
options.setCloseModalDescription(
|
|
165
|
+
call.getString("closeModalDescription", "Are you sure ?")
|
|
166
|
+
);
|
|
167
|
+
options.setCloseModalOk(call.getString("closeModalOk", "Ok"));
|
|
168
|
+
options.setCloseModalCancel(call.getString("closeModalCancel", "Cancel"));
|
|
169
|
+
} else {
|
|
170
|
+
options.setCloseModal(false);
|
|
171
|
+
}
|
|
160
172
|
options.setPluginCall(call);
|
|
161
173
|
options.setCallbacks(
|
|
162
174
|
new WebViewCallbacks() {
|
|
@@ -6,6 +6,11 @@ import com.getcapacitor.PluginCall;
|
|
|
6
6
|
public class Options {
|
|
7
7
|
|
|
8
8
|
private String title;
|
|
9
|
+
private boolean CloseModal;
|
|
10
|
+
private String CloseModalTitle;
|
|
11
|
+
private String CloseModalDescription;
|
|
12
|
+
private String CloseModalCancel;
|
|
13
|
+
private String CloseModalOk;
|
|
9
14
|
private String url;
|
|
10
15
|
private JSObject headers;
|
|
11
16
|
private String toolbarType;
|
|
@@ -31,6 +36,46 @@ public class Options {
|
|
|
31
36
|
this.title = title;
|
|
32
37
|
}
|
|
33
38
|
|
|
39
|
+
public boolean getCloseModal() {
|
|
40
|
+
return CloseModal;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public void setCloseModal(boolean CloseModal) {
|
|
44
|
+
this.CloseModal = CloseModal;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public String getCloseModalTitle() {
|
|
48
|
+
return CloseModalTitle;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public void setCloseModalTitle(String CloseModalTitle) {
|
|
52
|
+
this.CloseModalTitle = CloseModalTitle;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public String getCloseModalDescription() {
|
|
56
|
+
return CloseModalDescription;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public void setCloseModalDescription(String CloseModalDescription) {
|
|
60
|
+
this.CloseModalDescription = CloseModalDescription;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public String getCloseModalCancel() {
|
|
64
|
+
return CloseModalCancel;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public void setCloseModalCancel(String CloseModalCancel) {
|
|
68
|
+
this.CloseModalCancel = CloseModalCancel;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public String getCloseModalOk() {
|
|
72
|
+
return CloseModalOk;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public void setCloseModalOk(String CloseModalOk) {
|
|
76
|
+
this.CloseModalOk = CloseModalOk;
|
|
77
|
+
}
|
|
78
|
+
|
|
34
79
|
public String getUrl() {
|
|
35
80
|
return url;
|
|
36
81
|
}
|
|
@@ -59,6 +104,16 @@ public class Options {
|
|
|
59
104
|
return shareDisclaimer;
|
|
60
105
|
}
|
|
61
106
|
|
|
107
|
+
public boolean showReloadButton;
|
|
108
|
+
|
|
109
|
+
public boolean getShowReloadButton() {
|
|
110
|
+
return showReloadButton;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
public void setShowReloadButton(boolean showReloadButton) {
|
|
114
|
+
this.showReloadButton = showReloadButton;
|
|
115
|
+
}
|
|
116
|
+
|
|
62
117
|
public void setShareDisclaimer(JSObject shareDisclaimer) {
|
|
63
118
|
this.shareDisclaimer = shareDisclaimer;
|
|
64
119
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
package ee.forgr.capacitor_inappbrowser;
|
|
2
2
|
|
|
3
|
+
import android.app.AlertDialog;
|
|
3
4
|
import android.app.Dialog;
|
|
4
5
|
import android.content.Context;
|
|
6
|
+
import android.content.DialogInterface;
|
|
5
7
|
import android.graphics.Bitmap;
|
|
6
8
|
import android.text.TextUtils;
|
|
7
9
|
import android.view.View;
|
|
@@ -25,11 +27,13 @@ public class WebViewDialog extends Dialog {
|
|
|
25
27
|
private WebView _webView;
|
|
26
28
|
private Toolbar _toolbar;
|
|
27
29
|
private Options _options;
|
|
30
|
+
private Context _context;
|
|
28
31
|
private boolean isInitialized = false;
|
|
29
32
|
|
|
30
33
|
public WebViewDialog(Context context, int theme, Options options) {
|
|
31
34
|
super(context, theme);
|
|
32
35
|
this._options = options;
|
|
36
|
+
this._context = context;
|
|
33
37
|
this.isInitialized = false;
|
|
34
38
|
}
|
|
35
39
|
|
|
@@ -153,12 +157,44 @@ public class WebViewDialog extends Dialog {
|
|
|
153
157
|
new View.OnClickListener() {
|
|
154
158
|
@Override
|
|
155
159
|
public void onClick(View view) {
|
|
156
|
-
|
|
157
|
-
_options.
|
|
160
|
+
// if closeModal true then display a native modal to check if the user is sure to close the browser
|
|
161
|
+
if (_options.getCloseModal()) {
|
|
162
|
+
new AlertDialog.Builder(_context)
|
|
163
|
+
.setTitle(_options.getCloseModalTitle())
|
|
164
|
+
.setMessage(_options.getCloseModalDescription())
|
|
165
|
+
.setPositiveButton(
|
|
166
|
+
_options.getCloseModalOk(),
|
|
167
|
+
new DialogInterface.OnClickListener() {
|
|
168
|
+
public void onClick(DialogInterface dialog, int which) {
|
|
169
|
+
// Close button clicked, do something
|
|
170
|
+
dismiss();
|
|
171
|
+
_options.getCallbacks().closeEvent(_webView.getUrl());
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
)
|
|
175
|
+
.setNegativeButton(_options.getCloseModalCancel(), null)
|
|
176
|
+
.show();
|
|
177
|
+
} else {
|
|
178
|
+
dismiss();
|
|
179
|
+
_options.getCallbacks().closeEvent(_webView.getUrl());
|
|
180
|
+
}
|
|
158
181
|
}
|
|
159
182
|
}
|
|
160
183
|
);
|
|
161
184
|
|
|
185
|
+
if (_options.getShowReloadButton()) {
|
|
186
|
+
View reloadButton = _toolbar.findViewById(R.id.reloadButton);
|
|
187
|
+
reloadButton.setVisibility(View.VISIBLE);
|
|
188
|
+
reloadButton.setOnClickListener(
|
|
189
|
+
new View.OnClickListener() {
|
|
190
|
+
@Override
|
|
191
|
+
public void onClick(View view) {
|
|
192
|
+
_webView.reload();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
162
198
|
if (TextUtils.equals(_options.getToolbarType(), "activity")) {
|
|
163
199
|
_toolbar.findViewById(R.id.forwardButton).setVisibility(View.GONE);
|
|
164
200
|
_toolbar.findViewById(R.id.backButton).setVisibility(View.GONE);
|
|
@@ -198,7 +234,17 @@ public class WebViewDialog extends Dialog {
|
|
|
198
234
|
} catch (URISyntaxException e) {
|
|
199
235
|
// Do nothing
|
|
200
236
|
}
|
|
201
|
-
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
public void doUpdateVisitedHistory(
|
|
240
|
+
WebView view,
|
|
241
|
+
String url,
|
|
242
|
+
boolean isReload
|
|
243
|
+
) {
|
|
244
|
+
if (!isReload) {
|
|
245
|
+
_options.getCallbacks().urlChangeEvent(url);
|
|
246
|
+
}
|
|
247
|
+
super.doUpdateVisitedHistory(view, url, isReload);
|
|
202
248
|
}
|
|
203
249
|
|
|
204
250
|
@Override
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
+
android:width="24dp"
|
|
3
|
+
android:height="24dp"
|
|
4
|
+
android:viewportWidth="24.0"
|
|
5
|
+
android:viewportHeight="24.0">
|
|
6
|
+
<path
|
|
7
|
+
android:fillColor="@color/enable"
|
|
8
|
+
android:pathData="M17.65,6.35C16.2,4.9 14.21,4 12,4c-4.42,0 -7.99,3.58 -7.99,8s3.57,8 7.99,8c3.73,0 6.84,-2.55 7.73,-6h-2.08c-0.82,2.33 -3.04,4 -5.65,4 -3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6c1.66,0 3.14,0.69 4.22,1.78L13,11h7V4l-2.35,2.35z"/>
|
|
9
|
+
</vector>
|
|
@@ -15,6 +15,15 @@
|
|
|
15
15
|
android:layout_gravity="start"
|
|
16
16
|
android:background="#eeeeef"
|
|
17
17
|
android:contentDescription="@string/close_button" />
|
|
18
|
+
<ImageButton
|
|
19
|
+
android:id="@+id/reloadButton"
|
|
20
|
+
android:layout_width="wrap_content"
|
|
21
|
+
android:layout_height="wrap_content"
|
|
22
|
+
android:layout_gravity="end"
|
|
23
|
+
android:background="#eeeeef"
|
|
24
|
+
android:contentDescription="@string/reload_button"
|
|
25
|
+
android:src="@drawable/ic_refresh"
|
|
26
|
+
android:visibility="gone" />
|
|
18
27
|
|
|
19
28
|
<TextView
|
|
20
29
|
android:id="@+id/titleText"
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
<string name="title_activity_browser">BrowserActivity</string>
|
|
4
4
|
<string name="title_activity_basic">BasicActivity</string>
|
|
5
5
|
<string name="close_button">Close Button</string>
|
|
6
|
+
<string name="reload_button">Reload Button</string>
|
|
6
7
|
<string name="back_button">Back Button</string>
|
|
7
8
|
<string name="title">Title</string>
|
|
8
9
|
<string name="forward_button">Forward Button</string>
|
package/dist/docs.json
CHANGED
|
@@ -386,6 +386,102 @@
|
|
|
386
386
|
"docs": "Open url in a new window fullscreen\n\nisPresentAfterPageLoad: if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.",
|
|
387
387
|
"complexTypes": [],
|
|
388
388
|
"type": "boolean | undefined"
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
"name": "showReloadButton",
|
|
392
|
+
"tags": [
|
|
393
|
+
{
|
|
394
|
+
"text": "1.0.15",
|
|
395
|
+
"name": "since"
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
"text": "false",
|
|
399
|
+
"name": "default"
|
|
400
|
+
}
|
|
401
|
+
],
|
|
402
|
+
"docs": "Shows a reload button that reloads the web page",
|
|
403
|
+
"complexTypes": [],
|
|
404
|
+
"type": "boolean | undefined"
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
"name": "closeModal",
|
|
408
|
+
"tags": [
|
|
409
|
+
{
|
|
410
|
+
"text": "1.1.0",
|
|
411
|
+
"name": "since"
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
"text": "false",
|
|
415
|
+
"name": "default"
|
|
416
|
+
}
|
|
417
|
+
],
|
|
418
|
+
"docs": "CloseModal: if true a confirm will be displayed when user clicks on close button, if false the browser will be closed immediately.",
|
|
419
|
+
"complexTypes": [],
|
|
420
|
+
"type": "boolean | undefined"
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
"name": "closeModalTitle",
|
|
424
|
+
"tags": [
|
|
425
|
+
{
|
|
426
|
+
"text": "1.1.0",
|
|
427
|
+
"name": "since"
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
"text": "'Close'",
|
|
431
|
+
"name": "default"
|
|
432
|
+
}
|
|
433
|
+
],
|
|
434
|
+
"docs": "CloseModalTitle: title of the confirm when user clicks on close button, only on IOS",
|
|
435
|
+
"complexTypes": [],
|
|
436
|
+
"type": "string | undefined"
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
"name": "closeModalDescription",
|
|
440
|
+
"tags": [
|
|
441
|
+
{
|
|
442
|
+
"text": "1.1.0",
|
|
443
|
+
"name": "since"
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
"text": "'Are you sure you want to close this window?'",
|
|
447
|
+
"name": "default"
|
|
448
|
+
}
|
|
449
|
+
],
|
|
450
|
+
"docs": "CloseModalDescription: description of the confirm when user clicks on close button, only on IOS",
|
|
451
|
+
"complexTypes": [],
|
|
452
|
+
"type": "string | undefined"
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
"name": "closeModalOk",
|
|
456
|
+
"tags": [
|
|
457
|
+
{
|
|
458
|
+
"text": "1.1.0",
|
|
459
|
+
"name": "since"
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
"text": "'Close'",
|
|
463
|
+
"name": "default"
|
|
464
|
+
}
|
|
465
|
+
],
|
|
466
|
+
"docs": "CloseModalOk: text of the confirm button when user clicks on close button, only on IOS",
|
|
467
|
+
"complexTypes": [],
|
|
468
|
+
"type": "string | undefined"
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
"name": "closeModalCancel",
|
|
472
|
+
"tags": [
|
|
473
|
+
{
|
|
474
|
+
"text": "1.1.0",
|
|
475
|
+
"name": "since"
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
"text": "'Cancel'",
|
|
479
|
+
"name": "default"
|
|
480
|
+
}
|
|
481
|
+
],
|
|
482
|
+
"docs": "CloseModalCancel: text of the cancel button when user clicks on close button, only on IOS",
|
|
483
|
+
"complexTypes": [],
|
|
484
|
+
"type": "string | undefined"
|
|
389
485
|
}
|
|
390
486
|
]
|
|
391
487
|
},
|
|
@@ -101,6 +101,47 @@ export interface OpenWebViewOptions {
|
|
|
101
101
|
* @default false
|
|
102
102
|
*/
|
|
103
103
|
isPresentAfterPageLoad?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Shows a reload button that reloads the web page
|
|
106
|
+
* @since 1.0.15
|
|
107
|
+
* @default false
|
|
108
|
+
*/
|
|
109
|
+
showReloadButton?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* CloseModal: if true a confirm will be displayed when user clicks on close button, if false the browser will be closed immediately.
|
|
112
|
+
*
|
|
113
|
+
* @since 1.1.0
|
|
114
|
+
* @default false
|
|
115
|
+
*/
|
|
116
|
+
closeModal?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* CloseModalTitle: title of the confirm when user clicks on close button, only on IOS
|
|
119
|
+
*
|
|
120
|
+
* @since 1.1.0
|
|
121
|
+
* @default 'Close'
|
|
122
|
+
*/
|
|
123
|
+
closeModalTitle?: string;
|
|
124
|
+
/**
|
|
125
|
+
* CloseModalDescription: description of the confirm when user clicks on close button, only on IOS
|
|
126
|
+
*
|
|
127
|
+
* @since 1.1.0
|
|
128
|
+
* @default 'Are you sure you want to close this window?'
|
|
129
|
+
*/
|
|
130
|
+
closeModalDescription?: string;
|
|
131
|
+
/**
|
|
132
|
+
* CloseModalOk: text of the confirm button when user clicks on close button, only on IOS
|
|
133
|
+
*
|
|
134
|
+
* @since 1.1.0
|
|
135
|
+
* @default 'Close'
|
|
136
|
+
*/
|
|
137
|
+
closeModalOk?: string;
|
|
138
|
+
/**
|
|
139
|
+
* CloseModalCancel: text of the cancel button when user clicks on close button, only on IOS
|
|
140
|
+
*
|
|
141
|
+
* @since 1.1.0
|
|
142
|
+
* @default 'Cancel'
|
|
143
|
+
*/
|
|
144
|
+
closeModalCancel?: string;
|
|
104
145
|
}
|
|
105
146
|
export interface InAppBrowserPlugin {
|
|
106
147
|
/**
|
|
@@ -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\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\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"]}
|
|
@@ -54,6 +54,11 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
let headers = call.getObject("headers", [:]).mapValues { String(describing: $0 as Any) }
|
|
57
|
+
let closeModal = call.getBool("closeModal", false)
|
|
58
|
+
let closeModalTitle = call.getString("closeModalTitle", "Close")
|
|
59
|
+
let closeModalDescription = call.getString("closeModalDescription", "Are you sure you want to close this window?")
|
|
60
|
+
let closeModalOk = call.getString("closeModalOk", "OK")
|
|
61
|
+
let closeModalCancel = call.getString("closeModalCancel", "Cancel")
|
|
57
62
|
|
|
58
63
|
var disclaimerContent = call.getObject("shareDisclaimer")
|
|
59
64
|
let toolbarType = call.getString("toolbarType", "")
|
|
@@ -63,6 +68,7 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
63
68
|
}
|
|
64
69
|
|
|
65
70
|
self.isPresentAfterPageLoad = call.getBool("isPresentAfterPageLoad", false)
|
|
71
|
+
let showReloadButton = call.getBool("showReloadButton", false)
|
|
66
72
|
|
|
67
73
|
DispatchQueue.main.async {
|
|
68
74
|
let url = URL(string: urlString)
|
|
@@ -82,6 +88,13 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
82
88
|
self.webViewController?.title = call.getString("title", "New Window")
|
|
83
89
|
self.webViewController?.shareSubject = call.getString("shareSubject")
|
|
84
90
|
self.webViewController?.shareDisclaimer = disclaimerContent
|
|
91
|
+
if closeModal {
|
|
92
|
+
self.webViewController?.closeModal = true
|
|
93
|
+
self.webViewController?.closeModalTitle = closeModalTitle
|
|
94
|
+
self.webViewController?.closeModalDescription = closeModalDescription
|
|
95
|
+
self.webViewController?.closeModalOk = closeModalOk
|
|
96
|
+
self.webViewController?.closeModalCancel = closeModalCancel
|
|
97
|
+
}
|
|
85
98
|
self.navigationWebViewController = UINavigationController.init(rootViewController: self.webViewController!)
|
|
86
99
|
self.navigationWebViewController?.navigationBar.isTranslucent = false
|
|
87
100
|
self.navigationWebViewController?.toolbar.isTranslucent = false
|
|
@@ -91,6 +104,10 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
91
104
|
if toolbarType == "blank" {
|
|
92
105
|
self.navigationWebViewController?.navigationBar.isHidden = true
|
|
93
106
|
}
|
|
107
|
+
if showReloadButton {
|
|
108
|
+
var toolbarItems = self.getToolbarItems(toolbarType: toolbarType)
|
|
109
|
+
self.webViewController?.leftNavigaionBarItemTypes = toolbarItems + [.reload]
|
|
110
|
+
}
|
|
94
111
|
if !self.isPresentAfterPageLoad {
|
|
95
112
|
self.presentView()
|
|
96
113
|
}
|
|
@@ -74,6 +74,11 @@ open class WKWebViewController: UIViewController {
|
|
|
74
74
|
var viewHeightLandscape: CGFloat?
|
|
75
75
|
var viewHeightPortrait: CGFloat?
|
|
76
76
|
var currentViewHeight: CGFloat?
|
|
77
|
+
open var closeModal = false
|
|
78
|
+
open var closeModalTitle = ""
|
|
79
|
+
open var closeModalDescription = ""
|
|
80
|
+
open var closeModalOk = ""
|
|
81
|
+
open var closeModalCancel = ""
|
|
77
82
|
|
|
78
83
|
func setHeaders(headers: [String: String]) {
|
|
79
84
|
self.headers = headers
|
|
@@ -672,7 +677,7 @@ fileprivate extension WKWebViewController {
|
|
|
672
677
|
}
|
|
673
678
|
}
|
|
674
679
|
|
|
675
|
-
|
|
680
|
+
func closeView () {
|
|
676
681
|
var canDismiss = true
|
|
677
682
|
if let url = self.source?.url {
|
|
678
683
|
canDismiss = delegate?.webViewController?(self, canDismiss: url) ?? true
|
|
@@ -684,6 +689,21 @@ fileprivate extension WKWebViewController {
|
|
|
684
689
|
}
|
|
685
690
|
}
|
|
686
691
|
|
|
692
|
+
@objc func doneDidClick(sender: AnyObject) {
|
|
693
|
+
// check if closeModal is true, if true display alert before close
|
|
694
|
+
if self.closeModal {
|
|
695
|
+
let alert = UIAlertController(title: self.closeModalTitle, message: self.closeModalDescription, preferredStyle: UIAlertController.Style.alert)
|
|
696
|
+
alert.addAction(UIAlertAction(title: self.closeModalOk, style: UIAlertAction.Style.default, handler: { _ in
|
|
697
|
+
self.closeView()
|
|
698
|
+
}))
|
|
699
|
+
alert.addAction(UIAlertAction(title: self.closeModalCancel, style: UIAlertAction.Style.default, handler: nil))
|
|
700
|
+
self.present(alert, animated: true, completion: nil)
|
|
701
|
+
} else {
|
|
702
|
+
self.closeView()
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
}
|
|
706
|
+
|
|
687
707
|
@objc func customDidClick(sender: BlockBarButtonItem) {
|
|
688
708
|
sender.block?(self)
|
|
689
709
|
}
|