summaryrefslogtreecommitdiff
path: root/Juick/Helpers
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2021-12-01 17:43:49 +0300
committerGravatar Vitaly Takmazov2021-12-01 17:43:49 +0300
commit2c046a01003665aa78ca8f069c215ba1420c76cc (patch)
tree35bcf521084e3ed242bc841fb1920f4dcf629882 /Juick/Helpers
parentaa02a7e5ee527e20812096a6ae6294adec405877 (diff)
Present login error correctly on iPad/Mac
Diffstat (limited to 'Juick/Helpers')
-rw-r--r--Juick/Helpers/User+UIView.h2
-rw-r--r--Juick/Helpers/User+UIView.m13
2 files changed, 7 insertions, 8 deletions
diff --git a/Juick/Helpers/User+UIView.h b/Juick/Helpers/User+UIView.h
index d2f75ce..dcd7047 100644
--- a/Juick/Helpers/User+UIView.h
+++ b/Juick/Helpers/User+UIView.h
@@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface User (UIView)
-+ (void) throwUnableToLogin:(UIViewController *)view error:(NSError *)error path:(NSString *)path params:(NSDictionary * _Nullable)params;
++ (void) throwUnableToLogin:(UIViewController *)parentViewController sourceView:(UIView *)sourceView error:(NSError *)error path:(NSString *)path params:(NSDictionary * _Nullable)params;
@end
diff --git a/Juick/Helpers/User+UIView.m b/Juick/Helpers/User+UIView.m
index 4fb0bc3..2235cef 100644
--- a/Juick/Helpers/User+UIView.m
+++ b/Juick/Helpers/User+UIView.m
@@ -10,19 +10,18 @@
@implementation User (UIView)
-+(void) throwUnableToLogin:(UIViewController *)view error:(NSError *)error path:(NSString *)path params:(NSDictionary *)params {
++(void) throwUnableToLogin:(UIViewController *)parentViewController sourceView:(UIView *)sourceView error:(NSError *)error path:(NSString *)path params:(NSDictionary *)params {
UIAlertController *alert = [UIAlertController new];
NSString *title = error.userInfo[@"url"] ? error.userInfo[@"url"] : @"Something went wrong";
[alert setTitle:title];
[alert setMessage:[NSString stringWithFormat:@"err: %@, path: %@, params: %@", error.localizedDescription, path, params]];
[alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:nil]];
- UIPopoverPresentationController *popover = [alert popoverPresentationController];
- if (popover) {
- popover.sourceView = view.view;
- popover.sourceRect = CGRectMake(CGRectGetMidX(view.view.bounds), CGRectGetMidY(view.view.bounds), 0, 0);
- popover.permittedArrowDirections = UIPopoverArrowDirectionDown;
+ UIPopoverPresentationController *popopverPresenter = [alert popoverPresentationController];
+ if (popopverPresenter) {
+ popopverPresenter.sourceView = sourceView;
+ popopverPresenter.sourceRect = CGRectMake(CGRectGetMidX(sourceView.bounds), CGRectGetMidY(sourceView.bounds), 0, 0);
}
- [view presentViewController:alert animated:YES completion:nil];
+ [parentViewController presentViewController:alert animated:YES completion:nil];
}
@end