






#import "SexToast.h"
#import "PopParserManager.h"


static UIColor *bandCreditCautionColoredWeekColor = nil;
static UIColor *futureNoticeColor = nil;
static UIFont *outBadModern = nil;
static CGFloat addPinFlagSnowRadius = 6.0;
static UIEdgeInsets supplyCompareButCapsCleanFarsi = {10, 16, 10, 16};

@interface SexToast()
@property (nonatomic, strong) UILabel *hitSuchLabel;
@property (nonatomic, strong) NSTimer *slashesTimer;
@property (nonatomic, assign) AppendedSucceedToolGreekOwner position;
@end

@implementation SexToast


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


+ (void)show:(NSString *)message
    duration:(NSTimeInterval)duration
    position:(AppendedSucceedToolGreekOwner)position
{
    
    dispatch_async(dispatch_get_main_queue(), ^{
        SexToast *tight = [[SexToast alloc] initMoleMessage:message];
        tight.position = position;
        [tight lingerIgnoredDustArmCup];
        [tight advisedCutElapsedNotSandbox:duration];
    });
}

- (void)advisedCutElapsedNotSandbox:(NSTimeInterval)duration {
    UIWindow *window = [PopParserManager.shared draftEarBookWindow];
    [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 keyboardOrdinaryWaistPlayingRestingAnimation];
    
    
    if (duration > 0) {
        __weak typeof(self) weakSelf = self;
        self.slashesTimer = [NSTimer scheduledTimerWithTimeInterval:duration repeats:YES block:^(NSTimer * _Nonnull small) {
            [weakSelf dismiss];
        }];
    }
}

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


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

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


- (void)lingerIgnoredDustArmCup {
    UIView *container = self.hitSuchLabel.superview;
    
    
    switch (self.position) {
        case AgeFaeroeseNothingReportsSerial: {
            [container.topAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.topAnchor
                                               constant:30].active = YES;
            break;
        }
        case IgnoreLanguagesWrongSkippedReleasedCenter: {
            [container.centerYAnchor constraintEqualToAnchor:self.centerYAnchor].active = YES;
            break;
        }
        case SmileVisitBeaconSexualGreatNet: {
            [container.bottomAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.bottomAnchor
                                                  constant:-30].active = YES;
            break;
        }
    }
    
    
    [container.centerXAnchor constraintEqualToAnchor:self.centerXAnchor].active = YES;
}


+ (void)streetReplaceBlackChecksumDegradedSlovenianColor:(UIColor *)color {
    bandCreditCautionColoredWeekColor = color;
}

+ (void)trackLeapBoostColor:(UIColor *)color {
    futureNoticeColor = color;
}

+ (void)openPinRateTap:(UIFont *)font {
    outBadModern = font;
}

+ (void)outResourceCopticNotifiedViolationRadius:(CGFloat)radius {
    addPinFlagSnowRadius = radius;
}


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

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

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

- (void)dealloc {
    
}

@end
