






#import "LawToast.h"
#import "ManualCupManager.h"


static UIColor *airMirroredDitheredContainedWeightColor = nil;
static UIColor *bigSongCoastColor = nil;
static UIFont *joulePassive = nil;
static CGFloat promptPositionRadius = 6.0;
static UIEdgeInsets patternsUnableYahooAudiencesTwelveSidebar = {10, 16, 10, 16};

@interface LawToast()
@property (nonatomic, strong) UILabel *dateDidLabel;
@property (nonatomic, strong) NSTimer *seeNameTimer;
@property (nonatomic, assign) FillKilogramsAuthorityExpectingMile position;
@end

@implementation LawToast


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


+ (void)show:(NSString *)message
    duration:(NSTimeInterval)duration
    position:(FillKilogramsAuthorityExpectingMile)position
{
    
    dispatch_async(dispatch_get_main_queue(), ^{
        LawToast *human = [[LawToast alloc] initPickMessage:message];
        human.position = position;
        [human teethOwnershipAllAskGet];
        [human calorieLandscapeSpeakersBetterVirtual:duration];
    });
}

- (void)calorieLandscapeSpeakersBetterVirtual:(NSTimeInterval)duration {
    UIWindow *window = [ManualCupManager.shared paperMillOptWindow];
    [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 accurateTintParticleMayFiberAnimation];
    
    
    if (duration > 0) {
        __weak typeof(self) weakSelf = self;
        self.seeNameTimer = [NSTimer scheduledTimerWithTimeInterval:duration repeats:YES block:^(NSTimer * _Nonnull water) {
            [weakSelf dismiss];
        }];
    }
}

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


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

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


- (void)teethOwnershipAllAskGet {
    UIView *container = self.dateDidLabel.superview;
    
    
    switch (self.position) {
        case WarningArchiveTrapNewtonsWhile: {
            [container.topAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.topAnchor
                                               constant:30].active = YES;
            break;
        }
        case ImportantThresholdBundlesEndpointsTopCenter: {
            [container.centerYAnchor constraintEqualToAnchor:self.centerYAnchor].active = YES;
            break;
        }
        case RawResponseUploadRedSoftNearby: {
            [container.bottomAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.bottomAnchor
                                                  constant:-30].active = YES;
            break;
        }
    }
    
    
    [container.centerXAnchor constraintEqualToAnchor:self.centerXAnchor].active = YES;
}


+ (void)opacityMolarSonHumanMakeDocumentsColor:(UIColor *)color {
    airMirroredDitheredContainedWeightColor = color;
}

+ (void)fitSmallOffCapColor:(UIColor *)color {
    bigSongCoastColor = color;
}

+ (void)usedPlanarLose:(UIFont *)font {
    joulePassive = font;
}

+ (void)purpleLighterInheritedScrollingEggRadius:(CGFloat)radius {
    promptPositionRadius = radius;
}


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

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

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

- (void)dealloc {
    
}

@end
