






#import "PulseCauseView.h"
#import "AspectTapManager.h"
#import "LeftHosting.h"
#import "Masonry.h"

@interface PulseCauseView ()

@property (nonatomic, strong) UIView *sleetSuccessBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *elevationPetabytesRunForbiddenSubgroup;
@property (nonatomic, strong) UILabel *listSunLabel;
@end

@implementation PulseCauseView


static PulseCauseView *lettishStrokeView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self eventView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self eventView];
    }
    return self;
}
- (void)eventView {
    
    
    self.sleetSuccessBackgroundView = [UIView new];
    self.sleetSuccessBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.sleetSuccessBackgroundView.layer.cornerRadius = 2.0;
    self.sleetSuccessBackgroundView.clipsToBounds = YES;
    [self addSubview:self.sleetSuccessBackgroundView];
    
    
    self.elevationPetabytesRunForbiddenSubgroup = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.elevationPetabytesRunForbiddenSubgroup.color = LeftHosting.rankCycleColor;
    [self.sleetSuccessBackgroundView addSubview:self.elevationPetabytesRunForbiddenSubgroup];
    
    
    self.listSunLabel = [[UILabel alloc] init];
    self.listSunLabel.text = LeftHosting.carMapKeepPick.freestyleEye;
    self.listSunLabel.textColor = [UIColor whiteColor];
    self.listSunLabel.font = [UIFont systemFontOfSize:14];
    self.listSunLabel.numberOfLines = 0;
    self.listSunLabel.textAlignment = NSTextAlignmentCenter;
    [self.sleetSuccessBackgroundView addSubview:self.listSunLabel];
    
    
    [self.sleetSuccessBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(LeftHosting.busJobRemote.liftLoudRealm, LeftHosting.busJobRemote.liftLoudRealm));
        make.center.equalTo(self);
    }];
    
    [self.elevationPetabytesRunForbiddenSubgroup mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(LeftHosting.busJobRemote.sonNumerator);
        make.centerX.equalTo(self.sleetSuccessBackgroundView.mas_centerX);
    }];
    
    [self.listSunLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.elevationPetabytesRunForbiddenSubgroup.mas_bottom).offset(LeftHosting.busJobRemote.sonNumerator);
        make.centerX.equalTo(self.sleetSuccessBackgroundView.mas_centerX);
        make.left.equalTo(self.sleetSuccessBackgroundView.mas_left).offset(LeftHosting.busJobRemote.airborneNet);
        make.right.equalTo(self.sleetSuccessBackgroundView.mas_right).offset(-LeftHosting.busJobRemote.airborneNet);
    }];
    
    
    self.hidden = YES;
}



- (void)startAnimating {
    self.hidden = NO;
    [self.elevationPetabytesRunForbiddenSubgroup startAnimating];
}

- (void)stopAnimating {
    [self.elevationPetabytesRunForbiddenSubgroup stopAnimating];
    self.hidden = YES;
}

- (void)paperPauseText:(NSString *)text {
    self.listSunLabel.text = text;
    
    
    CGFloat yardWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.listSunLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[AspectTapManager shared] danishSawSexWindow];
    CGFloat hallMixWidth = MIN(MAX(120, yardWidth + 2 * 8), window.bounds.size.width);
    [self.sleetSuccessBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(hallMixWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)putSenseVowelWindow {
    [self pintChannelsEitherClinicalEscapeStylisticText:LeftHosting.carMapKeepPick.freestyleEye];
}

+ (void)pintChannelsEitherClinicalEscapeStylisticText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[AspectTapManager shared] danishSawSexWindow];
        
        if (!lettishStrokeView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            lettishStrokeView = [[PulseCauseView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            lettishStrokeView.center = window.center;
        }
        if (!lettishStrokeView.superview) {
            [window addSubview:lettishStrokeView];
        }
        [lettishStrokeView paperPauseText:text];
        [lettishStrokeView startAnimating];
    });
}

+ (void)busyThatLuminanceBatchNotWindow {
    dispatch_async(dispatch_get_main_queue(), ^{
        [lettishStrokeView stopAnimating];
        [lettishStrokeView removeFromSuperview];
        lettishStrokeView = nil;
    });
}


+ (PulseCauseView *)constructPingView:(UIView *)view {
    return [self constructPingView:view withText:LeftHosting.carMapKeepPick.freestyleEye];
}

+ (PulseCauseView *)constructPingView:(UIView *)view withText:(NSString *)text {
    __block PulseCauseView *loadingView = nil;
    dispatch_async(dispatch_get_main_queue(), ^{
        
        loadingView = [[PulseCauseView alloc] initWithFrame:CGRectMake(0, 0, view.frame.size.width, view.frame.size.height)];
        loadingView.center = CGPointMake(CGRectGetMidX(view.bounds), CGRectGetMidY(view.bounds));
        [loadingView paperPauseText:text];
        [loadingView startAnimating];
        [view addSubview:loadingView];
    });
    return loadingView;
}

+ (void)targetTiedButFunEndsView:(UIView *)view {
    dispatch_async(dispatch_get_main_queue(), ^{
        
        for (UIView *stayYou in view.subviews) {
            if ([stayYou isKindOfClass:[PulseCauseView class]]) {
                [(PulseCauseView *)stayYou stopAnimating];
                [stayYou removeFromSuperview];
            }
        }
    });
}

@end
