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

iOS: Add formSheetPreferredContentSize prop to allow for custom sized formSheet modals #331

Merged
merged 7 commits into from
May 20, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ in case of vulnerabilities.

## [Unreleased]

## [3.7.0] - 2022-03-01

### Added
- iOS: Add formSheetPreferredContentSize prop to allow for custom sized formSheet modals by [@ShaneMckenna23](https://github.com/ShaneMckenna23) ([#331](https://github.com/proyecto26/react-native-inappbrowser/pull/331)).

## [3.6.3] - 2021-07-05

### Fixed
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ Property | Description
`modalEnabled` (Boolean) | Present the **SafariViewController** modally or as push instead. [`true`/`false`]
`enableBarCollapsing` (Boolean) | Determines whether the browser's tool bars will collapse or not. [`true`/`false`]
`ephemeralWebSession` (Boolean) | Prevent re-use cookies of previous session (openAuth only) [`true`/`false`]
`formSheetPreferredContentSize` (Object) | Custom size for iPad `formSheet` modals [`{width: 400, height: 500}`]

### Android Options
Property | Description
Expand Down
3 changes: 2 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ declare module 'react-native-inappbrowser-reborn' {
| 'partialCurl',
modalEnabled?: boolean,
enableBarCollapsing?: boolean,
ephemeralWebSession?: boolean
ephemeralWebSession?: boolean,
formSheetPreferredContentSize?: { width: number, height: number },
}

export type InAppBrowserAndroidOptions = {
Expand Down
11 changes: 11 additions & 0 deletions ios/RNInAppBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ + (BOOL)requiresMainQueueSetup
NSNumber* preferredControlTintColor = [options valueForKey:@"preferredControlTintColor"];
NSString* modalPresentationStyle = [options valueForKey:@"modalPresentationStyle"];
NSString* modalTransitionStyle = [options valueForKey:@"modalTransitionStyle"];
NSDictionary* formSheetPreferredContentSize = [options valueForKey:@"formSheetPreferredContentSize"];

BOOL readerMode = [options[@"readerMode"] boolValue];
BOOL enableBarCollapsing = [options[@"enableBarCollapsing"] boolValue];
Expand Down Expand Up @@ -207,6 +208,16 @@ + (BOOL)requiresMainQueueSetup
if(animated) {
safariHackVC.modalTransitionStyle = [self getTransitionStyle: modalTransitionStyle];
}

if([modalPresentationStyle isEqualToString:@"formSheet"] && formSheetPreferredContentSize){
NSNumber *width = [formSheetPreferredContentSize valueForKey:@"width"];
NSNumber *height = [formSheetPreferredContentSize valueForKey:@"height"];

if(width && height){
safariHackVC.preferredContentSize = CGSizeMake([width doubleValue], [height doubleValue]);
}
}

safariHackVC.presentationController.delegate = self;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpartial-availability"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-inappbrowser-reborn",
"version": "3.6.3",
"version": "3.7.0",
"description": "InAppBrowser for React Native",
"main": "index.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions types.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export type InAppBrowseriOSOptions = {|
modalEnabled?: boolean,
enableBarCollapsing?: boolean,
ephemeralWebSession?: boolean,
formSheetPreferredContentSize?: { width: number, height: number },
|};

export type InAppBrowserAndroidOptions = {|
Expand Down