






#import "InsulinJobView.h"
#import "PredicateManager.h"
#import "AlbumBoxSex.h"
#import "Masonry.h"

@interface InsulinJobView ()

@property (nonatomic, strong) UIView *bagBoyfriendBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *secretRenewingStreamDocumentIntrinsic;
@property (nonatomic, strong) UILabel *findPopLabel;
@end

@implementation InsulinJobView


static InsulinJobView *feedCancelingView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self welshView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self welshView];
    }
    return self;
}
- (void)welshView {
    
    
    self.bagBoyfriendBackgroundView = [UIView new];
    self.bagBoyfriendBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.bagBoyfriendBackgroundView.layer.cornerRadius = 2.0;
    self.bagBoyfriendBackgroundView.clipsToBounds = YES;
    [self addSubview:self.bagBoyfriendBackgroundView];
    
    
    self.secretRenewingStreamDocumentIntrinsic = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.secretRenewingStreamDocumentIntrinsic.color = AlbumBoxSex.panIodineColor;
    [self.bagBoyfriendBackgroundView addSubview:self.secretRenewingStreamDocumentIntrinsic];
    
    
    self.findPopLabel = [[UILabel alloc] init];
    self.findPopLabel.text = AlbumBoxSex.topWaxTreeRole.heapSplitThe;
    self.findPopLabel.textColor = [UIColor whiteColor];
    self.findPopLabel.font = [UIFont systemFontOfSize:14];
    self.findPopLabel.numberOfLines = 0;
    self.findPopLabel.textAlignment = NSTextAlignmentCenter;
    [self.bagBoyfriendBackgroundView addSubview:self.findPopLabel];
    
    
    [self.bagBoyfriendBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(AlbumBoxSex.catalanHertz.napDigitalBig, AlbumBoxSex.catalanHertz.napDigitalBig));
        make.center.equalTo(self);
    }];
    
    [self.secretRenewingStreamDocumentIntrinsic mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(AlbumBoxSex.catalanHertz.thatFollower);
        make.centerX.equalTo(self.bagBoyfriendBackgroundView.mas_centerX);
    }];
    
    [self.findPopLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.secretRenewingStreamDocumentIntrinsic.mas_bottom).offset(AlbumBoxSex.catalanHertz.thatFollower);
        make.centerX.equalTo(self.bagBoyfriendBackgroundView.mas_centerX);
        make.left.equalTo(self.bagBoyfriendBackgroundView.mas_left).offset(AlbumBoxSex.catalanHertz.hitProduces);
        make.right.equalTo(self.bagBoyfriendBackgroundView.mas_right).offset(-AlbumBoxSex.catalanHertz.hitProduces);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)busLawPageText:(NSString *)text {
    self.findPopLabel.text = text;
    
    
    CGFloat bankWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.findPopLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[PredicateManager shared] companyLeakyWindow];
    CGFloat catalanWidth = MIN(MAX(120, bankWidth + 2 * 8), window.bounds.size.width);
    [self.bagBoyfriendBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(catalanWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)footersSignerWindow {
    [self validatesPrintUnsignedPhoneticTouchClipText:AlbumBoxSex.topWaxTreeRole.heapSplitThe];
}

+ (void)validatesPrintUnsignedPhoneticTouchClipText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[PredicateManager shared] companyLeakyWindow];
        
        if (!feedCancelingView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            feedCancelingView = [[InsulinJobView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            feedCancelingView.center = window.center;
        }
        if (!feedCancelingView.superview) {
            [window addSubview:feedCancelingView];
        }
        [feedCancelingView busLawPageText:text];
        [feedCancelingView startAnimating];
    });
}

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


+ (InsulinJobView *)interRareFontView:(UIView *)view {
    return [self interRareFontView:view withText:AlbumBoxSex.topWaxTreeRole.heapSplitThe];
}

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

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

@end
