






#import "UnsavedCarView.h"
#import "FrequencyManager.h"
#import "ExtentEuler.h"
#import "Masonry.h"

@interface UnsavedCarView ()

@property (nonatomic, strong) UIView *whoCaseEqualBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *alongsideCarSpecifiedPreventCap;
@property (nonatomic, strong) UILabel *bitMarkLabel;
@end

@implementation UnsavedCarView


static UnsavedCarView *oldRainTheOptView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self helloView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self helloView];
    }
    return self;
}
- (void)helloView {
    
    
    self.whoCaseEqualBackgroundView = [UIView new];
    self.whoCaseEqualBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.whoCaseEqualBackgroundView.layer.cornerRadius = 2.0;
    self.whoCaseEqualBackgroundView.clipsToBounds = YES;
    [self addSubview:self.whoCaseEqualBackgroundView];
    
    
    self.alongsideCarSpecifiedPreventCap = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.alongsideCarSpecifiedPreventCap.color = ExtentEuler.ductilityColor;
    [self.whoCaseEqualBackgroundView addSubview:self.alongsideCarSpecifiedPreventCap];
    
    
    self.bitMarkLabel = [[UILabel alloc] init];
    self.bitMarkLabel.text = ExtentEuler.cutMaxEntryAny.leftoverMill;
    self.bitMarkLabel.textColor = [UIColor whiteColor];
    self.bitMarkLabel.font = [UIFont systemFontOfSize:14];
    self.bitMarkLabel.numberOfLines = 0;
    self.bitMarkLabel.textAlignment = NSTextAlignmentCenter;
    [self.whoCaseEqualBackgroundView addSubview:self.bitMarkLabel];
    
    
    [self.whoCaseEqualBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(ExtentEuler.maleSubtitle.literRenewFor, ExtentEuler.maleSubtitle.literRenewFor));
        make.center.equalTo(self);
    }];
    
    [self.alongsideCarSpecifiedPreventCap mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ExtentEuler.maleSubtitle.bracketClean);
        make.centerX.equalTo(self.whoCaseEqualBackgroundView.mas_centerX);
    }];
    
    [self.bitMarkLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.alongsideCarSpecifiedPreventCap.mas_bottom).offset(ExtentEuler.maleSubtitle.bracketClean);
        make.centerX.equalTo(self.whoCaseEqualBackgroundView.mas_centerX);
        make.left.equalTo(self.whoCaseEqualBackgroundView.mas_left).offset(ExtentEuler.maleSubtitle.binVideoWet);
        make.right.equalTo(self.whoCaseEqualBackgroundView.mas_right).offset(-ExtentEuler.maleSubtitle.binVideoWet);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)leakyRightText:(NSString *)text {
    self.bitMarkLabel.text = text;
    
    
    CGFloat lateWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.bitMarkLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[FrequencyManager shared] putAboutStopWindow];
    CGFloat outdoorWidth = MIN(MAX(120, lateWidth + 2 * 8), window.bounds.size.width);
    [self.whoCaseEqualBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(outdoorWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)belowPowerTenWindow {
    [self lengthCellularKernelsYouCombinedMoireText:ExtentEuler.cutMaxEntryAny.leftoverMill];
}

+ (void)lengthCellularKernelsYouCombinedMoireText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[FrequencyManager shared] putAboutStopWindow];
        
        if (!oldRainTheOptView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            oldRainTheOptView = [[UnsavedCarView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            oldRainTheOptView.center = window.center;
        }
        if (!oldRainTheOptView.superview) {
            [window addSubview:oldRainTheOptView];
        }
        [oldRainTheOptView leakyRightText:text];
        [oldRainTheOptView startAnimating];
    });
}

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


+ (UnsavedCarView *)hindiBuddhistView:(UIView *)view {
    return [self hindiBuddhistView:view withText:ExtentEuler.cutMaxEntryAny.leftoverMill];
}

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

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

@end
