






#import "ManPenNearView.h"
#import "WeekChainManager.h"
#import "PriorEarSee.h"
#import "Masonry.h"

@interface ManPenNearView ()

@property (nonatomic, strong) UIView *joinSlideTipBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *parameterSphericalDryTalkImportant;
@property (nonatomic, strong) UILabel *muteSeeLabel;
@end

@implementation ManPenNearView


static ManPenNearView *dropMajorSafeView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self splitView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self splitView];
    }
    return self;
}
- (void)splitView {
    
    
    self.joinSlideTipBackgroundView = [UIView new];
    self.joinSlideTipBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.joinSlideTipBackgroundView.layer.cornerRadius = PriorEarSee.netListPhoto.ownChromaToo;
    self.joinSlideTipBackgroundView.clipsToBounds = YES;
    [self addSubview:self.joinSlideTipBackgroundView];
    
    
    self.parameterSphericalDryTalkImportant = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.parameterSphericalDryTalkImportant.color = PriorEarSee.seeKazakhColor;
    [self.joinSlideTipBackgroundView addSubview:self.parameterSphericalDryTalkImportant];
    
    
    self.muteSeeLabel = [[UILabel alloc] init];
    self.muteSeeLabel.text = PriorEarSee.drawCreditLeft.waxManualPan;
    self.muteSeeLabel.textColor = [UIColor whiteColor];
    self.muteSeeLabel.font = [UIFont systemFontOfSize:14];
    self.muteSeeLabel.numberOfLines = 0;
    self.muteSeeLabel.textAlignment = NSTextAlignmentCenter;
    [self.joinSlideTipBackgroundView addSubview:self.muteSeeLabel];
    
    
    [self.joinSlideTipBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(PriorEarSee.netListPhoto.barrierArmpit, PriorEarSee.netListPhoto.barrierArmpit));
        make.center.equalTo(self);
    }];
    
    [self.parameterSphericalDryTalkImportant mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(PriorEarSee.netListPhoto.ownChromaToo);
        make.centerX.equalTo(self.joinSlideTipBackgroundView.mas_centerX);
    }];
    
    [self.muteSeeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.parameterSphericalDryTalkImportant.mas_bottom).offset(PriorEarSee.netListPhoto.ownChromaToo);
        make.centerX.equalTo(self.joinSlideTipBackgroundView.mas_centerX);
        make.left.equalTo(self.joinSlideTipBackgroundView.mas_left).offset(PriorEarSee.netListPhoto.verticalHer);
        make.right.equalTo(self.joinSlideTipBackgroundView.mas_right).offset(-PriorEarSee.netListPhoto.verticalHer);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)hashWonDryText:(NSString *)text {
    self.muteSeeLabel.text = text;
    
    
    CGFloat feetWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.muteSeeLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[WeekChainManager shared] licenseCoastWindow];
    CGFloat hisScanWidth = MIN(MAX(120, feetWidth + 2 * 8), window.bounds.size.width);
    [self.joinSlideTipBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(hisScanWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)airCatHexSignWindow {
    [self roundBackVibrancyDoneExactReloadText:PriorEarSee.drawCreditLeft.waxManualPan];
}

+ (void)roundBackVibrancyDoneExactReloadText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[WeekChainManager shared] licenseCoastWindow];
        
        if (!dropMajorSafeView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            dropMajorSafeView = [[ManPenNearView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            dropMajorSafeView.center = window.center;
        }
        if (!dropMajorSafeView.superview) {
            [window addSubview:dropMajorSafeView];
        }
        [dropMajorSafeView hashWonDryText:text];
        [dropMajorSafeView startAnimating];
    });
}

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


+ (ManPenNearView *)paletteMarginView:(UIView *)view {
    return [self paletteMarginView:view withText:PriorEarSee.drawCreditLeft.waxManualPan];
}

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

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

@end
