From 855066436d9030c6ab72d94ecfebf751f45c6e3b Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Tue, 28 Jun 2022 16:27:21 +0200 Subject: [PATCH] feat(browser): Allow to configure popover size (#1056) --- README.md | 2 ++ ios/Plugin/BrowserPlugin.swift | 6 +++++- src/definitions.ts | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4a7da2b84f..fecabf19e2 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,8 @@ Represents the options passed to `open`. | **`windowName`** | string | Web only: Optional target for browser open. Follows the `target` property for window.open. Defaults to _blank. Ignored on other platforms. | 1.0.0 | | **`toolbarColor`** | string | A hex color to which the toolbar color is set. | 1.0.0 | | **`presentationStyle`** | 'fullscreen' \| 'popover' | iOS only: The presentation style of the browser. Defaults to fullscreen. Ignored on other platforms. | 1.0.0 | +| **`width`** | number | iOS only: The width the browser when using presentationStyle 'popover' on iPads. Ignored on other platforms. | 4.0.0 | +| **`height`** | number | iOS only: The height the browser when using presentationStyle 'popover' on iPads. Ignored on other platforms. | 4.0.0 | #### PluginListenerHandle diff --git a/ios/Plugin/BrowserPlugin.swift b/ios/Plugin/BrowserPlugin.swift index 9ad9c32fa6..f6be40dd72 100644 --- a/ios/Plugin/BrowserPlugin.swift +++ b/ios/Plugin/BrowserPlugin.swift @@ -28,7 +28,11 @@ public class CAPBrowserPlugin: CAPPlugin { // display DispatchQueue.main.async { [weak self] in if style == .popover { - self?.setCenteredPopover(viewController) + if let width = call.getInt("width"), let height = call.getInt("height") { + self?.setCenteredPopover(viewController, size: CGSize.init(width: width, height: height)) + } else { + self?.setCenteredPopover(viewController) + } } self?.bridge?.presentVC(viewController, animated: true, completion: { call.resolve() diff --git a/src/definitions.ts b/src/definitions.ts index 78ba1b481d..6946e5e7f3 100644 --- a/src/definitions.ts +++ b/src/definitions.ts @@ -87,6 +87,24 @@ export interface OpenOptions { * @since 1.0.0 */ presentationStyle?: 'fullscreen' | 'popover'; + + /** + * iOS only: The width the browser when using presentationStyle 'popover' on iPads. + * + * Ignored on other platforms. + * + * @since 4.0.0 + */ + width?: number; + + /** + * iOS only: The height the browser when using presentationStyle 'popover' on iPads. + * + * Ignored on other platforms. + * + * @since 4.0.0 + */ + height?: number; } /**