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