






#import "KitToast.h"
#import "AwayGlyphManager.h"


static UIColor *courseTreeVisibleWateryCentralColor = nil;
static UIColor *kinRankedKitColor = nil;
static UIFont *genreTexture = nil;
static CGFloat phaseSuspendedRadius = 6.0;
static UIEdgeInsets cleanupCompanyResponderExpandedChatFlights = {10, 16, 10, 16};

@interface KitToast()
@property (nonatomic, strong) UILabel *sigmoidLabel;
@property (nonatomic, strong) NSTimer *waxZoomTimer;
@property (nonatomic, assign) ThreadsReorderAffectingFairCert position;
@end

@implementation KitToast


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


+ (void)show:(NSString *)message
    duration:(NSTimeInterval)duration
    position:(ThreadsReorderAffectingFairCert)position
{
    
    dispatch_async(dispatch_get_main_queue(), ^{
        KitToast *tilde = [[KitToast alloc] initTurnMessage:message];
        tilde.position = position;
        [tilde accordingAssistiveFormatsNetworkChapter];
        [tilde matrixFeatureCollapseRollUpper:duration];
    });
}

- (void)matrixFeatureCollapseRollUpper:(NSTimeInterval)duration {
    UIWindow *window = [AwayGlyphManager.shared tagKeysSwipeWindow];
    [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 scrollChunkyIntegrityLocalizedDirectlyAnimation];
    
    
    if (duration > 0) {
        __weak typeof(self) weakSelf = self;
        self.waxZoomTimer = [NSTimer scheduledTimerWithTimeInterval:duration repeats:YES block:^(NSTimer * _Nonnull extra) {
            [weakSelf dismiss];
        }];
    }
}

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


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

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


- (void)accordingAssistiveFormatsNetworkChapter {
    UIView *container = self.sigmoidLabel.superview;
    
    
    switch (self.position) {
        case LinkTapBikeGujaratiCredit: {
            [container.topAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.topAnchor
                                               constant:30].active = YES;
            break;
        }
        case CallOrderMacintoshCallbacksReversesCenter: {
            [container.centerYAnchor constraintEqualToAnchor:self.centerYAnchor].active = YES;
            break;
        }
        case SlopeFamilyReportedDesignerMarginDesign: {
            [container.bottomAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.bottomAnchor
                                                  constant:-30].active = YES;
            break;
        }
    }
    
    
    [container.centerXAnchor constraintEqualToAnchor:self.centerXAnchor].active = YES;
}


+ (void)subListenersRadialHueFollowEmergencyColor:(UIColor *)color {
    courseTreeVisibleWateryCentralColor = color;
}

+ (void)correctedAlienColor:(UIColor *)color {
    kinRankedKitColor = color;
}

+ (void)workRearEarOne:(UIFont *)font {
    genreTexture = font;
}

+ (void)parserParserAbnormalPrimaryOldRadius:(CGFloat)radius {
    phaseSuspendedRadius = radius;
}


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

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

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

- (void)dealloc {
    
}

@end
