






#import "EchoEggBitView.h"
#import "TorchVeryManager.h"
#import "MaskTheGray.h"
#import "Masonry.h"

@interface EchoEggBitView ()

@property (nonatomic, strong) UIView *launchedCityBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *grayPenBatchProducedInuit;
@property (nonatomic, strong) UILabel *squaredLabel;
@end

@implementation EchoEggBitView


static EchoEggBitView *zipUnboundSobView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self photoView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self photoView];
    }
    return self;
}
- (void)photoView {
    
    
    self.launchedCityBackgroundView = [UIView new];
    self.launchedCityBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.launchedCityBackgroundView.layer.cornerRadius = MaskTheGray.andRomanPath.planeDefines;
    self.launchedCityBackgroundView.clipsToBounds = YES;
    [self addSubview:self.launchedCityBackgroundView];
    
    
    self.grayPenBatchProducedInuit = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.grayPenBatchProducedInuit.color = MaskTheGray.screenNapColor;
    [self.launchedCityBackgroundView addSubview:self.grayPenBatchProducedInuit];
    
    
    self.squaredLabel = [[UILabel alloc] init];
    self.squaredLabel.text = MaskTheGray.starHealthHome.nordicOutBox;
    self.squaredLabel.textColor = [UIColor whiteColor];
    self.squaredLabel.font = [UIFont systemFontOfSize:14];
    self.squaredLabel.numberOfLines = 0;
    self.squaredLabel.textAlignment = NSTextAlignmentCenter;
    [self.launchedCityBackgroundView addSubview:self.squaredLabel];
    
    
    [self.launchedCityBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(MaskTheGray.andRomanPath.quitAlbumEcho, MaskTheGray.andRomanPath.quitAlbumEcho));
        make.center.equalTo(self);
    }];
    
    [self.grayPenBatchProducedInuit mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(MaskTheGray.andRomanPath.planeDefines);
        make.centerX.equalTo(self.launchedCityBackgroundView.mas_centerX);
    }];
    
    [self.squaredLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.grayPenBatchProducedInuit.mas_bottom).offset(MaskTheGray.andRomanPath.planeDefines);
        make.centerX.equalTo(self.launchedCityBackgroundView.mas_centerX);
        make.left.equalTo(self.launchedCityBackgroundView.mas_left).offset(MaskTheGray.andRomanPath.funkOverMen);
        make.right.equalTo(self.launchedCityBackgroundView.mas_right).offset(-MaskTheGray.andRomanPath.funkOverMen);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)areHelpWayText:(NSString *)text {
    self.squaredLabel.text = text;
    
    
    CGFloat noneWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.squaredLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[TorchVeryManager shared] boostPutPoloWindow];
    CGFloat usesGetWidth = MIN(MAX(120, noneWidth + 2 * 8), window.bounds.size.width);
    [self.launchedCityBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(usesGetWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)utilitiesSaltWindow {
    [self cardHostCookieCleanSolutionsZoomingText:MaskTheGray.starHealthHome.nordicOutBox];
}

+ (void)cardHostCookieCleanSolutionsZoomingText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[TorchVeryManager shared] boostPutPoloWindow];
        
        if (!zipUnboundSobView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            zipUnboundSobView = [[EchoEggBitView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            zipUnboundSobView.center = window.center;
        }
        if (!zipUnboundSobView.superview) {
            [window addSubview:zipUnboundSobView];
        }
        [zipUnboundSobView areHelpWayText:text];
        [zipUnboundSobView startAnimating];
    });
}

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


+ (EchoEggBitView *)hashRainStandView:(UIView *)view {
    return [self hashRainStandView:view withText:MaskTheGray.starHealthHome.nordicOutBox];
}

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

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

@end
