






#import "UseToast.h"
#import "SoloSlantManager.h"


static UIColor *modifiedCreditOutUnitAzimuthColor = nil;
static UIColor *takeWinMixerColor = nil;
static UIFont *playingInuit = nil;
static CGFloat bleedLaunchingRadius = 6.0;
static UIEdgeInsets clockEntitiesBarMinimumSectionsProvider = {10, 16, 10, 16};

@interface UseToast()
@property (nonatomic, strong) UILabel *anchorsLabel;
@property (nonatomic, strong) NSTimer *handlerTimer;
@property (nonatomic, assign) FlexibleMaleRejectArcheryWhite position;
@end

@implementation UseToast


- (instancetype)initDateMessage:(NSString *)message {
    self = [super initWithFrame:CGRectZero];
    if (self) {
        self.userInteractionEnabled = NO;
        self.backgroundColor = UIColor.clearColor;
        
        
        UIView *container = [UIView new];
        container.backgroundColor = modifiedCreditOutUnitAzimuthColor ?:
            [[UIColor blackColor] colorWithAlphaComponent:0.85];
        container.layer.cornerRadius = bleedLaunchingRadius;
        container.clipsToBounds = YES;
        container.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:container];
        
        
        _anchorsLabel = [UILabel new];
        _anchorsLabel.text = message;
        _anchorsLabel.textColor = takeWinMixerColor ?: UIColor.whiteColor;
        _anchorsLabel.font = playingInuit ?: [UIFont systemFontOfSize:14];
        _anchorsLabel.textAlignment = NSTextAlignmentCenter;
        _anchorsLabel.numberOfLines = 0;
        _anchorsLabel.translatesAutoresizingMaskIntoConstraints = NO;
        [container addSubview:_anchorsLabel];
        
        
        [NSLayoutConstraint activateConstraints:@[
            
            [container.leadingAnchor constraintEqualToAnchor:_anchorsLabel.leadingAnchor
                                                   constant:-clockEntitiesBarMinimumSectionsProvider.left],
            [container.trailingAnchor constraintEqualToAnchor:_anchorsLabel.trailingAnchor
                                                    constant:clockEntitiesBarMinimumSectionsProvider.right],
            [container.topAnchor constraintEqualToAnchor:_anchorsLabel.topAnchor
                                              constant:-clockEntitiesBarMinimumSectionsProvider.top],
            [container.bottomAnchor constraintEqualToAnchor:_anchorsLabel.bottomAnchor
                                                 constant:clockEntitiesBarMinimumSectionsProvider.bottom],
            
            
            [container.widthAnchor constraintLessThanOrEqualToConstant:
                [UIScreen mainScreen].bounds.size.width - 40]
        ]];
    }
    return self;
}


+ (void)show:(NSString *)message
    duration:(NSTimeInterval)duration
    position:(FlexibleMaleRejectArcheryWhite)position
{
    
    dispatch_async(dispatch_get_main_queue(), ^{
        UseToast *bleed = [[UseToast alloc] initDateMessage:message];
        bleed.position = position;
        [bleed cautionInvalidEquallyMenstrualScore];
        [bleed mostlyMeterPicturesSubmitRoom:duration];
    });
}

- (void)mostlyMeterPicturesSubmitRoom:(NSTimeInterval)duration {
    UIWindow *window = [SoloSlantManager.shared foggyTiedDueWindow];
    [window addSubview:self];
    
    
    self.translatesAutoresizingMaskIntoConstraints = NO;
    [NSLayoutConstraint activateConstraints:@[
        [self.leadingAnchor constraintEqualToAnchor:window.leadingAnchor],
        [self.trailingAnchor constraintEqualToAnchor:window.trailingAnchor],
        [self.topAnchor constraintEqualToAnchor:window.topAnchor],
        [self.bottomAnchor constraintEqualToAnchor:window.bottomAnchor]
    ]];
    
    
    [self blobHungarianDeveloperBandwidthMinimizeAnimation];
    
    
    if (duration > 0) {
        __weak typeof(self) weakSelf = self;
        self.handlerTimer = [NSTimer scheduledTimerWithTimeInterval:duration repeats:YES block:^(NSTimer * _Nonnull stair) {
            [weakSelf dismiss];
        }];
    }
}

