// // FLEXAlert.h // FLEX // // Created by Tanner Bennett on 8/20/19. // Copyright © 2019 Flipboard. All rights reserved. // #import @class FLEXAlert, FLEXAlertAction; typedef void (^FLEXAlertReveal)(void); typedef void (^FLEXAlertBuilder)(FLEXAlert *make); typedef FLEXAlert *(^FLEXAlertStringProperty)(NSString *); typedef FLEXAlert *(^FLEXAlertStringArg)(NSString *); typedef FLEXAlert *(^FLEXAlertTextField)(void(^configurationHandler)(UITextField *textField)); typedef FLEXAlertAction *(^FLEXAlertAddAction)(NSString *title); typedef FLEXAlertAction *(^FLEXAlertActionStringProperty)(NSString *); typedef FLEXAlertAction *(^FLEXAlertActionProperty)(void); typedef FLEXAlertAction *(^FLEXAlertActionBOOLProperty)(BOOL); typedef FLEXAlertAction *(^FLEXAlertActionHandler)(void(^handler)(NSArray *strings)); @interface FLEXAlert : NSObject /// Shows a simple alert with one button which says "Dismiss" + (void)showAlert:(NSString *)title message:(NSString *)message from:(UIViewController *)viewController; /// Construct and display an alert + (void)makeAlert:(FLEXAlertBuilder)block showFrom:(UIViewController *)viewController; /// Construct and display an action sheet-style alert + (void)makeSheet:(FLEXAlertBuilder)block showFrom:(UIViewController *)viewController; /// Construct an alert + (UIAlertController *)makeAlert:(FLEXAlertBuilder)block; /// Construct an action sheet-style alert + (UIAlertController *)makeSheet:(FLEXAlertBuilder)block; /// Set the alert's title. /// /// Call in succession to append strings to the title. @property (nonatomic, readonly) FLEXAlertStringProperty title; /// Set the alert's message. /// /// Call in succession to append strings to the message. @property (nonatomic, readonly) FLEXAlertStringProperty message; /// Add a button with a given title with the default style and no action. @property (nonatomic, readonly) FLEXAlertAddAction button; /// Add a text field with the given (optional) placeholder text. @property (nonatomic, readonly) FLEXAlertStringArg textField; /// Add and configure the given text field. /// /// Use this if you need to more than set the placeholder, such as /// supply a delegate, make it secure entry, or change other attributes. @property (nonatomic, readonly) FLEXAlertTextField configuredTextField; @end @interface FLEXAlertAction : NSObject /// Set the action's title. /// /// Call in succession to append strings to the title. @property (nonatomic, readonly) FLEXAlertActionStringProperty title; /// Make the action destructive. It appears with red text. @property (nonatomic, readonly) FLEXAlertActionProperty destructiveStyle; /// Make the action cancel-style. It appears with a bolder font. @property (nonatomic, readonly) FLEXAlertActionProperty cancelStyle; /// Enable or disable the action. Enabled by default. @property (nonatomic, readonly) FLEXAlertActionBOOLProperty enabled; /// Give the button an action. The action takes an array of text field strings. @property (nonatomic, readonly) FLEXAlertActionHandler handler; /// Access the underlying UIAlertAction, should you need to change it while /// the encompassing alert is being displayed. For example, you may want to /// enable or disable a button based on the input of some text fields in the alert. /// Do not call this more than once per instance. @property (nonatomic, readonly) UIAlertAction *action; @end