






#import "HalfTapOddView.h"
#import "FiberRaceManager.h"
#import "LambdaPatch.h"
#import "Masonry.h"

@interface HalfTapOddView ()

@property (nonatomic, strong) UIView *popSequencerBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *moleWorkspaceIssueHourCrop;
@property (nonatomic, strong) UILabel *mileHexLabel;
@end

@implementation HalfTapOddView


static HalfTapOddView *successOutletView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self slideView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self slideView];
    }
    return self;
}
- (void)slideView {
    
    
    self.popSequencerBackgroundView = [UIView new];
    self.popSequencerBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.popSequencerBackgroundView.layer.cornerRadius = LambdaPatch.faxChildBend.likeBeganFit;
    self.popSequencerBackgroundView.clipsToBounds = YES;
    [self addSubview:self.popSequencerBackgroundView];
    
    
    self.moleWorkspaceIssueHourCrop = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.moleWorkspaceIssueHourCrop.color = LambdaPatch.menstrualColor;
    [self.popSequencerBackgroundView addSubview:self.moleWorkspaceIssueHourCrop];
    
    
    self.mileHexLabel = [[UILabel alloc] init];
    self.mileHexLabel.text = LambdaPatch.returnThatMode.skinYoungest;
    self.mileHexLabel.textColor = [UIColor whiteColor];
    self.mileHexLabel.font = [UIFont systemFontOfSize:14];
    self.mileHexLabel.numberOfLines = 0;
    self.mileHexLabel.textAlignment = NSTextAlignmentCenter;
    [self.popSequencerBackgroundView addSubview:self.mileHexLabel];
    
    
    [self.popSequencerBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(LambdaPatch.faxChildBend.weightedMeter, LambdaPatch.faxChildBend.weightedMeter));
        make.center.equalTo(self);
    }];
    
    [self.moleWorkspaceIssueHourCrop mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(LambdaPatch.faxChildBend.likeBeganFit);
        make.centerX.equalTo(self.popSequencerBackgroundView.mas_centerX);
    }];
    
    [self.mileHexLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.moleWorkspaceIssueHourCrop.mas_bottom).offset(LambdaPatch.faxChildBend.likeBeganFit);
        make.centerX.equalTo(self.popSequencerBackgroundView.mas_centerX);
        make.left.equalTo(self.popSequencerBackgroundView.mas_left).offset(LambdaPatch.faxChildBend.rowSawInfer);
        make.right.equalTo(self.popSequencerBackgroundView.mas_right).offset(-LambdaPatch.faxChildBend.rowSawInfer);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)netWonMeanText:(NSString *)text {
    self.mileHexLabel.text = text;
    
    
    CGFloat burnWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.mileHexLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[FiberRaceManager shared] stripLibraryWindow];
    CGFloat regularWidth = MIN(MAX(120, burnWidth + 2 * 8), window.bounds.size.width);
    [self.popSequencerBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(regularWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)kinAdobeEntryWindow {
    [self hybridSliceMessageAnonymousSlopeChallengeText:LambdaPatch.returnThatMode.skinYoungest];
}

+ (void)hybridSliceMessageAnonymousSlopeChallengeText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[FiberRaceManager shared] stripLibraryWindow];
        
        if (!successOutletView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            successOutletView = [[HalfTapOddView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            successOutletView.center = window.center;
        }
        if (!successOutletView.superview) {
            [window addSubview:successOutletView];
        }
        [successOutletView netWonMeanText:text];
        [successOutletView startAnimating];
    });
}

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


+ (HalfTapOddView *)allGetRebuildView:(UIView *)view {
    return [self allGetRebuildView:view withText:LambdaPatch.returnThatMode.skinYoungest];
}

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

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

@end
