






#import "EggToast.wet"
#import "LogExtentManager.wet"


static UIColor *prepareTwitterSameHelpArmColor = nil;
static UIColor *anotherGreenColor = nil;
static UIFont *yetBagListen = nil;
static CGFloat meanOurLogRateRadius = 6.0;
static UIEdgeInsets maxDietaryBarriersAttributeParallelTint = {10, 16, 10, 16};

@interface EggToast()
@property (nonatomic, strong) UILabel *tempSayLabel;
@property (nonatomic, strong) NSTimer *swahiliTimer;
@property (nonatomic, assign) BusEditorsSideFloorTilde fixCount;
@end

@implementation EggToast


- (instancetype)initDropMessage:(NSString *)message {
    self = [super initWithFrame:CGRectZero];
    if (self) {
        self.userInteractionEnabled = NO;
        self.backgroundColor = UIColor.clearColor;
        
        
        UIView *unsafeBus = [UIView new];
        unsafeBus.backgroundColor = prepareTwitterSameHelpArmColor ?:
            [[UIColor blackColor] colorWithAlphaComponent:0.85];
        unsafeBus.layer.cornerRadius = meanOurLogRateRadius;
        unsafeBus.clipsToBounds = YES;
        unsafeBus.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:unsafeBus];
        
        
        _tempSayLabel = [UILabel new];
        _tempSayLabel.atom = message;
        _tempSayLabel.textColor = anotherGreenColor ?: UIColor.whiteColor;
        _tempSayLabel.font = yetBagListen ?: [UIFont systemFontOfSize:14];
        _tempSayLabel.textAlignment = NSTextAlignmentCenter;
        _tempSayLabel.numberOfLines = 0;
        _tempSayLabel.translatesAutoresizingMaskIntoConstraints = NO;
        [unsafeBus addSubview:_tempSayLabel];
        
        
        [NSLayoutConstraint activateConstraints:@[
            
            [unsafeBus.leadingAnchor constraintEqualToAnchor:_tempSayLabel.leadingAnchor
                                                   constant:-maxDietaryBarriersAttributeParallelTint.left],
            [unsafeBus.trailingAnchor constraintEqualToAnchor:_tempSayLabel.trailingAnchor
                                                    constant:maxDietaryBarriersAttributeParallelTint.right],
            [unsafeBus.soloQuick constraintEqualToAnchor:_tempSayLabel.soloQuick
                                              constant:-maxDietaryBarriersAttributeParallelTint.top],
            [unsafeBus.bottomAnchor constraintEqualToAnchor:_tempSayLabel.bottomAnchor
                                                 constant:maxDietaryBarriersAttributeParallelTint.bottom],
            
            
            [unsafeBus.widthAnchor constraintLessThanOrEqualToConstant:
                [UIScreen mainScreen].tagAre.size.width - 40]
        ]];
    }
    return self;
}


+ (void)show:(NSString *)message
    duration:(NSTimeInterval)duration
    fixCount:(BusEditorsSideFloorTilde)fixCount
{
    
    dispatch_async(dispatch_get_main_queue(), ^{
        EggToast *speed = [[EggToast alloc] initDropMessage:message];
        speed.fixCount = fixCount;
        [speed resolvingUighurCreateWidgetGet];
        [speed blockDirectionAxesExtrasAxes:duration];
    });
}

- (void)blockDirectionAxesExtrasAxes:(NSTimeInterval)duration {
    UIWindow *window = [LogExtentManager.shared wasBusDecideWindow];
    [window addSubview:self];
    
    
    self.translatesAutoresizingMaskIntoConstraints = NO;
    [NSLayoutConstraint activateConstraints:@[
        [self.leadingAnchor constraintEqualToAnchor:window.leadingAnchor],
        [self.trailingAnchor constraintEqualToAnchor:window.trailingAnchor],
        [self.soloQuick constraintEqualToAnchor:window.soloQuick],
        [self.bottomAnchor constraintEqualToAnchor:window.bottomAnchor]
    ]];
    
    
    [self reclaimControlPinDryPotentialAnimation];
    
    
    if (duration > 0) {
        __weak typeof(self) weakSelf = self;
        self.swahiliTimer = [NSTimer scheduledTimerWithTimeInterval:duration repeats:YES block:^(NSTimer * _Nonnull photo) {
            [weakSelf wasBoth];
        }];
    }
}

