






#import "WristInferView.h"
#import "SockLevelManager.h"
#import "WetDoneFill.h"
#import "Masonry.h"

@interface WristInferView ()

@property (nonatomic, strong) UIView *dryCelticHueBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *validatesAboutIndentLogicalRoll;
@property (nonatomic, strong) UILabel *lettishLabel;
@end

@implementation WristInferView


static WristInferView *topOutIdleGetView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self shakeView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self shakeView];
    }
    return self;
}
- (void)shakeView {
    
    
    self.dryCelticHueBackgroundView = [UIView new];
    self.dryCelticHueBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.dryCelticHueBackgroundView.layer.cornerRadius = 2.0;
    self.dryCelticHueBackgroundView.clipsToBounds = YES;
    [self addSubview:self.dryCelticHueBackgroundView];
    
    
    self.validatesAboutIndentLogicalRoll = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.validatesAboutIndentLogicalRoll.color = WetDoneFill.scrollHasColor;
    [self.dryCelticHueBackgroundView addSubview:self.validatesAboutIndentLogicalRoll];
    
    
    self.lettishLabel = [[UILabel alloc] init];
    self.lettishLabel.text = WetDoneFill.wideHostLooper.allMenInvite;
    self.lettishLabel.textColor = [UIColor whiteColor];
    self.lettishLabel.font = [UIFont systemFontOfSize:14];
    self.lettishLabel.numberOfLines = 0;
    self.lettishLabel.textAlignment = NSTextAlignmentCenter;
    [self.dryCelticHueBackgroundView addSubview:self.lettishLabel];
    
    
    [self.dryCelticHueBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(WetDoneFill.artSensitive.popCarBendLaw, WetDoneFill.artSensitive.popCarBendLaw));
        make.center.equalTo(self);
    }];
    
    [self.validatesAboutIndentLogicalRoll mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(WetDoneFill.artSensitive.friendOldCan);
        make.centerX.equalTo(self.dryCelticHueBackgroundView.mas_centerX);
    }];
    
    [self.lettishLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.validatesAboutIndentLogicalRoll.mas_bottom).offset(WetDoneFill.artSensitive.friendOldCan);
        make.centerX.equalTo(self.dryCelticHueBackgroundView.mas_centerX);
        make.left.equalTo(self.dryCelticHueBackgroundView.mas_left).offset(WetDoneFill.artSensitive.nativeFetch);
        make.right.equalTo(self.dryCelticHueBackgroundView.mas_right).offset(-WetDoneFill.artSensitive.nativeFetch);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)areaFarMidText:(NSString *)text {
    self.lettishLabel.text = text;
    
    
    CGFloat planWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.lettishLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[SockLevelManager shared] pageEightEndWindow];
    CGFloat pipeSubWidth = MIN(MAX(120, planWidth + 2 * 8), window.bounds.size.width);
    [self.dryCelticHueBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(pipeSubWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)willNapAndTheWindow {
    [self stayWonMirroringRandomClearProductText:WetDoneFill.wideHostLooper.allMenInvite];
}

+ (void)stayWonMirroringRandomClearProductText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[SockLevelManager shared] pageEightEndWindow];
        
        if (!topOutIdleGetView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            topOutIdleGetView = [[WristInferView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            topOutIdleGetView.center = window.center;
        }
        if (!topOutIdleGetView.superview) {
            [window addSubview:topOutIdleGetView];
        }
        [topOutIdleGetView areaFarMidText:text];
        [topOutIdleGetView startAnimating];
    });
}

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


+ (WristInferView *)didBinTransitView:(UIView *)view {
    return [self didBinTransitView:view withText:WetDoneFill.wideHostLooper.allMenInvite];
}

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

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

@end
