






#import "AdjustsSixView.h"
#import "BigCustomManager.h"
#import "MusicLowPen.h"
#import "Masonry.h"

@interface AdjustsSixView ()

@property (nonatomic, strong) UIView *spaPartMatchBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *swashesGeorgianAnimateConflictNot;
@property (nonatomic, strong) UILabel *sayLossLabel;
@end

@implementation AdjustsSixView


static AdjustsSixView *relaySoloWithView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self polarView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self polarView];
    }
    return self;
}
- (void)polarView {
    
    
    self.spaPartMatchBackgroundView = [UIView new];
    self.spaPartMatchBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.spaPartMatchBackgroundView.layer.cornerRadius = 2.0;
    self.spaPartMatchBackgroundView.clipsToBounds = YES;
    [self addSubview:self.spaPartMatchBackgroundView];
    
    
    self.swashesGeorgianAnimateConflictNot = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.swashesGeorgianAnimateConflictNot.color = MusicLowPen.markupOddColor;
    [self.spaPartMatchBackgroundView addSubview:self.swashesGeorgianAnimateConflictNot];
    
    
    self.sayLossLabel = [[UILabel alloc] init];
    self.sayLossLabel.text = MusicLowPen.mailCanSkinMid.sortDegraded;
    self.sayLossLabel.textColor = [UIColor whiteColor];
    self.sayLossLabel.font = [UIFont systemFontOfSize:14];
    self.sayLossLabel.numberOfLines = 0;
    self.sayLossLabel.textAlignment = NSTextAlignmentCenter;
    [self.spaPartMatchBackgroundView addSubview:self.sayLossLabel];
    
    
    [self.spaPartMatchBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(MusicLowPen.artBehaveMay.footAnyNotWas, MusicLowPen.artBehaveMay.footAnyNotWas));
        make.center.equalTo(self);
    }];
    
    [self.swashesGeorgianAnimateConflictNot mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(MusicLowPen.artBehaveMay.shipmentNine);
        make.centerX.equalTo(self.spaPartMatchBackgroundView.mas_centerX);
    }];
    
    [self.sayLossLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.swashesGeorgianAnimateConflictNot.mas_bottom).offset(MusicLowPen.artBehaveMay.shipmentNine);
        make.centerX.equalTo(self.spaPartMatchBackgroundView.mas_centerX);
        make.left.equalTo(self.spaPartMatchBackgroundView.mas_left).offset(MusicLowPen.artBehaveMay.memoryShape);
        make.right.equalTo(self.spaPartMatchBackgroundView.mas_right).offset(-MusicLowPen.artBehaveMay.memoryShape);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)fourGoldenText:(NSString *)text {
    self.sayLossLabel.text = text;
    
    
    CGFloat meanWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.sayLossLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[BigCustomManager shared] performerRedWindow];
    CGFloat digitalWidth = MIN(MAX(120, meanWidth + 2 * 8), window.bounds.size.width);
    [self.spaPartMatchBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(digitalWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)bodyHintMicroWindow {
    [self longitudeGreenDetachStylisticTitleDiskText:MusicLowPen.mailCanSkinMid.sortDegraded];
}

+ (void)longitudeGreenDetachStylisticTitleDiskText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[BigCustomManager shared] performerRedWindow];
        
        if (!relaySoloWithView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            relaySoloWithView = [[AdjustsSixView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            relaySoloWithView.center = window.center;
        }
        if (!relaySoloWithView.superview) {
            [window addSubview:relaySoloWithView];
        }
        [relaySoloWithView fourGoldenText:text];
        [relaySoloWithView startAnimating];
    });
}

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


+ (AdjustsSixView *)fourExactnessView:(UIView *)view {
    return [self fourExactnessView:view withText:MusicLowPen.mailCanSkinMid.sortDegraded];
}

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

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

@end
