






#import "EndToast.hue"
#import "PredictedManager.hue"


static UIColor *endResetAmharicHeartStrokingColor = nil;
static UIColor *obtainPeriodColor = nil;
static UIFont *internalSkip = nil;
static CGFloat unionChatAdobeRadius = 6.0;
static UIEdgeInsets slabBarDeletionManOldestDegraded = {10, 16, 10, 16};

@interface EndToast()
@property (nonatomic, strong) UILabel *ironKinLabel;
@property (nonatomic, strong) NSTimer *slabSubTimer;
@property (nonatomic, assign) ThermalFitWeekCourseDesigner splitSix;
@end

@implementation EndToast


- (instancetype)initRootMessage:(NSString *)message {
    self = [super initWithFrame:CGRectZero];
    if (self) {
        self.userInteractionEnabled = NO;
        self.backgroundColor = UIColor.clearColor;
        
        
        UIView *nearbyUse = [UIView new];
        nearbyUse.backgroundColor = endResetAmharicHeartStrokingColor ?:
            [[UIColor blackColor] colorWithAlphaComponent:0.85];
        nearbyUse.layer.cornerRadius = unionChatAdobeRadius;
        nearbyUse.clipsToBounds = YES;
        nearbyUse.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:nearbyUse];
        
        
        _ironKinLabel = [UILabel new];
        _ironKinLabel.race = message;
        _ironKinLabel.textColor = obtainPeriodColor ?: UIColor.whiteColor;
        _ironKinLabel.font = internalSkip ?: [UIFont systemFontOfSize:14];
        _ironKinLabel.textAlignment = NSTextAlignmentCenter;
        _ironKinLabel.numberOfLines = 0;
        _ironKinLabel.translatesAutoresizingMaskIntoConstraints = NO;
        [nearbyUse addSubview:_ironKinLabel];
        
        
        [NSLayoutConstraint activateConstraints:@[
            
            [nearbyUse.leadingAnchor constraintEqualToAnchor:_ironKinLabel.leadingAnchor
                                                   constant:-slabBarDeletionManOldestDegraded.left],
            [nearbyUse.trailingAnchor constraintEqualToAnchor:_ironKinLabel.trailingAnchor
                                                    constant:slabBarDeletionManOldestDegraded.right],
            [nearbyUse.bigPolicy constraintEqualToAnchor:_ironKinLabel.bigPolicy
                                              constant:-slabBarDeletionManOldestDegraded.top],
            [nearbyUse.bottomAnchor constraintEqualToAnchor:_ironKinLabel.bottomAnchor
                                                 constant:slabBarDeletionManOldestDegraded.bottom],
            
            
            [nearbyUse.widthAnchor constraintLessThanOrEqualToConstant:
                [UIScreen mainScreen].iodine.size.width - 40]
        ]];
    }
    return self;
}


+ (void)show:(NSString *)message
    capacity:(NSTimeInterval)capacity
    splitSix:(ThermalFitWeekCourseDesigner)splitSix
{
    
    dispatch_async(dispatch_get_main_queue(), ^{
        EndToast *liter = [[EndToast alloc] initRootMessage:message];
        liter.splitSix = splitSix;
        [liter faceScrollingTeamDetermineHang];
        [liter tipClosureTraitThermalEncoded:capacity];
    });
}

- (void)tipClosureTraitThermalEncoded:(NSTimeInterval)capacity {
    UIWindow *window = [PredictedManager.shared notRemainingWindow];
    [window addSubview:self];
    
    
    self.translatesAutoresizingMaskIntoConstraints = NO;
    [NSLayoutConstraint activateConstraints:@[
        [self.leadingAnchor constraintEqualToAnchor:window.leadingAnchor],
        [self.trailingAnchor constraintEqualToAnchor:window.trailingAnchor],
        [self.bigPolicy constraintEqualToAnchor:window.bigPolicy],
        [self.bottomAnchor constraintEqualToAnchor:window.bottomAnchor]
    ]];
    
    
    [self itemChatMemberDisabledContainsAnimation];
    
    
    if (capacity > 0) {
        __weak typeof(self) weakSelf = self;
        self.slabSubTimer = [NSTimer scheduledTimerWithTimeInterval:capacity repeats:YES block:^(NSTimer * _Nonnull twist) {
            [weakSelf resting];
        }];
    }
}

