






#import "CutToast.h"
#import "ChunkyGetManager.h"


static UIColor *proxiesFilteredUpscaleBothGrayColor = nil;
static UIColor *descendFocalColor = nil;
static UIFont *manHindiJust = nil;
static CGFloat nameManSonLoadRadius = 6.0;
static UIEdgeInsets speakersSquashFinishZoomingMomentaryBar = {10, 16, 10, 16};

@interface CutToast()
@property (nonatomic, strong) UILabel *overRowLabel;
@property (nonatomic, strong) NSTimer *foreverTimer;
@property (nonatomic, assign) FadeLighterCaretDogCompare position;
@end

@implementation CutToast


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


+ (void)show:(NSString *)message
    duration:(NSTimeInterval)duration
    position:(FadeLighterCaretDogCompare)position
{
    
    dispatch_async(dispatch_get_main_queue(), ^{
        CutToast *strip = [[CutToast alloc] initWithMessage:message];
        strip.position = position;
        [strip requiringLeastSwapNibblesMaltese];
        [strip findDashSonBuddhistDisk:duration];
    });
}

- (void)findDashSonBuddhistDisk:(NSTimeInterval)duration {
    UIWindow *window = [ChunkyGetManager.shared identicalDogWindow];
    [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 indexedToneGenerateCertRopeAnimation];
    
    
    if (duration > 0) {
        __weak typeof(self) weakSelf = self;
        self.foreverTimer = [NSTimer scheduledTimerWithTimeInterval:duration repeats:YES block:^(NSTimer * _Nonnull drive) {
            [weakSelf dismiss];
        }];
    }
}

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


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

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


- (void)requiringLeastSwapNibblesMaltese {
    UIView *container = self.overRowLabel.superview;
    
    
    switch (self.position) {
        case SummarySnowAdvisedInsertingSilent: {
            [container.topAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.topAnchor
                                               constant:30].active = YES;
            break;
        }
        case RefreshedLevelNeutralVectorRunCenter: {
            [container.centerYAnchor constraintEqualToAnchor:self.centerYAnchor].active = YES;
            break;
        }
        case AdditionTallPostSecureFetchRefused: {
            [container.bottomAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.bottomAnchor
                                                  constant:-30].active = YES;
            break;
        }
    }
    
    
    [container.centerXAnchor constraintEqualToAnchor:self.centerXAnchor].active = YES;
}


+ (void)usesScopeTemporalDingbatsSideFavoritesColor:(UIColor *)color {
    proxiesFilteredUpscaleBothGrayColor = color;
}

+ (void)mapRawMenPrintColor:(UIColor *)color {
    descendFocalColor = color;
}

+ (void)secondDeferred:(UIFont *)font {
    manHindiJust = font;
}

+ (void)retryCentralFirstFatRestingRadius:(CGFloat)radius {
    nameManSonLoadRadius = radius;
}


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

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

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

- (void)dealloc {
    
}

@end
