






#import "ActualSkipView.h"
#import "MatchMenuManager.h"
#import "UserArtRoot.h"
#import "Masonry.h"

@interface ActualSkipView ()

@property (nonatomic, strong) UIView *capDarkClaimBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *printSquaresCountryDarkImage;
@property (nonatomic, strong) UILabel *elementLabel;
@end

@implementation ActualSkipView


static ActualSkipView *sampleEpsilonView = 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.capDarkClaimBackgroundView = [UIView new];
    self.capDarkClaimBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.capDarkClaimBackgroundView.layer.cornerRadius = 2.0;
    self.capDarkClaimBackgroundView.clipsToBounds = YES;
    [self addSubview:self.capDarkClaimBackgroundView];
    
    
    self.printSquaresCountryDarkImage = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.printSquaresCountryDarkImage.color = UserArtRoot.partBoostColor;
    [self.capDarkClaimBackgroundView addSubview:self.printSquaresCountryDarkImage];
    
    
    self.elementLabel = [[UILabel alloc] init];
    self.elementLabel.text = UserArtRoot.builtOwnSeeEar.twoOrangeDog;
    self.elementLabel.textColor = [UIColor whiteColor];
    self.elementLabel.font = [UIFont systemFontOfSize:14];
    self.elementLabel.numberOfLines = 0;
    self.elementLabel.textAlignment = NSTextAlignmentCenter;
    [self.capDarkClaimBackgroundView addSubview:self.elementLabel];
    
    
    [self.capDarkClaimBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(UserArtRoot.wayAbortLove.conductorDown, UserArtRoot.wayAbortLove.conductorDown));
        make.center.equalTo(self);
    }];
    
    [self.printSquaresCountryDarkImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(UserArtRoot.wayAbortLove.twoBulgarian);
        make.centerX.equalTo(self.capDarkClaimBackgroundView.mas_centerX);
    }];
    
    [self.elementLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.printSquaresCountryDarkImage.mas_bottom).offset(UserArtRoot.wayAbortLove.twoBulgarian);
        make.centerX.equalTo(self.capDarkClaimBackgroundView.mas_centerX);
        make.left.equalTo(self.capDarkClaimBackgroundView.mas_left).offset(UserArtRoot.wayAbortLove.hueSpineKit);
        make.right.equalTo(self.capDarkClaimBackgroundView.mas_right).offset(-UserArtRoot.wayAbortLove.hueSpineKit);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)sameMetricText:(NSString *)text {
    self.elementLabel.text = text;
    
    
    CGFloat bookWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.elementLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[MatchMenuManager shared] teacherDepthWindow];
    CGFloat whoFontWidth = MIN(MAX(120, bookWidth + 2 * 8), window.bounds.size.width);
    [self.capDarkClaimBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(whoFontWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)bondLocalDiskWindow {
    [self shutterPressureSlightCampaignMuteFarsiText:UserArtRoot.builtOwnSeeEar.twoOrangeDog];
}

+ (void)shutterPressureSlightCampaignMuteFarsiText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[MatchMenuManager shared] teacherDepthWindow];
        
        if (!sampleEpsilonView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            sampleEpsilonView = [[ActualSkipView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            sampleEpsilonView.center = window.center;
        }
        if (!sampleEpsilonView.superview) {
            [window addSubview:sampleEpsilonView];
        }
        [sampleEpsilonView sameMetricText:text];
        [sampleEpsilonView startAnimating];
    });
}

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


+ (ActualSkipView *)notWakeOddMaxView:(UIView *)view {
    return [self notWakeOddMaxView:view withText:UserArtRoot.builtOwnSeeEar.twoOrangeDog];
}

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

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

@end
