From daa48873255d0fc31608cc8515e08386c01db6dd Mon Sep 17 00:00:00 2001 From: VReactor Date: Sat, 19 Feb 2022 23:37:28 +0300 Subject: [PATCH] feat(browser-tab): add plugin (#4046) * feat(browser-tab): add plugin * feat(browser-tab): add documentation Co-authored-by: Neroda.NN --- docs/SUMMARY.md | 1 + docs/plugins/browser-tab.md | 17 +++++ docs/plugins/browser-tab/README.md | 17 +++++ .../plugins/browser-tab/index.ts | 63 +++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 docs/plugins/browser-tab.md create mode 100644 docs/plugins/browser-tab/README.md create mode 100644 src/@awesome-cordova-plugins/plugins/browser-tab/index.ts diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index 302d63b0c..d5597f039 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -214,6 +214,7 @@ * [Android Notch](plugins/android-notch.md) * [Network Interface](plugins/network-interface.md) * [Printer](plugins/printer.md) + * [Browser Tab](plugins/browser-tab.md) * [Installation](installation.md) * [FAQ](faq.md) diff --git a/docs/plugins/browser-tab.md b/docs/plugins/browser-tab.md new file mode 100644 index 000000000..516b23665 --- /dev/null +++ b/docs/plugins/browser-tab.md @@ -0,0 +1,17 @@ +# Browser Tab + +``` +$ ionic cordova plugin add cordova-plugin-browsertab +$ npm install @awesome-cordova-plugins/browser-tab +``` + +## [Usage Documentation](https://danielsogl.gitbook.io/awesome-cordova-plugins/plugins/browser-tab/) + +Plugin Repo: [https://github.com/google/cordova-plugin-browsertab](https://github.com/google/cordova-plugin-browsertab) + +This plugin provides an interface to in-app browser tabs that exist on some mobile platforms, specifically [Custom Tabs](http://developer.android.com/tools/support-library/features.html#custom-tabs) on Android (including the [Chrome Custom Tabs](https://developer.chrome.com/multidevice/android/customtabs) implementation), and [SFSafariViewController](https://developer.apple.com/library/ios/documentation/SafariServices/Reference/SFSafariViewController_Ref/) on iOS. + +## Supported platforms + +- Android +- iOS \ No newline at end of file diff --git a/docs/plugins/browser-tab/README.md b/docs/plugins/browser-tab/README.md new file mode 100644 index 000000000..516b23665 --- /dev/null +++ b/docs/plugins/browser-tab/README.md @@ -0,0 +1,17 @@ +# Browser Tab + +``` +$ ionic cordova plugin add cordova-plugin-browsertab +$ npm install @awesome-cordova-plugins/browser-tab +``` + +## [Usage Documentation](https://danielsogl.gitbook.io/awesome-cordova-plugins/plugins/browser-tab/) + +Plugin Repo: [https://github.com/google/cordova-plugin-browsertab](https://github.com/google/cordova-plugin-browsertab) + +This plugin provides an interface to in-app browser tabs that exist on some mobile platforms, specifically [Custom Tabs](http://developer.android.com/tools/support-library/features.html#custom-tabs) on Android (including the [Chrome Custom Tabs](https://developer.chrome.com/multidevice/android/customtabs) implementation), and [SFSafariViewController](https://developer.apple.com/library/ios/documentation/SafariServices/Reference/SFSafariViewController_Ref/) on iOS. + +## Supported platforms + +- Android +- iOS \ No newline at end of file diff --git a/src/@awesome-cordova-plugins/plugins/browser-tab/index.ts b/src/@awesome-cordova-plugins/plugins/browser-tab/index.ts new file mode 100644 index 000000000..1125b9e40 --- /dev/null +++ b/src/@awesome-cordova-plugins/plugins/browser-tab/index.ts @@ -0,0 +1,63 @@ +import { Injectable } from '@angular/core'; +import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core'; + +/** + * @name Browser Tab + * @description + * This plugin provides an interface to in-app browser tabs that exist on some mobile platforms, specifically [Custom Tabs](http://developer.android.com/tools/support-library/features.html#custom-tabs) on Android (including the [Chrome Custom Tabs](https://developer.chrome.com/multidevice/android/customtabs) implementation), and [SFSafariViewController](https://developer.apple.com/library/ios/documentation/SafariServices/Reference/SFSafariViewController_Ref/) on iOS. + * + * @usage + * ```typescript + * import { BrowserTab } from '@awesome-cordova-plugins/browser-tab/ngx'; + * + * constructor(private browserTab: BrowserTab) { + * + * browserTab.isAvailable() + * .then(isAvailable => { + * if (isAvailable) { + * browserTab.openUrl('https://ionic.io'); + * } else { + * // open URL with InAppBrowser instead or SafariViewController + * } + * }); + * } + * + * ``` + */ +@Plugin({ + pluginName: 'BrowserTab', + plugin: 'cordova-plugin-browsertab', + pluginRef: 'cordova.plugins.browsertab', + repo: 'https://github.com/google/cordova-plugin-browsertab', + platforms: ['Android', 'iOS'], +}) +@Injectable() +export class BrowserTab extends AwesomeCordovaNativePlugin { + /** + * Check if BrowserTab option is available + * @return {Promise} Returns a promise that resolves when check is successful and returns true or false + */ + @Cordova() + isAvailable(): Promise { + return; + } + + /** + * Opens the provided URL using a browser tab + * @param {string} url The URL you want to open + * @return {Promise} Returns a promise that resolves when check open was successful + */ + @Cordova() + openUrl(url: string): Promise { + return; + } + + /** + * Closes browser tab + * @return {Promise} Returns a promise that resolves when close was finished + */ + @Cordova() + close(): Promise { + return; + } +}