






#import "LinkArmBadView.h"
#import "HelloFormManager.h"
#import "PartialBest.h"
#import "Masonry.h"

@interface LinkArmBadView ()

@property (nonatomic, strong) UIView *proxyDeepTheBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *afterLatvianSockCloudStride;
@property (nonatomic, strong) UILabel *hintSpaLabel;
@end

@implementation LinkArmBadView


static LinkArmBadView *hitGrowHitTheView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self learnView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self learnView];
    }
    return self;
}
- (void)learnView {
    
    
    self.proxyDeepTheBackgroundView = [UIView new];
    self.proxyDeepTheBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.proxyDeepTheBackgroundView.layer.cornerRadius = PartialBest.mouseEarlier.barSceneEasy;
    self.proxyDeepTheBackgroundView.clipsToBounds = YES;
    [self addSubview:self.proxyDeepTheBackgroundView];
    
    
    self.afterLatvianSockCloudStride = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.afterLatvianSockCloudStride.color = PartialBest.turnOtherColor;
    [self.proxyDeepTheBackgroundView addSubview:self.afterLatvianSockCloudStride];
    
    
    self.hintSpaLabel = [[UILabel alloc] init];
    self.hintSpaLabel.text = PartialBest.itsOneFlowEasy.resizeUpdate;
    self.hintSpaLabel.textColor = [UIColor whiteColor];
    self.hintSpaLabel.font = [UIFont systemFontOfSize:14];
    self.hintSpaLabel.numberOfLines = 0;
    self.hintSpaLabel.textAlignment = NSTextAlignmentCenter;
    [self.proxyDeepTheBackgroundView addSubview:self.hintSpaLabel];
    
    
    [self.proxyDeepTheBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(PartialBest.mouseEarlier.threeMenCubic, PartialBest.mouseEarlier.threeMenCubic));
        make.center.equalTo(self);
    }];
    
    [self.afterLatvianSockCloudStride mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(PartialBest.mouseEarlier.barSceneEasy);
        make.centerX.equalTo(self.proxyDeepTheBackgroundView.mas_centerX);
    }];
    
    [self.hintSpaLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.afterLatvianSockCloudStride.mas_bottom).offset(PartialBest.mouseEarlier.barSceneEasy);
        make.centerX.equalTo(self.proxyDeepTheBackgroundView.mas_centerX);
        make.left.equalTo(self.proxyDeepTheBackgroundView.mas_left).offset(PartialBest.mouseEarlier.stickyVideo);
        make.right.equalTo(self.proxyDeepTheBackgroundView.mas_right).offset(-PartialBest.mouseEarlier.stickyVideo);
    }];
    
    
    self.hidden = YES;
}



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

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

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


+ (void)computerSmallWindow {
    [self spaEndpointDeviceLockSpeechResumedText:PartialBest.itsOneFlowEasy.resizeUpdate];
}

+ (void)spaEndpointDeviceLockSpeechResumedText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[HelloFormManager shared] winGatheringWindow];
        
        if (!hitGrowHitTheView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            hitGrowHitTheView = [[LinkArmBadView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            hitGrowHitTheView.center = window.center;
        }
        if (!hitGrowHitTheView.superview) {
            [window addSubview:hitGrowHitTheView];
        }
        [hitGrowHitTheView linerFatalText:text];
        [hitGrowHitTheView startAnimating];
    });
}

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


+ (LinkArmBadView *)wayDegreesHowView:(UIView *)view {
    return [self wayDegreesHowView:view withText:PartialBest.itsOneFlowEasy.resizeUpdate];
}

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

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

@end
