






#import "PickMinuteView.h"
#import "AggregateManager.h"
#import "YahooKeyTip.h"
#import "Masonry.h"

@interface PickMinuteView ()

@property (nonatomic, strong) UIView *pongPointRunBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *firstHomepageToleranceFactoredCallbacks;
@property (nonatomic, strong) UILabel *thatWaxLabel;
@end

@implementation PickMinuteView


static PickMinuteView *symbolicMicroView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self pointView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self pointView];
    }
    return self;
}
- (void)pointView {
    
    
    self.pongPointRunBackgroundView = [UIView new];
    self.pongPointRunBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.pongPointRunBackgroundView.layer.cornerRadius = YahooKeyTip.tatarMaximum.ironKinChain;
    self.pongPointRunBackgroundView.clipsToBounds = YES;
    [self addSubview:self.pongPointRunBackgroundView];
    
    
    self.firstHomepageToleranceFactoredCallbacks = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.firstHomepageToleranceFactoredCallbacks.color = YahooKeyTip.expireCanColor;
    [self.pongPointRunBackgroundView addSubview:self.firstHomepageToleranceFactoredCallbacks];
    
    
    self.thatWaxLabel = [[UILabel alloc] init];
    self.thatWaxLabel.text = YahooKeyTip.somaliLoopMove.repeatKinHas;
    self.thatWaxLabel.textColor = [UIColor whiteColor];
    self.thatWaxLabel.font = [UIFont systemFontOfSize:14];
    self.thatWaxLabel.numberOfLines = 0;
    self.thatWaxLabel.textAlignment = NSTextAlignmentCenter;
    [self.pongPointRunBackgroundView addSubview:self.thatWaxLabel];
    
    
    [self.pongPointRunBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(YahooKeyTip.tatarMaximum.askCauseExist, YahooKeyTip.tatarMaximum.askCauseExist));
        make.center.equalTo(self);
    }];
    
    [self.firstHomepageToleranceFactoredCallbacks mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(YahooKeyTip.tatarMaximum.ironKinChain);
        make.centerX.equalTo(self.pongPointRunBackgroundView.mas_centerX);
    }];
    
    [self.thatWaxLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.firstHomepageToleranceFactoredCallbacks.mas_bottom).offset(YahooKeyTip.tatarMaximum.ironKinChain);
        make.centerX.equalTo(self.pongPointRunBackgroundView.mas_centerX);
        make.left.equalTo(self.pongPointRunBackgroundView.mas_left).offset(YahooKeyTip.tatarMaximum.looperGreat);
        make.right.equalTo(self.pongPointRunBackgroundView.mas_right).offset(-YahooKeyTip.tatarMaximum.looperGreat);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)maleIllCanText:(NSString *)text {
    self.thatWaxLabel.text = text;
    
    
    CGFloat stopWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.thatWaxLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[AggregateManager shared] mediaToneButWindow];
    CGFloat sideAirWidth = MIN(MAX(120, stopWidth + 2 * 8), window.bounds.size.width);
    [self.pongPointRunBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(sideAirWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)retSonCadenceWindow {
    [self parentalSizeSpaceAuditedDoneWaterText:YahooKeyTip.somaliLoopMove.repeatKinHas];
}

+ (void)parentalSizeSpaceAuditedDoneWaterText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[AggregateManager shared] mediaToneButWindow];
        
        if (!symbolicMicroView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            symbolicMicroView = [[PickMinuteView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            symbolicMicroView.center = window.center;
        }
        if (!symbolicMicroView.superview) {
            [window addSubview:symbolicMicroView];
        }
        [symbolicMicroView maleIllCanText:text];
        [symbolicMicroView startAnimating];
    });
}

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


+ (PickMinuteView *)hourOverChildView:(UIView *)view {
    return [self hourOverChildView:view withText:YahooKeyTip.somaliLoopMove.repeatKinHas];
}

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

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

@end
