






#import "YouMetricsView.h"
#import "UploadWhoManager.h"
#import "InvertPinch.h"
#import "Masonry.h"

@interface YouMetricsView ()

@property (nonatomic, strong) UIView *lossySwapEggBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *forwardsProjectsManRequestedDebugging;
@property (nonatomic, strong) UILabel *jobRopeLabel;
@end

@implementation YouMetricsView


static YouMetricsView *sectionsReadyView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self modalView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self modalView];
    }
    return self;
}
- (void)modalView {
    
    
    self.lossySwapEggBackgroundView = [UIView new];
    self.lossySwapEggBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.lossySwapEggBackgroundView.layer.cornerRadius = 2.0;
    self.lossySwapEggBackgroundView.clipsToBounds = YES;
    [self addSubview:self.lossySwapEggBackgroundView];
    
    
    self.forwardsProjectsManRequestedDebugging = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.forwardsProjectsManRequestedDebugging.color = InvertPinch.indicatedColor;
    [self.lossySwapEggBackgroundView addSubview:self.forwardsProjectsManRequestedDebugging];
    
    
    self.jobRopeLabel = [[UILabel alloc] init];
    self.jobRopeLabel.text = InvertPinch.knowSunTalkHas.spaHelperCat;
    self.jobRopeLabel.textColor = [UIColor whiteColor];
    self.jobRopeLabel.font = [UIFont systemFontOfSize:14];
    self.jobRopeLabel.numberOfLines = 0;
    self.jobRopeLabel.textAlignment = NSTextAlignmentCenter;
    [self.lossySwapEggBackgroundView addSubview:self.jobRopeLabel];
    
    
    [self.lossySwapEggBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(InvertPinch.didThousands.airSayMarquee, InvertPinch.didThousands.airSayMarquee));
        make.center.equalTo(self);
    }];
    
    [self.forwardsProjectsManRequestedDebugging mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(InvertPinch.didThousands.penDiacritic);
        make.centerX.equalTo(self.lossySwapEggBackgroundView.mas_centerX);
    }];
    
    [self.jobRopeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.forwardsProjectsManRequestedDebugging.mas_bottom).offset(InvertPinch.didThousands.penDiacritic);
        make.centerX.equalTo(self.lossySwapEggBackgroundView.mas_centerX);
        make.left.equalTo(self.lossySwapEggBackgroundView.mas_left).offset(InvertPinch.didThousands.repairPower);
        make.right.equalTo(self.lossySwapEggBackgroundView.mas_right).offset(-InvertPinch.didThousands.repairPower);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)notBlockerText:(NSString *)text {
    self.jobRopeLabel.text = text;
    
    
    CGFloat pullWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.jobRopeLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[UploadWhoManager shared] roomSystolicWindow];
    CGFloat compileWidth = MIN(MAX(120, pullWidth + 2 * 8), window.bounds.size.width);
    [self.lossySwapEggBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(compileWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)smartNotPieceWindow {
    [self cocoaPlanarOceanLeastSuccessCollisionText:InvertPinch.knowSunTalkHas.spaHelperCat];
}

+ (void)cocoaPlanarOceanLeastSuccessCollisionText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[UploadWhoManager shared] roomSystolicWindow];
        
        if (!sectionsReadyView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            sectionsReadyView = [[YouMetricsView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            sectionsReadyView.center = window.center;
        }
        if (!sectionsReadyView.superview) {
            [window addSubview:sectionsReadyView];
        }
        [sectionsReadyView notBlockerText:text];
        [sectionsReadyView startAnimating];
    });
}

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


+ (YouMetricsView *)axialThirteenView:(UIView *)view {
    return [self axialThirteenView:view withText:InvertPinch.knowSunTalkHas.spaHelperCat];
}

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

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

@end