- (void)dismiss {
    [self.handlerTimer invalidate];
    [self misplacedSecureTapFetchBannerBusyPut:^{
        [self removeFromSuperview];
    }];
}


- (void)blobHungarianDeveloperBandwidthMinimizeAnimation {
    CGAffineTransform transform;
    switch (self.position) {
        case SixteenStormIdleBinEnable:
            transform = CGAffineTransformMakeTranslation(0, -100);
            break;
        case SnowWorkClippingThousandsWeekendOptimized:
            transform = CGAffineTransformMakeTranslation(0, 100);
            break;
        default:
            transform = CGAffineTransformMakeScale(0.8, 0.8);
            break;
    }
    
    self.alpha = 0;
    self.anchorsLabel.superview.transform = transform;
    
    [UIView animateWithDuration:0.3
                          delay:0
         usingSpringWithDamping:0.7
          initialSpringVelocity:0.1
                        options:UIViewAnimationOptionCurveEaseOut
                     animations:^{
        self.alpha = 1;
        self.anchorsLabel.superview.transform = CGAffineTransformIdentity;
    } completion:nil];
}

- (void)misplacedSecureTapFetchBannerBusyPut:(void(^)(void))completion {
    CGAffineTransform transform;
    switch (self.position) {
        case SixteenStormIdleBinEnable:
            transform = CGAffineTransformMakeTranslation(0, -self.anchorsLabel.superview.frame.size.height - 50);
            break;
        case SnowWorkClippingThousandsWeekendOptimized:
            transform = CGAffineTransformMakeTranslation(0, self.anchorsLabel.superview.frame.size.height + 50);
            break;
        default:
            transform = CGAffineTransformMakeScale(0.8, 0.8);
            break;
    }
    
    [UIView animateWithDuration:0.25
                     animations:^{
        self.alpha = 0;
        self.anchorsLabel.superview.transform = transform;
    } completion:^(BOOL finished) {
        if (completion) completion();
    }];
}


- (void)cautionInvalidEquallyMenstrualScore {
    UIView *container = self.anchorsLabel.superview;
    
    
    switch (self.position) {
        case SixteenStormIdleBinEnable: {
            [container.topAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.topAnchor
                                               constant:30].active = YES;
            break;
        }
        case AwayCurveFactoriesLoveBlendCenter: {
            [container.centerYAnchor constraintEqualToAnchor:self.centerYAnchor].active = YES;
            break;
        }
        case SnowWorkClippingThousandsWeekendOptimized: {
            [container.bottomAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.bottomAnchor
                                                  constant:-30].active = YES;
            break;
        }
    }
    
    
    [container.centerXAnchor constraintEqualToAnchor:self.centerXAnchor].active = YES;
}


+ (void)handledBundlesResultingBrownUsageDesignColor:(UIColor *)color {
    modifiedCreditOutUnitAzimuthColor = color;
}

+ (void)awakeFractionsColor:(UIColor *)color {
    takeWinMixerColor = color;
}

+ (void)markAlertSound:(UIFont *)font {
    playingInuit = font;
}

+ (void)allergyBikePointQueryingContextRadius:(CGFloat)radius {
    bleedLaunchingRadius = radius;
}


+ (void)dashMen:(NSString *)message {
    [self show:message duration:2.0 position:SixteenStormIdleBinEnable];
}

+ (void)taskCenter:(NSString *)message {
    [self show:message duration:2.0 position:AwayCurveFactoriesLoveBlendCenter];
}

+ (void)finishForm:(NSString *)message {
    [self show:message duration:2.0 position:SnowWorkClippingThousandsWeekendOptimized];
}

- (void)dealloc {
    
}

@end
