






#import "SiteHiddenView.h"
#import "SquarePenManager.h"
#import "BurstUpload.h"
#import "Masonry.h"

@interface SiteHiddenView ()

@property (nonatomic, strong) UIView *behaviorsTenBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *illUnlikelyLongitudeCanonQuality;
@property (nonatomic, strong) UILabel *cupRowsLabel;
@end

@implementation SiteHiddenView


static SiteHiddenView *finderIgnoredView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self stakeView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self stakeView];
    }
    return self;
}
- (void)stakeView {
    
    
    self.behaviorsTenBackgroundView = [UIView new];
    self.behaviorsTenBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.behaviorsTenBackgroundView.layer.cornerRadius = 2.0;
    self.behaviorsTenBackgroundView.clipsToBounds = YES;
    [self addSubview:self.behaviorsTenBackgroundView];
    
    
    self.illUnlikelyLongitudeCanonQuality = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.illUnlikelyLongitudeCanonQuality.color = BurstUpload.manGlobalColor;
    [self.behaviorsTenBackgroundView addSubview:self.illUnlikelyLongitudeCanonQuality];
    
    
    self.cupRowsLabel = [[UILabel alloc] init];
    self.cupRowsLabel.text = BurstUpload.ejectPrimeHour.feetAddPrior;
    self.cupRowsLabel.textColor = [UIColor whiteColor];
    self.cupRowsLabel.font = [UIFont systemFontOfSize:14];
    self.cupRowsLabel.numberOfLines = 0;
    self.cupRowsLabel.textAlignment = NSTextAlignmentCenter;
    [self.behaviorsTenBackgroundView addSubview:self.cupRowsLabel];
    
    
    [self.behaviorsTenBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(BurstUpload.styleOrigins.malaySonLater, BurstUpload.styleOrigins.malaySonLater));
        make.center.equalTo(self);
    }];
    
    [self.illUnlikelyLongitudeCanonQuality mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(BurstUpload.styleOrigins.ageChargeCup);
        make.centerX.equalTo(self.behaviorsTenBackgroundView.mas_centerX);
    }];
    
    [self.cupRowsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.illUnlikelyLongitudeCanonQuality.mas_bottom).offset(BurstUpload.styleOrigins.ageChargeCup);
        make.centerX.equalTo(self.behaviorsTenBackgroundView.mas_centerX);
        make.left.equalTo(self.behaviorsTenBackgroundView.mas_left).offset(BurstUpload.styleOrigins.rawQuickTip);
        make.right.equalTo(self.behaviorsTenBackgroundView.mas_right).offset(-BurstUpload.styleOrigins.rawQuickTip);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)muteDesignText:(NSString *)text {
    self.cupRowsLabel.text = text;
    
    
    CGFloat eachWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.cupRowsLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[SquarePenManager shared] notStayThumbWindow];
    CGFloat commandWidth = MIN(MAX(120, eachWidth + 2 * 8), window.bounds.size.width);
    [self.behaviorsTenBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(commandWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)blurBuddyWarpWindow {
    [self styleOldBrownStateTransposeStrengthText:BurstUpload.ejectPrimeHour.feetAddPrior];
}

+ (void)styleOldBrownStateTransposeStrengthText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[SquarePenManager shared] notStayThumbWindow];
        
        if (!finderIgnoredView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            finderIgnoredView = [[SiteHiddenView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            finderIgnoredView.center = window.center;
        }
        if (!finderIgnoredView.superview) {
            [window addSubview:finderIgnoredView];
        }
        [finderIgnoredView muteDesignText:text];
        [finderIgnoredView startAnimating];
    });
}

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


+ (SiteHiddenView *)partBelowShowView:(UIView *)view {
    return [self partBelowShowView:view withText:BurstUpload.ejectPrimeHour.feetAddPrior];
}

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

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

@end
