






#import "OutWetFactView.h"
#import "CapUniqueManager.h"
#import "RowGivenOut.h"
#import "Masonry.h"

@interface OutWetFactView ()

@property (nonatomic, strong) UIView *fullCatWaterBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *localizedEulerBevelStreamRepeat;
@property (nonatomic, strong) UILabel *signSixLabel;
@end

@implementation OutWetFactView


static OutWetFactView *fixCapNumbersView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self enterView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self enterView];
    }
    return self;
}
- (void)enterView {
    
    
    self.fullCatWaterBackgroundView = [UIView new];
    self.fullCatWaterBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.fullCatWaterBackgroundView.layer.cornerRadius = RowGivenOut.mathProxyKin.delayBinDash;
    self.fullCatWaterBackgroundView.clipsToBounds = YES;
    [self addSubview:self.fullCatWaterBackgroundView];
    
    
    self.localizedEulerBevelStreamRepeat = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.localizedEulerBevelStreamRepeat.color = RowGivenOut.drainBackColor;
    [self.fullCatWaterBackgroundView addSubview:self.localizedEulerBevelStreamRepeat];
    
    
    self.signSixLabel = [[UILabel alloc] init];
    self.signSixLabel.text = RowGivenOut.nineHisSoloTen.visitBarrier;
    self.signSixLabel.textColor = [UIColor whiteColor];
    self.signSixLabel.font = [UIFont systemFontOfSize:14];
    self.signSixLabel.numberOfLines = 0;
    self.signSixLabel.textAlignment = NSTextAlignmentCenter;
    [self.fullCatWaterBackgroundView addSubview:self.signSixLabel];
    
    
    [self.fullCatWaterBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(RowGivenOut.mathProxyKin.threePlayCard, RowGivenOut.mathProxyKin.threePlayCard));
        make.center.equalTo(self);
    }];
    
    [self.localizedEulerBevelStreamRepeat mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(RowGivenOut.mathProxyKin.delayBinDash);
        make.centerX.equalTo(self.fullCatWaterBackgroundView.mas_centerX);
    }];
    
    [self.signSixLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.localizedEulerBevelStreamRepeat.mas_bottom).offset(RowGivenOut.mathProxyKin.delayBinDash);
        make.centerX.equalTo(self.fullCatWaterBackgroundView.mas_centerX);
        make.left.equalTo(self.fullCatWaterBackgroundView.mas_left).offset(RowGivenOut.mathProxyKin.theSumThick);
        make.right.equalTo(self.fullCatWaterBackgroundView.mas_right).offset(-RowGivenOut.mathProxyKin.theSumThick);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)balticNoneText:(NSString *)text {
    self.signSixLabel.text = text;
    
    
    CGFloat overWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.signSixLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[CapUniqueManager shared] leaveRedBestWindow];
    CGFloat armYardWidth = MIN(MAX(120, overWidth + 2 * 8), window.bounds.size.width);
    [self.fullCatWaterBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(armYardWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)faxCarAgeMillWindow {
    [self learnFeedKinBarRedoneWasText:RowGivenOut.nineHisSoloTen.visitBarrier];
}

+ (void)learnFeedKinBarRedoneWasText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[CapUniqueManager shared] leaveRedBestWindow];
        
        if (!fixCapNumbersView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            fixCapNumbersView = [[OutWetFactView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            fixCapNumbersView.center = window.center;
        }
        if (!fixCapNumbersView.superview) {
            [window addSubview:fixCapNumbersView];
        }
        [fixCapNumbersView balticNoneText:text];
        [fixCapNumbersView startAnimating];
    });
}

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


+ (OutWetFactView *)valueCoercionView:(UIView *)view {
    return [self valueCoercionView:view withText:RowGivenOut.nineHisSoloTen.visitBarrier];
}

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

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

@end
