alert handler takes alert object
This commit is contained in:
parent
e0a704ec51
commit
636417b317
@ -219,7 +219,7 @@ NSString * const KeyActionTypeOpen = @"openPage";
|
||||
NSDictionary *responseInfo = [jsonDictionary dict:KeyResponseInfo];
|
||||
if (responseInfo) {
|
||||
MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectForPageType:pageTypeForTopAlert responseInfo:responseInfo additionalData:additionalData actionDelegate:delegate];
|
||||
if ([delegate respondsToSelector:@selector(willShowPopupWithAlertObject:alertJson:)]) {
|
||||
if ([delegate respondsToSelector:@selector(willShowTopAlertWithAlertObject:alertJson:)]) {
|
||||
alertObject = [delegate willShowTopAlertWithAlertObject:alertObject alertJson:jsonDictionary];
|
||||
}
|
||||
[alertObject showAlert];
|
||||
|
||||
@ -8,11 +8,13 @@
|
||||
// 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>
|
||||
@class MVMCoreAlertObject;
|
||||
|
||||
@interface MVMCoreAlertController : UIAlertController
|
||||
|
||||
@property (nonatomic, readonly, getter=isVisible) BOOL visible;
|
||||
@property (nullable, nonatomic, copy) NSString *alertPageType;
|
||||
@property (nullable, nonatomic, strong) MVMCoreAlertObject *alertObject;
|
||||
@property (nullable, nonatomic, weak) id delegate;
|
||||
|
||||
@end
|
||||
|
||||
@ -8,11 +8,13 @@
|
||||
|
||||
#import "MVMCoreAlertController.h"
|
||||
#import "MVMCoreLoggingHandler.h"
|
||||
#import "MVMCoreAlertObject.h"
|
||||
|
||||
@interface MVMCoreAlertController ()
|
||||
|
||||
@property (nonatomic, readwrite, getter=isVisible) BOOL visible;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@implementation MVMCoreAlertController
|
||||
|
||||
@ -29,15 +29,17 @@
|
||||
- (BOOL)greedyAlertShowing;
|
||||
|
||||
/** Shows the popup with the passed in parameter.
|
||||
* @param alertObject The origonal alertObject
|
||||
* @param title The title of the alert.
|
||||
* @param message The message of the alert.
|
||||
* @param actions An array of actions for the alert.
|
||||
* @param isGreedy Sets up a greedy popup. In other words, any popups currently shown or queued are dismissed.
|
||||
* @return Returns the UIAlertController.
|
||||
*/
|
||||
- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray<UIAlertAction *>*)actions isGreedy:(BOOL)isGreedy;
|
||||
- (nonnull UIAlertController *)showAlertWithAlertObject:(nullable MVMCoreAlertObject *)alertObject title:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray<UIAlertAction *>*)actions isGreedy:(BOOL)isGreedy;
|
||||
|
||||
/** Shows the alert.
|
||||
* @param alertObject The origonal alertObject
|
||||
* @param title The title of the alert.
|
||||
* @param message The message of the alert.
|
||||
* @param actions An array of actions for the alert.
|
||||
@ -46,7 +48,7 @@
|
||||
* @param alertDelegate The delegate to be notified.
|
||||
* @return Returns the UIAlertController.
|
||||
*/
|
||||
- (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;
|
||||
- (nonnull UIAlertController *)showAlertWithAlertObject:(nullable MVMCoreAlertObject *)alertObject title:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray<UIAlertAction *>*)actions alertStyle:(UIAlertControllerStyle)alertStyle isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject <MVMCoreAlertDelegateProtocol>*)alertDelegate;
|
||||
|
||||
/** Shows the popup with the passed in alert object. This is a convenience method that automatically handles using the proper alert type based on what's available.
|
||||
* @param alertObject The alert object to use for the alert.
|
||||
|
||||
@ -72,15 +72,15 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray<UIAlertAction *>*)actions isGreedy:(BOOL)isGreedy {
|
||||
- (nonnull UIAlertController *)showAlertWithAlertObject:(nullable MVMCoreAlertObject *)alertObject title:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray<UIAlertAction *>*)actions isGreedy:(BOOL)isGreedy {
|
||||
return [self showAlertWithTitle:title message:message actions:actions isGreedy:isGreedy alertDelegate:nil];
|
||||
}
|
||||
|
||||
- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray<UIAlertAction *>*)actions isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject <MVMCoreAlertDelegateProtocol>*)alertDelegate {
|
||||
- (nonnull UIAlertController *)showAlertWithAlertObject:(nullable MVMCoreAlertObject *)alertObject title:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray<UIAlertAction *>*)actions isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject <MVMCoreAlertDelegateProtocol>*)alertDelegate {
|
||||
return [self showAlertWithTitle:title message:message actions:actions alertStyle:UIAlertControllerStyleAlert isGreedy:isGreedy alertDelegate:alertDelegate];
|
||||
}
|
||||
|
||||
- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message pageType:(nullable NSString *)pageType actions:(nullable NSArray<UIAlertAction *>*)actions alertStyle:(UIAlertControllerStyle)alertStyle isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject <MVMCoreAlertDelegateProtocol>*)alertDelegate {
|
||||
- (nonnull UIAlertController *)showAlertWithAlertObject:(nullable MVMCoreAlertObject *)alertObject title:(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) {
|
||||
@ -89,7 +89,8 @@
|
||||
|
||||
// Create the alert. Adds the actions one by one.
|
||||
MVMCoreAlertController *alertController = [MVMCoreAlertController alertControllerWithTitle:(title ?: @"") message:message preferredStyle:alertStyle];
|
||||
alertController.alertPageType = pageType;
|
||||
alertController.alertObject = alertObject;
|
||||
alertController.alertPageType = alertObject.pageType;
|
||||
alertController.delegate = alertDelegate;
|
||||
for (NSUInteger i = 0; i < [actions count]; i++) {
|
||||
UIAlertAction *action = [actions objectAtIndex:i ofType:[UIAlertAction class]];
|
||||
@ -104,7 +105,7 @@
|
||||
}
|
||||
|
||||
- (nonnull UIAlertController *)showAlertWithAlertObject:(nonnull MVMCoreAlertObject *)alertObject {
|
||||
return [self showAlertWithTitle:alertObject.title message:alertObject.message pageType:alertObject.pageType actions:alertObject.actions alertStyle:alertObject.alertStyle isGreedy:alertObject.isGreedy alertDelegate:alertObject.alertDelegate];
|
||||
return [self showAlertWithAlertObject:alertObject title:alertObject.title message:alertObject.message pageType:alertObject.pageType actions:alertObject.actions alertStyle:alertObject.alertStyle isGreedy:alertObject.isGreedy alertDelegate:alertObject.alertDelegate];
|
||||
}
|
||||
|
||||
- (void)removeAllAlertViews {
|
||||
|
||||
@ -28,6 +28,7 @@ typedef void (^TextFieldErrorHandler)(NSArray * _Nonnull fieldErrors);
|
||||
@interface MVMCoreAlertObject : NSObject
|
||||
|
||||
@property (nullable, strong, nonatomic) NSString *title;
|
||||
@property (nullable, copy, nonatomic) NSDictionary *pageJson;
|
||||
@property (nullable, strong, nonatomic) NSString *message;
|
||||
@property (nullable, strong, nonatomic) NSString *pageType;
|
||||
@property (nonnull, strong, nonatomic) NSArray *actions;
|
||||
|
||||
@ -146,6 +146,7 @@
|
||||
|
||||
MVMCoreAlertObject *alert = [[MVMCoreAlertObject alloc] init];
|
||||
alert.title = [page stringForKey:KeyTitle];
|
||||
alert.pageJson = page;
|
||||
alert.message = [page stringForKey:KeyMessage];
|
||||
alert.isGreedy = isGreedy;
|
||||
alert.type = MFAlertTypePopup;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user