






#import "TradFaxAgeView.h"
#import "BitmapWaxManager.h"
#import "MillLiftIll.h"
#import "Masonry.h"

@interface TradFaxAgeView ()

@property (nonatomic, strong) UIView *napRebusBaseBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *spaMaxMatchListenerTied;
@property (nonatomic, strong) UILabel *shotCupLabel;
@end

@implementation TradFaxAgeView


static TradFaxAgeView *validatesLeapView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self trashView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self trashView];
    }
    return self;
}
- (void)trashView {
    
    
    self.napRebusBaseBackgroundView = [UIView new];
    self.napRebusBaseBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.napRebusBaseBackgroundView.layer.cornerRadius = 2.0;
    self.napRebusBaseBackgroundView.clipsToBounds = YES;
    [self addSubview:self.napRebusBaseBackgroundView];
    
    
    self.spaMaxMatchListenerTied = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.spaMaxMatchListenerTied.color = MillLiftIll.shearHeadColor;
    [self.napRebusBaseBackgroundView addSubview:self.spaMaxMatchListenerTied];
    
    
    self.shotCupLabel = [[UILabel alloc] init];
    self.shotCupLabel.text = MillLiftIll.cutHoldDateSix.sixPermitted;
    self.shotCupLabel.textColor = [UIColor whiteColor];
    self.shotCupLabel.font = [UIFont systemFontOfSize:14];
    self.shotCupLabel.numberOfLines = 0;
    self.shotCupLabel.textAlignment = NSTextAlignmentCenter;
    [self.napRebusBaseBackgroundView addSubview:self.shotCupLabel];
    
    
    [self.napRebusBaseBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(MillLiftIll.hintLegalHue.musicFilmFast, MillLiftIll.hintLegalHue.musicFilmFast));
        make.center.equalTo(self);
    }];
    
    [self.spaMaxMatchListenerTied mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(MillLiftIll.hintLegalHue.gatherSexual);
        make.centerX.equalTo(self.napRebusBaseBackgroundView.mas_centerX);
    }];
    
    [self.shotCupLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.spaMaxMatchListenerTied.mas_bottom).offset(MillLiftIll.hintLegalHue.gatherSexual);
        make.centerX.equalTo(self.napRebusBaseBackgroundView.mas_centerX);
        make.left.equalTo(self.napRebusBaseBackgroundView.mas_left).offset(MillLiftIll.hintLegalHue.fixLastPick);
        make.right.equalTo(self.napRebusBaseBackgroundView.mas_right).offset(-MillLiftIll.hintLegalHue.fixLastPick);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)bookEffortText:(NSString *)text {
    self.shotCupLabel.text = text;
    
    
    CGFloat hostWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.shotCupLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[BitmapWaxManager shared] freezingThinWindow];
    CGFloat webpageWidth = MIN(MAX(120, hostWidth + 2 * 8), window.bounds.size.width);
    [self.napRebusBaseBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(webpageWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)partnerArteryWindow {
    [self sceneWaxMenQueryHitWithText:MillLiftIll.cutHoldDateSix.sixPermitted];
}

+ (void)sceneWaxMenQueryHitWithText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[BitmapWaxManager shared] freezingThinWindow];
        
        if (!validatesLeapView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            validatesLeapView = [[TradFaxAgeView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            validatesLeapView.center = window.center;
        }
        if (!validatesLeapView.superview) {
            [window addSubview:validatesLeapView];
        }
        [validatesLeapView bookEffortText:text];
        [validatesLeapView startAnimating];
    });
}

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


+ (TradFaxAgeView *)wetPoolButHexView:(UIView *)view {
    return [self wetPoolButHexView:view withText:MillLiftIll.cutHoldDateSix.sixPermitted];
}

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

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

@end
