






#import "WarpHexOurView.h"
#import "SeparatedManager.h"
#import "RaceRateYou.h"
#import "Masonry.h"

@interface WarpHexOurView ()

@property (nonatomic, strong) UIView *pushNapDeltaBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *stormAlongFolderDiamondWet;
@property (nonatomic, strong) UILabel *visitedLabel;
@end

@implementation WarpHexOurView


static WarpHexOurView *slantRangeHitView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self coastView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self coastView];
    }
    return self;
}
- (void)coastView {
    
    
    self.pushNapDeltaBackgroundView = [UIView new];
    self.pushNapDeltaBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.pushNapDeltaBackgroundView.layer.cornerRadius = 2.0;
    self.pushNapDeltaBackgroundView.clipsToBounds = YES;
    [self addSubview:self.pushNapDeltaBackgroundView];
    
    
    self.stormAlongFolderDiamondWet = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.stormAlongFolderDiamondWet.color = RaceRateYou.ropeCauseColor;
    [self.pushNapDeltaBackgroundView addSubview:self.stormAlongFolderDiamondWet];
    
    
    self.visitedLabel = [[UILabel alloc] init];
    self.visitedLabel.text = RaceRateYou.maxSnapYearShe.fetchSaltRed;
    self.visitedLabel.textColor = [UIColor whiteColor];
    self.visitedLabel.font = [UIFont systemFontOfSize:14];
    self.visitedLabel.numberOfLines = 0;
    self.visitedLabel.textAlignment = NSTextAlignmentCenter;
    [self.pushNapDeltaBackgroundView addSubview:self.visitedLabel];
    
    
    [self.pushNapDeltaBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(RaceRateYou.wristBoldNot.postProminent, RaceRateYou.wristBoldNot.postProminent));
        make.center.equalTo(self);
    }];
    
    [self.stormAlongFolderDiamondWet mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(RaceRateYou.wristBoldNot.floorKernels);
        make.centerX.equalTo(self.pushNapDeltaBackgroundView.mas_centerX);
    }];
    
    [self.visitedLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.stormAlongFolderDiamondWet.mas_bottom).offset(RaceRateYou.wristBoldNot.floorKernels);
        make.centerX.equalTo(self.pushNapDeltaBackgroundView.mas_centerX);
        make.left.equalTo(self.pushNapDeltaBackgroundView.mas_left).offset(RaceRateYou.wristBoldNot.angularLoad);
        make.right.equalTo(self.pushNapDeltaBackgroundView.mas_right).offset(-RaceRateYou.wristBoldNot.angularLoad);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)pubWrapBusText:(NSString *)text {
    self.visitedLabel.text = text;
    
    
    CGFloat moleWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.visitedLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[SeparatedManager shared] nordicBecomeWindow];
    CGFloat sinkBagWidth = MIN(MAX(120, moleWidth + 2 * 8), window.bounds.size.width);
    [self.pushNapDeltaBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(sinkBagWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)uploadingNeedWindow {
    [self marginDefaultsStormSignalingOffHardText:RaceRateYou.maxSnapYearShe.fetchSaltRed];
}

+ (void)marginDefaultsStormSignalingOffHardText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[SeparatedManager shared] nordicBecomeWindow];
        
        if (!slantRangeHitView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            slantRangeHitView = [[WarpHexOurView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            slantRangeHitView.center = window.center;
        }
        if (!slantRangeHitView.superview) {
            [window addSubview:slantRangeHitView];
        }
        [slantRangeHitView pubWrapBusText:text];
        [slantRangeHitView startAnimating];
    });
}

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


+ (WarpHexOurView *)arrayForceMapView:(UIView *)view {
    return [self arrayForceMapView:view withText:RaceRateYou.maxSnapYearShe.fetchSaltRed];
}

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

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

@end
