Skip to content

Commit

Permalink
feat(browser): Allow to configure popover size (ionic-team#1056)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored and hmaretic24 committed Apr 25, 2023
1 parent 533ebbd commit 5bdb486
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ Represents the options passed to `open`.
| **`windowName`** | <code>string</code> | 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`** | <code>string</code> | A hex color to which the toolbar color is set. | 1.0.0 |
| **`presentationStyle`** | <code>'fullscreen' \| 'popover'</code> | iOS only: The presentation style of the browser. Defaults to fullscreen. Ignored on other platforms. | 1.0.0 |
| **`width`** | <code>number</code> | iOS only: The width the browser when using presentationStyle 'popover' on iPads. Ignored on other platforms. | 4.0.0 |
| **`height`** | <code>number</code> | iOS only: The height the browser when using presentationStyle 'popover' on iPads. Ignored on other platforms. | 4.0.0 |


#### PluginListenerHandle
Expand Down
6 changes: 5 additions & 1 deletion ios/Plugin/BrowserPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
18 changes: 18 additions & 0 deletions src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 5bdb486

Please sign in to comment.