Skip to content

Commit

Permalink
feat(ios): Allow to configure popover size (#5717)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Jun 27, 2022
1 parent 2e83133 commit ca1a125
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ios/Capacitor/Capacitor/CAPPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
-(NSString* _Nullable)getString:(CAPPluginCall* _Nonnull)call field:(NSString* _Nonnull)field defaultValue:(NSString* _Nonnull)defaultValue DEPRECATED_MSG_ATTRIBUTE("Use accessors on CAPPluginCall instead. See CAPBridgedJSTypes.h for Obj-C implementations.");
-(id _Nullable)getConfigValue:(NSString* _Nonnull)key __deprecated_msg("use getConfig() and access config values using the methods available depending on the type.");
-(PluginConfig* _Nonnull)getConfig;
-(void)setCenteredPopover:(UIViewController* _Nonnull)vc;
-(void)setCenteredPopover:(UIViewController* _Nonnull) vc;
-(void)setCenteredPopover:(UIViewController* _Nonnull) vc size:(CGSize) size;
-(BOOL)supportsPopover DEPRECATED_MSG_ATTRIBUTE("All iOS 13+ devices support popover");

@end
9 changes: 9 additions & 0 deletions ios/Capacitor/Capacitor/CAPPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ -(void)setCenteredPopover:(UIViewController *) vc {
}
}

-(void)setCenteredPopover:(UIViewController* _Nonnull) vc size:(CGSize) size {
if (self.bridge.viewController != nil) {
vc.popoverPresentationController.sourceRect = CGRectMake(self.bridge.viewController.view.center.x, self.bridge.viewController.view.center.y, 0, 0);
vc.preferredContentSize = size;
vc.popoverPresentationController.sourceView = self.bridge.viewController.view;
vc.popoverPresentationController.permittedArrowDirections = 0;
}
}

-(BOOL)supportsPopover {
return YES;
}
Expand Down

0 comments on commit ca1a125

Please # to comment.