//
//  MFSizeObject.h
//  mobilefirst
//
//  Created by Scott Pfeil on 12/20/16.
//  Copyright © 2016 Verizon Wireless. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <MVMCoreUI/MFSizeThreshold.h>

extern CGFloat const MFSizeiPhone4HeightThreshold;
extern CGFloat const MFSizeiPhone5HeightThreshold;

extern CGFloat const MFSizeSmalliPhoneThreshold;
extern CGFloat const MFSizeLargeiPhoneThreshold;
extern CGFloat const MFSizeStandardiPadPortraitThreshold;
extern CGFloat const MFSizeStandardiPadLandscapeThreshold;
extern CGFloat const MFSizeiPadProLandscapeThreshold;
extern CGFloat const MFSizeMostlySweetSpotThreshold;

@interface MFSizeObject : NSObject

// Standard size
@property (nonatomic) CGFloat standardSize;
@property (nonatomic) BOOL scaleStandardSize;
@property (nonatomic, strong, nullable) NSNumber *scaleStandardSizeBaseValue;
@property (nonatomic, copy) void (^ _Nullable standardThresholdBlock)(void);

// Can be used to set the maximum size.
@property (nonatomic) CGFloat maximumSize;

// returns value * (size/base)
+ (CGFloat)getScaledValue:(CGFloat)value forSize:(CGFloat)size fromBase:(nullable NSNumber *)base;

#pragma mark - Size Initializers

+ (nullable instancetype)sizeObjectWithStandardSize:(CGFloat)standardSize;
+ (nullable instancetype)sizeObjectWithScalingStandardSize:(CGFloat)standardSize;

// Convenience initializers.
+ (nullable instancetype)sizeObjectWithStandardSize:(CGFloat)standardSize smalliPhoneSize:(CGFloat)smalliPhoneSize standardiPadPortraitSize:(CGFloat)standardiPadPortraitSize;
+ (nullable instancetype)sizeObjectWithStandardSize:(CGFloat)standardSize standardiPadPortraitSize:(CGFloat)standardiPadPortraitSize;
+ (nullable instancetype)sizeObjectWithStandardSize:(CGFloat)standardSize smalliPhoneSize:(CGFloat)smalliPhoneSize;
+ (nullable instancetype)sizeObjectWithStandardSize:(CGFloat)standardSize standardiPadPortraitSize:(CGFloat)standardiPadPortraitSize iPadProLandscapeSize:(CGFloat)iPadProLandscapeSize;
+ (nullable instancetype)sizeObjectWithStandardSize:(CGFloat)standardSize smalliPhoneSize:(CGFloat)smalliPhoneSize standardiPadPortraitSize:(CGFloat)standardiPadPortraitSize iPadProLandscapeSize:(CGFloat)iPadProLandscapeSize;


#pragma mark - Block Initializers

+ (nullable instancetype)sizeObjectWithStandardSizeBlock:(nonnull void (^)(void))block;

// Convenience initializers.
+ (nullable instancetype)sizeObjectWithStandardBlock:(nonnull void (^)(void))standardBlock smalliPhoneBlock:(nonnull void (^)(void))smalliPhoneBlock standardiPadPortraitBlock:(nonnull void (^)(void))standardiPadPortraitBlock;
+ (nullable instancetype)sizeObjectWithStandardBlock:(nonnull void (^)(void))standardBlock standardiPadPortraitBlock:(nonnull void (^)(void))standardiPadPortraitBlock;
+ (nullable instancetype)sizeObjectWithStandardBlock:(nonnull void (^)(void))standardBlock smalliPhoneBlock:(nonnull void (^)(void))smalliPhoneBlock;
+ (nullable instancetype)sizeObjectWithStandardBlock:(nonnull void (^)(void))standardBlock standardiPadPortraitBlock:(nonnull void (^)(void))standardiPadPortraitBlock iPadProLandscapeBlock:(nonnull void (^)(void))iPadProLandscapeBlock;
+ (nullable instancetype)sizeObjectWithStandardBlock:(nonnull void (^)(void))standardBlock smalliPhoneBlock:(nonnull void (^)(void))smalliPhoneBlock standardiPadPortraitBlock:(nonnull void (^)(void))standardiPadPortraitBlock iPadProLandscapeBlock:(nonnull void (^)(void))iPadProLandscapeBlock;

#pragma mark - Size Getters

// Returns the value for the appropriate size threshold
- (CGFloat)getValueBasedOnScreenSize;
- (CGFloat)getValueBasedOnDetailWidth;
- (CGFloat)getValueBasedOnApplicationWidth;
- (CGFloat)getValueBasedOnScreenHeight;
- (CGFloat)getValueBasedOnSize:(CGFloat)size;

#pragma mark - Block performers

// Performs a block for the given sizes.
- (void)performBlockBaseOnScreenSize;
- (void)performBlockBaseOnDetailWidth;
- (void)performBlockBaseOnApplicationWidth;
- (void)performBlockBaseOnScreenHeight;
- (void)performBlockBaseOnSize:(CGFloat)size;

#pragma mark - Add size thresholds

// Can add custom thresholds and sizes.
- (void)addCustomSize:(nullable MFSizeThreshold *)sizeThreshold;
- (void)addCustomSize:(CGFloat)size forThreshold:(CGFloat)threshold compareDirection:(MFSizeCompareDirection)compareDirection;

// Common directions
- (void)addLargerThanCustomSize:(CGFloat)size forThreshold:(CGFloat)threshold;
- (void)addSmallerThanCustomSize:(CGFloat)size forThreshold:(CGFloat)threshold;
- (void)addScalingLargerThanCustomSize:(CGFloat)size forThreshold:(CGFloat)threshold;
- (void)addScalingSmallerThanCustomSize:(CGFloat)size forThreshold:(CGFloat)threshold;

// Common thresholds
- (void)addSizeForSmalliPhoneThreshold:(CGFloat)size;
- (void)addSizeForStandardiPadPortaitThreshold:(CGFloat)size;
- (void)addSizeForiPadProLandscapeThreshold:(CGFloat)size;

#pragma mark - Add block thresholds

- (void)addCustomThreshold:(CGFloat)threshold compareDirection:(MFSizeCompareDirection)compareDirection block:(nonnull void (^)(void))block;

// Common directions
- (void)addLargerThanCustomThreshold:(CGFloat)threshold block:(nonnull void (^)(void))block;
- (void)addSmallerThanCustomThreshold:(CGFloat)threshold block:(nonnull void (^)(void))block;
- (void)addScalingLargerThanCustomThreshold:(CGFloat)threshold block:(nonnull void (^)(void))block;
- (void)addScalingSmallerThanCustomThreshold:(CGFloat)threshold block:(nonnull void (^)(void))block;

// Common thresholds
- (void)addBlockForSmalliPhoneThreshold:(nonnull void (^)(void))block;
- (void)addBlockForStandardiPadPortaitThreshold:(nonnull void (^)(void))block;
- (void)addBlockForiPadProLandscapeThreshold:(nonnull void (^)(void))block;

@end
