






#import "SobToast.h"
#import "AssumeNotManager.h"


static UIColor *norwegianDryBinDanishDescendColor = nil;
static UIColor *caseMediaRunColor = nil;
static UIFont *mathChinaToo = nil;
static CGFloat charHitRowMoreRadius = 6.0;
static UIEdgeInsets goldenCutterWelshBackwardsNoiseWrapper = {10, 16, 10, 16};

@interface SobToast()
@property (nonatomic, strong) UILabel *areBlueLabel;
@property (nonatomic, strong) NSTimer *checkerTimer;
@property (nonatomic, assign) TrashFetchShiftDisallowUnwind position;
@end

@implementation SobToast


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


+ (void)show:(NSString *)message
    duration:(NSTimeInterval)duration
    position:(TrashFetchShiftDisallowUnwind)position
{
    
    dispatch_async(dispatch_get_main_queue(), ^{
        SobToast *three = [[SobToast alloc] initMustMessage:message];
        three.position = position;
        [three minSpotlightDragDarkerComponent];
        [three thousandsPerformerFeetCurrentlyHas:duration];
    });
}

- (void)thousandsPerformerFeetCurrentlyHas:(NSTimeInterval)duration {
    UIWindow *window = [AssumeNotManager.shared headsetEarlyWindow];
    [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 sinCheckoutPopGainClearedAnimation];
    
    
    if (duration > 0) {
        __weak typeof(self) weakSelf = self;
        self.checkerTimer = [NSTimer scheduledTimerWithTimeInterval:duration repeats:YES block:^(NSTimer * _Nonnull focal) {
            [weakSelf dismiss];
        }];
    }
}

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


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

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


- (void)minSpotlightDragDarkerComponent {
    UIView *container = self.areBlueLabel.superview;
    
    
    switch (self.position) {
        case SpaShapeBaseFunNominal: {
            [container.topAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.topAnchor
                                               constant:30].active = YES;
            break;
        }
        case SmallPlanAlienMirroredLoudCenter: {
            [container.centerYAnchor constraintEqualToAnchor:self.centerYAnchor].active = YES;
            break;
        }
        case JumpMutableMuteSingularUpdateFocused: {
            [container.bottomAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.bottomAnchor
                                                  constant:-30].active = YES;
            break;
        }
    }
    
    
    [container.centerXAnchor constraintEqualToAnchor:self.centerXAnchor].active = YES;
}


+ (void)truncateCancelSmoothBackwardBedLandscapeColor:(UIColor *)color {
    norwegianDryBinDanishDescendColor = color;
}

+ (void)areaCopperRestColor:(UIColor *)color {
    caseMediaRunColor = color;
}

+ (void)sendSunEdgaEgg:(UIFont *)font {
    mathChinaToo = font;
}

+ (void)didBuildPassivelyWristOrderingRadius:(CGFloat)radius {
    charHitRowMoreRadius = radius;
}


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

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

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

- (void)dealloc {
    
}

@end
