Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(browser): Allow to configure popover size #1056

Merged
merged 2 commits into from
Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions browser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,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 browser/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 browser/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