






#import "FireResizeView.h"
#import "WeekStripManager.h"
#import "PrintFarFor.h"
#import "Masonry.h"

@interface FireResizeView ()

@property (nonatomic, strong) UIView *manLegacyMenBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *weightedShelfRenewingBankersPasswords;
@property (nonatomic, strong) UILabel *seeUsedLabel;
@end

@implementation FireResizeView


static FireResizeView *coverWarnMailView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self mouthView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self mouthView];
    }
    return self;
}
- (void)mouthView {
    
    
    self.manLegacyMenBackgroundView = [UIView new];
    self.manLegacyMenBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.manLegacyMenBackgroundView.layer.cornerRadius = PrintFarFor.guideMaySelf.boxAbovePast;
    self.manLegacyMenBackgroundView.clipsToBounds = YES;
    [self addSubview:self.manLegacyMenBackgroundView];
    
    
    self.weightedShelfRenewingBankersPasswords = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.weightedShelfRenewingBankersPasswords.color = PrintFarFor.expansionColor;
    [self.manLegacyMenBackgroundView addSubview:self.weightedShelfRenewingBankersPasswords];
    
    
    self.seeUsedLabel = [[UILabel alloc] init];
    self.seeUsedLabel.text = PrintFarFor.tempSockJobHas.icyTolerance;
    self.seeUsedLabel.textColor = [UIColor whiteColor];
    self.seeUsedLabel.font = [UIFont systemFontOfSize:14];
    self.seeUsedLabel.numberOfLines = 0;
    self.seeUsedLabel.textAlignment = NSTextAlignmentCenter;
    [self.manLegacyMenBackgroundView addSubview:self.seeUsedLabel];
    
    
    [self.manLegacyMenBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(PrintFarFor.guideMaySelf.draftChecking, PrintFarFor.guideMaySelf.draftChecking));
        make.center.equalTo(self);
    }];
    
    [self.weightedShelfRenewingBankersPasswords mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(PrintFarFor.guideMaySelf.boxAbovePast);
        make.centerX.equalTo(self.manLegacyMenBackgroundView.mas_centerX);
    }];
    
    [self.seeUsedLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.weightedShelfRenewingBankersPasswords.mas_bottom).offset(PrintFarFor.guideMaySelf.boxAbovePast);
        make.centerX.equalTo(self.manLegacyMenBackgroundView.mas_centerX);
        make.left.equalTo(self.manLegacyMenBackgroundView.mas_left).offset(PrintFarFor.guideMaySelf.splatButPen);
        make.right.equalTo(self.manLegacyMenBackgroundView.mas_right).offset(-PrintFarFor.guideMaySelf.splatButPen);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)rawPercentText:(NSString *)text {
    self.seeUsedLabel.text = text;
    
    
    CGFloat modeWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.seeUsedLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[WeekStripManager shared] swipePenSideWindow];
    CGFloat wordSinWidth = MIN(MAX(120, modeWidth + 2 * 8), window.bounds.size.width);
    [self.manLegacyMenBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(wordSinWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)brushLabelCutWindow {
    [self hardKeyKeyboardBadmintonRemainderPenText:PrintFarFor.tempSockJobHas.icyTolerance];
}

+ (void)hardKeyKeyboardBadmintonRemainderPenText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[WeekStripManager shared] swipePenSideWindow];
        
        if (!coverWarnMailView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            coverWarnMailView = [[FireResizeView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            coverWarnMailView.center = window.center;
        }
        if (!coverWarnMailView.superview) {
            [window addSubview:coverWarnMailView];
        }
        [coverWarnMailView rawPercentText:text];
        [coverWarnMailView startAnimating];
    });
}

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


+ (FireResizeView *)marathiLinearView:(UIView *)view {
    return [self marathiLinearView:view withText:PrintFarFor.tempSockJobHas.icyTolerance];
}

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

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

@end
