Skip to content

Commit 482b288

Browse files
author
DependencyBot
committed
fix(share_plus): Throw error if sharePositionOrigin not in sourceView
The sharePositionOrigin must be in the coordinate space of sourceView. See https://developer.apple.com/documentation/uikit/uipopoverpresentationcontroller/1622324-sourcerect
1 parent b9951b7 commit 482b288

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/share_plus/share_plus/ios/Classes/FLTSharePlusPlugin.m

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,22 @@ + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
261261

262262
UIViewController *topViewController =
263263
TopViewControllerForViewController(RootViewController());
264+
BOOL isCoordinateSpaceOfSourceView =
265+
CGRectContainsRect(topViewController.view.frame, originRect);
266+
if (!isCoordinateSpaceOfSourceView) {
267+
result([FlutterError
268+
errorWithCode:@"error"
269+
message:[NSString
270+
stringWithFormat:
271+
@"sharePositionOrigin: %@ must be within "
272+
@"coordinate space of source view: %@",
273+
NSStringFromCGRect(originRect),
274+
NSStringFromCGRect(
275+
topViewController.view.bounds)]
276+
details:nil]);
277+
return;
278+
}
279+
264280
[self shareText:shareText
265281
subject:shareSubject
266282
withController:topViewController

0 commit comments

Comments
 (0)