






#import "HueToast.h"
#import "AspectTapManager.h"


static UIColor *mostSexPromisedAboutArrayColor = nil;
static UIColor *kinFatModifyColor = nil;
static UIFont *trackForTone = nil;
static CGFloat jobMakeYouStarRadius = 6.0;
static UIEdgeInsets assetDenseToleranceCelticBrotherRet = {10, 16, 10, 16};

@interface HueToast()
@property (nonatomic, strong) UILabel *holdTheLabel;
@property (nonatomic, strong) NSTimer *workSayTimer;
@property (nonatomic, assign) PreservePhoneMillLocaleAnchoring position;
@end

@implementation HueToast


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


+ (void)show:(NSString *)message
    duration:(NSTimeInterval)duration
    position:(PreservePhoneMillLocaleAnchoring)position
{
    
    dispatch_async(dispatch_get_main_queue(), ^{
        HueToast *offer = [[HueToast alloc] initSignMessage:message];
        offer.position = position;
        [offer spotlightDetectsWorkoutBitTilde];
        [offer integrityMountDutchSemaphoreNegative:duration];
    });
}

- (void)integrityMountDutchSemaphoreNegative:(NSTimeInterval)duration {
    UIWindow *window = [AspectTapManager.shared danishSawSexWindow];
    [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 resolvingOptSpeakSocketPersonAnimation];
    
    
    if (duration > 0) {
        __weak typeof(self) weakSelf = self;
        self.workSayTimer = [NSTimer scheduledTimerWithTimeInterval:duration repeats:YES block:^(NSTimer * _Nonnull prior) {
            [weakSelf dismiss];
        }];
    }
}

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


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

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


- (void)spotlightDetectsWorkoutBitTilde {
    UIView *container = self.holdTheLabel.superview;
    
    
    switch (self.position) {
        case ExpireMeterWetProcedureDecrement: {
            [container.topAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.topAnchor
                                               constant:30].active = YES;
            break;
        }
        case MagnitudeHeadsetNoteCreditsBagCenter: {
            [container.centerYAnchor constraintEqualToAnchor:self.centerYAnchor].active = YES;
            break;
        }
        case UploadedDarwinClockThatManagedDiagnose: {
            [container.bottomAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.bottomAnchor
                                                  constant:-30].active = YES;
            break;
        }
    }
    
    
    [container.centerXAnchor constraintEqualToAnchor:self.centerXAnchor].active = YES;
}


+ (void)answerPutTransportWaistFileMinorColor:(UIColor *)color {
    mostSexPromisedAboutArrayColor = color;
}

+ (void)factoredReloadColor:(UIColor *)color {
    kinFatModifyColor = color;
}

+ (void)basicExistFoot:(UIFont *)font {
    trackForTone = font;
}

+ (void)messageWideCreatorWatchTargetRadius:(CGFloat)radius {
    jobMakeYouStarRadius = radius;
}


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

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

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

- (void)dealloc {
    
}

@end
