//
//  MVMCoreAlertHandler.h
//  myverizon
//
//  Created by Scott Pfeil on 3/10/14.
//  Copyright (c) 2014 Verizon Wireless. All rights reserved.
//
//  Keeps track of alerts and handles them. Should always use this to present alerts in mf.

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <MVMCore/MVMCoreTopAlertObject.h>
#import <MVMCore/MVMCoreAlertDelegateProtocol.h>

@class MVMCoreAlertObject;

@interface MVMCoreAlertHandler : NSObject

// Returns the shared instance of this singleton
+ (nullable instancetype)sharedAlertHandler;

#pragma mark - Popup Alert Functions

// Returns if any alert is currently showing (even if supressed).
- (BOOL)alertCurrentlyShowing;

// Returns if a greedy alert is currently showing (even if supressed).
- (BOOL)greedyAlertShowing;

/** Shows the popup with the passed in parameter.
 *  @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;

/** Shows the alert.
 *  @param  title                   The title of the alert.
 *  @param  message                 The message of the alert.
 *  @param  actions                 An array of actions for the alert.
 *  @param  alertStyle              Popup or action sheet
 *  @param  isGreedy                Sets up a greedy alert. In other words, any alerts currently shown or queued are dismissed.
 *  @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;

/** 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.
 *  @return                         Returns UIAlertController.
 */
- (nonnull UIAlertController *)showAlertWithAlertObject:(nonnull MVMCoreAlertObject *)alertObject;

// Removes all alerts.
- (void)removeAllAlertViews;

#pragma mark - Supression Functions

// Returns true if alerts are supressed.
- (BOOL)mfAlertsSupressed;

// Supresses the alerts (Used by other "apps" in our app).
- (void)supressMFAlerts;

// Unsupresses the alerts (Used by other "apps" in our app).
- (void)unSupressMFAlerts;

#pragma mark - Top Alert Functions

// Show based on the object. Will be used by the architecture.
- (void)showTopAlertWithObject:(nullable MVMCoreTopAlertObject *)topAlertObject;

// Convenience functions
- (void)showTopAlertErrorWithMessage:(nullable NSString *)message;
- (void)showTopAlertConfirmationWithMessage:(nullable NSString *)message;
- (void)showTopAlertWithType:(nullable NSString *)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent actionMap:(nullable NSDictionary *)actionMap additionalData:(nullable NSDictionary *)additionalData;
- (void)showTopAlertWithType:(nullable NSString *)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent buttonTitle:(nullable NSString *)buttonTitle userActionHandler:(nullable void (^)(id  _Nonnull sender))userActionHandler;

// Hides the current alert view.
- (void)hideTopAlertView;

// Hides a persistent alert based on the type string.
- (void)hidePersistentTopAlertViewOfType:(nullable NSString *)type;

// Removes all top alerts.
- (void)removeAllTopAlerts;

/// Returns YES if the persistent type is already registered in the alert queue.
- (BOOL)hasPersistentTopAlertOfType:(nullable NSString *)type;

@end