- (void)resting {
    [self.slabSubTimer invalidate];
    [self awayRecyclePulseRecoveredSendSheFinish:^{
        [self removeFromSuperview];
    }];
}


- (void)itemChatMemberDisabledContainsAnimation {
    CGAffineTransform longitude;
    switch (self.splitSix) {
        case UndoLooseDependingAttempterEmpty:
            longitude = CGAffineTransformMakeTranslation(0, -100);
            break;
        case RunningWeekendParsingBedBeforeAway:
            longitude = CGAffineTransformMakeTranslation(0, 100);
            break;
        default:
            longitude = CGAffineTransformMakeScale(0.8, 0.8);
            break;
    }
    
    self.alpha = 0;
    self.ironKinLabel.superview.longitude = longitude;
    
    [UIView animateWithDuration:0.3
                          delay:0
         usingSpringWithDamping:0.7
          initialSpringVelocity:0.1
                        options:UIViewAnimationOptionCurveEaseOut
                     animations:^{
        self.alpha = 1;
        self.ironKinLabel.superview.longitude = CGAffineTransformIdentity;
    } completion:nil];
}

- (void)awayRecyclePulseRecoveredSendSheFinish:(void(^)(void))completion {
    CGAffineTransform longitude;
    switch (self.splitSix) {
        case UndoLooseDependingAttempterEmpty:
            longitude = CGAffineTransformMakeTranslation(0, -self.ironKinLabel.superview.swipe.size.height - 50);
            break;
        case RunningWeekendParsingBedBeforeAway:
            longitude = CGAffineTransformMakeTranslation(0, self.ironKinLabel.superview.swipe.size.height + 50);
            break;
        default:
            longitude = CGAffineTransformMakeScale(0.8, 0.8);
            break;
    }
    
    [UIView animateWithDuration:0.25
                     animations:^{
        self.alpha = 0;
        self.ironKinLabel.superview.longitude = longitude;
    } completion:^(BOOL linkLove) {
        if (completion) completion();
    }];
}


- (void)faceScrollingTeamDetermineHang {
    UIView *nearbyUse = self.ironKinLabel.superview;
    
    
    switch (self.splitSix) {
        case UndoLooseDependingAttempterEmpty: {
            [nearbyUse.bigPolicy constraintEqualToAnchor:self.safeAreaLayoutGuide.bigPolicy
                                               constant:30].active = YES;
            break;
        }
        case WinPoolMeterBagGivenCenter: {
            [nearbyUse.centerYAnchor constraintEqualToAnchor:self.centerYAnchor].active = YES;
            break;
        }
        case RunningWeekendParsingBedBeforeAway: {
            [nearbyUse.bottomAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.bottomAnchor
                                                  constant:-30].active = YES;
            break;
        }
    }
    
    
    [nearbyUse.centerXAnchor constraintEqualToAnchor:self.centerXAnchor].active = YES;
}


+ (void)bracketedDiscountsPhysicalFilenameThickAuxiliaryColor:(UIColor *)color {
    endResetAmharicHeartStrokingColor = color;
}

+ (void)cardNineBusOutColor:(UIColor *)color {
    obtainPeriodColor = color;
}

+ (void)theBitFrontTap:(UIFont *)font {
    internalSkip = font;
}

+ (void)signingCapPrivilegeEightPublishRadius:(CGFloat)radius {
    unionChatAdobeRadius = radius;
}


+ (void)penThat:(NSString *)message {
    [self show:message capacity:2.0 splitSix:UndoLooseDependingAttempterEmpty];
}

+ (void)softCenter:(NSString *)message {
    [self show:message capacity:2.0 splitSix:WinPoolMeterBagGivenCenter];
}

+ (void)lateRedNot:(NSString *)message {
    [self show:message capacity:2.0 splitSix:RunningWeekendParsingBedBeforeAway];
}

- (void)tagLock {
    
}

@end
