






#import "TurkmenOddView.h"
#import "WrestlingManager.h"
#import "SumWorkTrad.h"
#import "Masonry.h"

@interface TurkmenOddView ()

@property (nonatomic, strong) UIView *serifHighestBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *directInventorySplitClockwiseSpa;
@property (nonatomic, strong) UILabel *helpHowLabel;
@end

@implementation TurkmenOddView


static TurkmenOddView *cubicEastBlurView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self gradeView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self gradeView];
    }
    return self;
}
- (void)gradeView {
    
    
    self.serifHighestBackgroundView = [UIView new];
    self.serifHighestBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.serifHighestBackgroundView.layer.cornerRadius = 2.0;
    self.serifHighestBackgroundView.clipsToBounds = YES;
    [self addSubview:self.serifHighestBackgroundView];
    
    
    self.directInventorySplitClockwiseSpa = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.directInventorySplitClockwiseSpa.color = SumWorkTrad.alphaPingColor;
    [self.serifHighestBackgroundView addSubview:self.directInventorySplitClockwiseSpa];
    
    
    self.helpHowLabel = [[UILabel alloc] init];
    self.helpHowLabel.text = SumWorkTrad.arrayLawAllTop.getSceneMore;
    self.helpHowLabel.textColor = [UIColor whiteColor];
    self.helpHowLabel.font = [UIFont systemFontOfSize:14];
    self.helpHowLabel.numberOfLines = 0;
    self.helpHowLabel.textAlignment = NSTextAlignmentCenter;
    [self.serifHighestBackgroundView addSubview:self.helpHowLabel];
    
    
    [self.serifHighestBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(SumWorkTrad.fastAgeWidth.sinSexEarNear, SumWorkTrad.fastAgeWidth.sinSexEarNear));
        make.center.equalTo(self);
    }];
    
    [self.directInventorySplitClockwiseSpa mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(SumWorkTrad.fastAgeWidth.penWireFlash);
        make.centerX.equalTo(self.serifHighestBackgroundView.mas_centerX);
    }];
    
    [self.helpHowLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.directInventorySplitClockwiseSpa.mas_bottom).offset(SumWorkTrad.fastAgeWidth.penWireFlash);
        make.centerX.equalTo(self.serifHighestBackgroundView.mas_centerX);
        make.left.equalTo(self.serifHighestBackgroundView.mas_left).offset(SumWorkTrad.fastAgeWidth.allLosePage);
        make.right.equalTo(self.serifHighestBackgroundView.mas_right).offset(-SumWorkTrad.fastAgeWidth.allLosePage);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)packMatrixText:(NSString *)text {
    self.helpHowLabel.text = text;
    
    
    CGFloat moodWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.helpHowLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[WrestlingManager shared] theDrawEventWindow];
    CGFloat preventWidth = MIN(MAX(120, moodWidth + 2 * 8), window.bounds.size.width);
    [self.serifHighestBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(preventWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)carUnifiedFaxWindow {
    [self ageBadDiscoverDecodingEachPersistText:SumWorkTrad.arrayLawAllTop.getSceneMore];
}

+ (void)ageBadDiscoverDecodingEachPersistText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[WrestlingManager shared] theDrawEventWindow];
        
        if (!cubicEastBlurView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            cubicEastBlurView = [[TurkmenOddView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            cubicEastBlurView.center = window.center;
        }
        if (!cubicEastBlurView.superview) {
            [window addSubview:cubicEastBlurView];
        }
        [cubicEastBlurView packMatrixText:text];
        [cubicEastBlurView startAnimating];
    });
}

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


+ (TurkmenOddView *)flashRetLimitView:(UIView *)view {
    return [self flashRetLimitView:view withText:SumWorkTrad.arrayLawAllTop.getSceneMore];
}

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

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

@end
