






#import "MidToast.h"
#import "ShearPeakManager.h"


static UIColor *controlBagEscapesEngineerExplicitColor = nil;
static UIColor *dayTildeHardColor = nil;
static UIFont *gesturesMake = nil;
static CGFloat whoTalkTrapOurRadius = 6.0;
static UIEdgeInsets veryClipSpotlightBitSmallAscended = {10, 16, 10, 16};

@interface MidToast()
@property (nonatomic, strong) UILabel *fontManLabel;
@property (nonatomic, strong) NSTimer *cupNodeTimer;
@property (nonatomic, assign) EndSpecificRedefinedKinPriority position;
@end

@implementation MidToast


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


+ (void)show:(NSString *)message
    duration:(NSTimeInterval)duration
    position:(EndSpecificRedefinedKinPriority)position
{
    
    dispatch_async(dispatch_get_main_queue(), ^{
        MidToast *slant = [[MidToast alloc] initLoopMessage:message];
        slant.position = position;
        [slant armenianCombineSettlingMetricsBin];
        [slant startMustIndexLeakyElder:duration];
    });
}

- (void)startMustIndexLeakyElder:(NSTimeInterval)duration {
    UIWindow *window = [ShearPeakManager.shared netTripleLawWindow];
    [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 intervalsBrotherSessionTailZipAnimation];
    
    
    if (duration > 0) {
        __weak typeof(self) weakSelf = self;
        self.cupNodeTimer = [NSTimer scheduledTimerWithTimeInterval:duration repeats:YES block:^(NSTimer * _Nonnull basal) {
            [weakSelf dismiss];
        }];
    }
}

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


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

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


- (void)armenianCombineSettlingMetricsBin {
    UIView *container = self.fontManLabel.superview;
    
    
    switch (self.position) {
        case NominallyChargeProducedTwentySuitable: {
            [container.topAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.topAnchor
                                               constant:30].active = YES;
            break;
        }
        case AdditiveFreezingHalftoneRequiringBeginCenter: {
            [container.centerYAnchor constraintEqualToAnchor:self.centerYAnchor].active = YES;
            break;
        }
        case BuddyNumberEjectFemaleSingleWho: {
            [container.bottomAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.bottomAnchor
                                                  constant:-30].active = YES;
            break;
        }
    }
    
    
    [container.centerXAnchor constraintEqualToAnchor:self.centerXAnchor].active = YES;
}


+ (void)glyphRuleGroupingBrowsingRowSubgroupsColor:(UIColor *)color {
    controlBagEscapesEngineerExplicitColor = color;
}

+ (void)inuitSonOffMidColor:(UIColor *)color {
    dayTildeHardColor = color;
}

+ (void)overAmountFull:(UIFont *)font {
    gesturesMake = font;
}

+ (void)schoolRedirectContentUighurSoundRadius:(CGFloat)radius {
    whoTalkTrapOurRadius = radius;
}


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

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

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

- (void)dealloc {
    
}

@end
