Skip to content

Feature/presentation style #92

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

Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Adds presentation style property to navigatorStyle object to allow se…
…tting of the UIModalPresentationStyle of a view controller, allowing things such as part-screen views on iOS
  • Loading branch information
simonmitchell committed Aug 31, 2016
commit 7f68aee0b755358bb1adffe184373488ab4d3b45
38 changes: 38 additions & 0 deletions ios/RCCManagerModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,23 @@ @implementation RCTConvert (RCCManagerModuleErrorCode)
(@{@"RCCManagerModuleCantCreateControllerErrorCode": @(RCCManagerModuleCantCreateControllerErrorCode),
@"RCCManagerModuleCantFindTabControllerErrorCode": @(RCCManagerModuleCantFindTabControllerErrorCode),
}), RCCManagerModuleCantCreateControllerErrorCode, integerValue)

@end

@implementation RCTConvert (UIModalPresentationStyle)

RCT_ENUM_CONVERTER(UIModalPresentationStyle,
(@{@"fullScreen": @(UIModalPresentationFullScreen),
@"pageSheet": @(UIModalPresentationPageSheet),
@"formSheet": @(UIModalPresentationFormSheet),
@"currentContext": @(UIModalPresentationCurrentContext),
@"custom": @(UIModalPresentationCustom),
@"overFullScreen": @(UIModalPresentationOverFullScreen),
@"overCurrentContext": @(UIModalPresentationOverCurrentContext),
@"popover": @(UIModalPresentationPopover),
@"none": @(UIModalPresentationNone)
}), UIModalPresentationFullScreen, integerValue)

@end

@implementation RCCManagerModule
Expand All @@ -35,10 +52,20 @@ @implementation RCCManagerModule

- (NSDictionary *)constantsToExport
{

return @{
//Error codes
@"RCCManagerModuleCantCreateControllerErrorCode" : @(RCCManagerModuleCantCreateControllerErrorCode),
@"RCCManagerModuleCantFindTabControllerErrorCode" : @(RCCManagerModuleCantFindTabControllerErrorCode),
@"PresentFullScreen": @"fullScreen",
@"PresentPageSheet": @"pageSheet",
@"PresentFormSheet": @"formSheet",
@"PresentCurrentContext": @"currentContext",
@"PresentCustom": @"custom",
@"PresentOverFullScreen": @"overFullScreen",
@"PresentOverCurrentContext": @"overCurrentContext",
@"PresentPopover": @"popover",
@"PresentNone": @"none"
};
}

Expand Down Expand Up @@ -300,6 +327,17 @@ -(void)performSetRootController:(NSDictionary*)layout animationType:(NSString*)a
error:[RCCManagerModule rccErrorWithCode:RCCManagerModuleCantCreateControllerErrorCode description:@"could not create controller"]];
return;
}

if (layout[@"props"] && [layout[@"props"] isKindOfClass:[NSDictionary class]] && layout[@"props"][@"style"] && [layout[@"props"][@"style"] isKindOfClass: [NSDictionary class]]) {

NSDictionary *style = layout[@"props"][@"style"];
if (style[@"modalPresentationStyle"] && [style[@"modalPresentationStyle"] isKindOfClass:[NSString class]]) {

NSString *presentationStyle = style[@"modalPresentationStyle"];
UIModalPresentationStyle modalPresentationStyle = [RCTConvert UIModalPresentationStyle:presentationStyle];
controller.modalPresentationStyle = modalPresentationStyle;
}
}

[[RCCManagerModule lastModalPresenterViewController] presentViewController:controller
animated:![animationType isEqualToString:@"none"]
Expand Down