//
//  PrimaryButton.h
//  myverizon
//
//  Created by Scott Pfeil on 12/2/15.
//  Copyright © 2015 Verizon Wireless. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <MVMCoreUI/MFCustomButton.h>
#import <MVMCoreUI/MFTextField.h>
#import <MVMCoreUI/MFView.h>
#import <MVMCoreUI/MVMCoreUIMoleculeViewProtocol.h>

typedef enum : NSUInteger {
    PrimaryButtonTypeRed,
    PrimaryButtonTypeGray,
    PrimaryButtonTypeWhiteRed,
    PrimaryButtonTypeGrayRed,
    // 2.0
    PrimaryButtonTypeBlack,
    PrimaryButtonTypeWhite,
    PrimaryButtonTypeCustom
} PrimaryButtonType;

static CGFloat const PrimaryButtonHeight = 42.0;
static CGFloat const PrimaryButtonSmallHeight = 30.0;

@interface PrimaryButton : MFCustomButton <MFTextFieldDelegate, UITextFieldDelegate, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol>

@property (nonatomic, readonly, assign) PrimaryButtonType primaryButtonType; //use reset function to set

// For custom type.
@property (nonatomic, strong, nullable) UIColor *fillColor;
@property (nonatomic, strong, nullable) UIColor *borderColor;
@property (nonatomic, strong, nullable) UIColor *textColor;
@property (nonatomic, strong, nullable) UIColor *disabledFillColor;
@property (nonatomic, strong, nullable) UIColor *disabledBorderColor;
@property (nonatomic, strong, nullable) UIColor *disabledTextColor;

@property (nullable, copy, nonatomic) BOOL(^extraValidationBlock)(void);

// Set as no to make button filled, set as yes to make button bordered.
@property (nonatomic) BOOL bordered;

// set YES to skip highlight method, for customer color button
@property (nonatomic) BOOL skipHighlighted;

// The main creation functions, changed to black button for 2.0 for default
+ (nullable instancetype)primaryButton:(BOOL)enabled;
+ (nullable instancetype)primarySmallButton:(BOOL)enabled;
+ (nullable instancetype)primaryTinyButton:(BOOL)enabled;

+ (nonnull instancetype)primaryButton NS_SWIFT_NAME(button());
+ (nullable instancetype)primarySmallButton;
+ (nullable instancetype)primaryWhiteButton:(BOOL)small;

// legacy color functions.
+ (nullable instancetype)primaryRedButton;
+ (nullable instancetype)primaryGrayButtonSmall:(BOOL)small;
+ (nullable instancetype)primaryRedSmallButton;
+ (nullable instancetype)primaryGraySmallRedButton;
+ (nullable instancetype)primaryWhiteSmallRedButton;

// Returns the current height of the button.
- (CGFloat)getHeight;

#pragma mark - For Subclassing

// Creates and pins the height of the button, nothing more.
+ (nullable instancetype)getButton;

// Pins the height initially.
- (void)pinHeight;

#pragma mark - Setting

// The new defaults.
- (void)setAsStandardCustom;
- (void)setAsSecondaryCustom;

// For setting after creation.
- (void)setAsSmallButton:(BOOL)smallButton enabled:(BOOL)enabled bordered:(BOOL)bordered;

// Changes the size of the button. Currently only small,regular and tiny.
- (void)setAsSmallButton:(BOOL)smallButton;

// Changes the size of the button to Tiny
- (void)setAsTiny:(BOOL)tinyButton;

// Sets the button to red.
- (void)setAsRed;

// Sets the button to gray.
- (void)setAsGray;

// Sets the button to dark gray/ for white button disabled
- (void)setAsDarkGray;

// Sets the button with white background color with red border (used in ISPU)
- (void)setAsWhite;

- (void)setAsAllWhite;

- (void)setAsInactiveGray;

// Pins the width after title/text setup.
// Note: use this after setting up button title
- (void)pinWidth;

// Add edgeinset into button, redo constraints
- (void)pinEdgeInsetHeight:(CGFloat)heightInset Width:(CGFloat)widthInset;

// properly reset the button appearence 
- (void)resetButtonType:(PrimaryButtonType)type small:(BOOL)isSmall bordered:(BOOL)bordered;
- (void)resetButtonType:(PrimaryButtonType)type tiny:(BOOL)isTiny bordered:(BOOL)bordered;

#pragma mark - Handling Validations

// Sets the enabled property depending on the validity checks
- (void)setEnabledByValidity;

// Will handle enabling and disabling itself based on if all the textfields passed in are valid or not. This will set the textfields validation block to accept any entered value (except no entry).
- (void)handleEnablingWithTextFieldsDefaultValidations:(nullable NSArray <MFTextField *>*)textFields;

// Same as above but will not use default validations. You will have to set validation blocks yourself prior.
- (void)handleEnablingWithTextFields:(nullable NSArray <MFTextField *>*)textFields;

@end
