changes to the way popup delegacy works
This commit is contained in:
parent
cbcab0ea1c
commit
bffb93660d
@ -8,13 +8,11 @@
|
||||
// Used by our alert handler. Not for subclassing. Simply keeps track of if it's visible. Tries to parallel the UIAlertView to make it easier for the MVMCoreAlertHandler.
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <MVMCore/MVMCoreAlertDelegateProtocol.h>
|
||||
@class MVMCoreAlertObject;
|
||||
|
||||
@interface MVMCoreAlertController : UIAlertController
|
||||
|
||||
@property (nonatomic, readonly, getter=isVisible) BOOL visible;
|
||||
@property (nullable, nonatomic, strong) MVMCoreAlertObject *alertObject;
|
||||
@property (nullable, nonatomic, weak) NSObject <MVMCoreAlertDelegateProtocol>*delegate;
|
||||
|
||||
@end
|
||||
|
||||
@ -8,7 +8,6 @@
|
||||
|
||||
#import "MVMCoreAlertController.h"
|
||||
#import "MVMCoreLoggingHandler.h"
|
||||
#import "MVMCoreAlertObject.h"
|
||||
|
||||
@interface MVMCoreAlertController ()
|
||||
|
||||
|
||||
@ -81,7 +81,7 @@
|
||||
}
|
||||
|
||||
- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray<UIAlertAction *>*)actions alertStyle:(UIAlertControllerStyle)alertStyle isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject <MVMCoreAlertDelegateProtocol>*)alertDelegate {
|
||||
|
||||
|
||||
// It's a greedy alert! Clear all alerts that are queued up and the one that is showing
|
||||
if (isGreedy) {
|
||||
[self removeAllAlertViews];
|
||||
@ -89,7 +89,6 @@
|
||||
|
||||
// Create the alert. Adds the actions one by one.
|
||||
MVMCoreAlertController *alertController = [MVMCoreAlertController alertControllerWithTitle:(title ?: @"") message:message preferredStyle:alertStyle];
|
||||
alertController.delegate = alertDelegate;
|
||||
for (NSUInteger i = 0; i < [actions count]; i++) {
|
||||
UIAlertAction *action = [actions objectAtIndex:i ofType:[UIAlertAction class]];
|
||||
if (action) {
|
||||
|
||||
@ -50,6 +50,7 @@
|
||||
__block MVMCoreAlertObject *alert = [[MVMCoreAlertObject alloc] init];
|
||||
alert.title = [responseInfo stringForKey:KeyErrorHeading];
|
||||
alert.message = [responseInfo stringForKey:KeyUserMessage];
|
||||
alert.alertDelegate = actionDelegate;
|
||||
|
||||
NSString *messageStyle = [responseInfo stringForKey:KeyMessageStyle];
|
||||
if ([ValueTypeFieldErrors isEqualToString:[responseInfo string:KeyType]]) {
|
||||
@ -71,6 +72,7 @@
|
||||
// Perform a popup.
|
||||
alert.type = MFAlertTypePopup;
|
||||
alert.alertStyle = UIAlertControllerStyleAlert;
|
||||
|
||||
// Check if we have a popup driven by page object (otherwise by default it will just use response info title message with an OK button).
|
||||
NSString *pageTypeForPopup = [responseInfo stringForKey:@"popupPageType"];
|
||||
[[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForPopup queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) {
|
||||
@ -87,8 +89,6 @@
|
||||
alert = popupAlert;
|
||||
}
|
||||
}];
|
||||
alert.pageType = pageTypeForPopup;
|
||||
alert.alertDelegate = actionDelegate;
|
||||
} else if (messageStyle.length == 0 && pageType) {
|
||||
|
||||
// No message style!
|
||||
|
||||
Loading…
Reference in New Issue
Block a user