






#import "ContainWinView.h"
#import "OutDemandManager.h"
#import "SkinEchoMen.h"
#import "Masonry.h"

@interface ContainWinView ()

@property (nonatomic, strong) UIView *coloredBlendBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *lockManVerticalProxiesLoop;
@property (nonatomic, strong) UILabel *corruptLabel;
@end

@implementation ContainWinView


static ContainWinView *logCubeDogBoxView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self queueView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self queueView];
    }
    return self;
}
- (void)queueView {
    
    
    self.coloredBlendBackgroundView = [UIView new];
    self.coloredBlendBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.coloredBlendBackgroundView.layer.cornerRadius = SkinEchoMen.pauseKirghiz.downBinVital;
    self.coloredBlendBackgroundView.clipsToBounds = YES;
    [self addSubview:self.coloredBlendBackgroundView];
    
    
    self.lockManVerticalProxiesLoop = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.lockManVerticalProxiesLoop.color = SkinEchoMen.panoramasColor;
    [self.coloredBlendBackgroundView addSubview:self.lockManVerticalProxiesLoop];
    
    
    self.corruptLabel = [[UILabel alloc] init];
    self.corruptLabel.text = SkinEchoMen.cubePrimeToken.menAgentBest;
    self.corruptLabel.textColor = [UIColor whiteColor];
    self.corruptLabel.font = [UIFont systemFontOfSize:14];
    self.corruptLabel.numberOfLines = 0;
    self.corruptLabel.textAlignment = NSTextAlignmentCenter;
    [self.coloredBlendBackgroundView addSubview:self.corruptLabel];
    
    
    [self.coloredBlendBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(SkinEchoMen.pauseKirghiz.retNowNearest, SkinEchoMen.pauseKirghiz.retNowNearest));
        make.center.equalTo(self);
    }];
    
    [self.lockManVerticalProxiesLoop mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(SkinEchoMen.pauseKirghiz.downBinVital);
        make.centerX.equalTo(self.coloredBlendBackgroundView.mas_centerX);
    }];
    
    [self.corruptLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.lockManVerticalProxiesLoop.mas_bottom).offset(SkinEchoMen.pauseKirghiz.downBinVital);
        make.centerX.equalTo(self.coloredBlendBackgroundView.mas_centerX);
        make.left.equalTo(self.coloredBlendBackgroundView.mas_left).offset(SkinEchoMen.pauseKirghiz.thickArtery);
        make.right.equalTo(self.coloredBlendBackgroundView.mas_right).offset(-SkinEchoMen.pauseKirghiz.thickArtery);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)logIdleLogText:(NSString *)text {
    self.corruptLabel.text = text;
    
    
    CGFloat rearWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.corruptLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[OutDemandManager shared] headlineSentWindow];
    CGFloat pinkCupWidth = MIN(MAX(120, rearWidth + 2 * 8), window.bounds.size.width);
    [self.coloredBlendBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(pinkCupWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)ourLawRemovesWindow {
    [self talkMixEngineerProtectedAllergyHashText:SkinEchoMen.cubePrimeToken.menAgentBest];
}

+ (void)talkMixEngineerProtectedAllergyHashText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[OutDemandManager shared] headlineSentWindow];
        
        if (!logCubeDogBoxView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            logCubeDogBoxView = [[ContainWinView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            logCubeDogBoxView.center = window.center;
        }
        if (!logCubeDogBoxView.superview) {
            [window addSubview:logCubeDogBoxView];
        }
        [logCubeDogBoxView logIdleLogText:text];
        [logCubeDogBoxView startAnimating];
    });
}

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


+ (ContainWinView *)mildRankChinaView:(UIView *)view {
    return [self mildRankChinaView:view withText:SkinEchoMen.cubePrimeToken.menAgentBest];
}

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

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

@end