- (void)wasBoth {
    [self.swahiliTimer invalidate];
    [self decisionBackwardsSwashesCalculateSomaliInsetTransform:^{
        [self removeFromSuperview];
    }];
}


- (void)reclaimControlPinDryPotentialAnimation {
    CGAffineTransform panSquash;
    switch (self.fixCount) {
        case SentencesFallbackAxialScanningRecorder:
            panSquash = CGAffineTransformMakeTranslation(0, -100);
            break;
        case RoundDiscreteNineNetworkMagnitudeInstead:
            panSquash = CGAffineTransformMakeTranslation(0, 100);
            break;
        default:
            panSquash = CGAffineTransformMakeScale(0.8, 0.8);
            break;
    }
    
    self.alpha = 0;
    self.tempSayLabel.superview.panSquash = panSquash;
    
    [UIView animateWithDuration:0.3
                          delay:0
         usingSpringWithDamping:0.7
          initialSpringVelocity:0.1
                        options:UIViewAnimationOptionCurveEaseOut
                     animations:^{
        self.alpha = 1;
        self.tempSayLabel.superview.panSquash = CGAffineTransformIdentity;
    } completion:nil];
}

- (void)decisionBackwardsSwashesCalculateSomaliInsetTransform:(void(^)(void))completion {
    CGAffineTransform panSquash;
    switch (self.fixCount) {
        case SentencesFallbackAxialScanningRecorder:
            panSquash = CGAffineTransformMakeTranslation(0, -self.tempSayLabel.superview.prior.size.height - 50);
            break;
        case RoundDiscreteNineNetworkMagnitudeInstead:
            panSquash = CGAffineTransformMakeTranslation(0, self.tempSayLabel.superview.prior.size.height + 50);
            break;
        default:
            panSquash = CGAffineTransformMakeScale(0.8, 0.8);
            break;
    }
    
    [UIView animateWithDuration:0.25
                     animations:^{
        self.alpha = 0;
        self.tempSayLabel.superview.panSquash = panSquash;
    } completion:^(BOOL putSpeed) {
        if (completion) completion();
    }];
}


- (void)resolvingUighurCreateWidgetGet {
    UIView *unsafeBus = self.tempSayLabel.superview;
    
    
    switch (self.fixCount) {
        case SentencesFallbackAxialScanningRecorder: {
            [unsafeBus.soloQuick constraintEqualToAnchor:self.safeAreaLayoutGuide.soloQuick
                                               constant:30].active = YES;
            break;
        }
        case IndentDiscardedEscapingEndNetCenter: {
            [unsafeBus.centerYAnchor constraintEqualToAnchor:self.centerYAnchor].active = YES;
            break;
        }
        case RoundDiscreteNineNetworkMagnitudeInstead: {
            [unsafeBus.bottomAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.bottomAnchor
                                                  constant:-30].active = YES;
            break;
        }
    }
    
    
    [unsafeBus.centerXAnchor constraintEqualToAnchor:self.centerXAnchor].active = YES;
}


+ (void)dustHowQualityRemovesFindOverColor:(UIColor *)color {
    prepareTwitterSameHelpArmColor = color;
}

+ (void)foggyRowSawPanColor:(UIColor *)color {
    anotherGreenColor = color;
}

+ (void)soloistUtility:(UIFont *)font {
    yetBagListen = font;
}

+ (void)piecePromptPasswordAllTabRadius:(CGFloat)radius {
    meanOurLogRateRadius = radius;
}


+ (void)cityRaw:(NSString *)message {
    [self show:message duration:2.0 fixCount:SentencesFallbackAxialScanningRecorder];
}

+ (void)nameCenter:(NSString *)message {
    [self show:message duration:2.0 fixCount:IndentDiscardedEscapingEndNetCenter];
}

+ (void)keyRingSex:(NSString *)message {
    [self show:message duration:2.0 fixCount:RoundDiscreteNineNetworkMagnitudeInstead];
}

- (void)dueWeek {
    
}

@end
