






#import "OddPlayingView.h"
#import "UndefinedManager.h"
#import "ZipCoulombs.h"
#import "Masonry.h"

@interface OddPlayingView ()

@property (nonatomic, strong) UIView *eraExternSeeBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *suitableComputerRetAirHit;
@property (nonatomic, strong) UILabel *youSinkLabel;
@end

@implementation OddPlayingView


static OddPlayingView *binActionsAllView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self aboutView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self aboutView];
    }
    return self;
}
- (void)aboutView {
    
    
    self.eraExternSeeBackgroundView = [UIView new];
    self.eraExternSeeBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.eraExternSeeBackgroundView.layer.cornerRadius = ZipCoulombs.locatorCanon.producesUsed;
    self.eraExternSeeBackgroundView.clipsToBounds = YES;
    [self addSubview:self.eraExternSeeBackgroundView];
    
    
    self.suitableComputerRetAirHit = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.suitableComputerRetAirHit.color = ZipCoulombs.zipSuddenColor;
    [self.eraExternSeeBackgroundView addSubview:self.suitableComputerRetAirHit];
    
    
    self.youSinkLabel = [[UILabel alloc] init];
    self.youSinkLabel.text = ZipCoulombs.airAgeGreekAnd.maxKnowStyle;
    self.youSinkLabel.textColor = [UIColor whiteColor];
    self.youSinkLabel.font = [UIFont systemFontOfSize:14];
    self.youSinkLabel.numberOfLines = 0;
    self.youSinkLabel.textAlignment = NSTextAlignmentCenter;
    [self.eraExternSeeBackgroundView addSubview:self.youSinkLabel];
    
    
    [self.eraExternSeeBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(ZipCoulombs.locatorCanon.embeddedUnion, ZipCoulombs.locatorCanon.embeddedUnion));
        make.center.equalTo(self);
    }];
    
    [self.suitableComputerRetAirHit mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ZipCoulombs.locatorCanon.producesUsed);
        make.centerX.equalTo(self.eraExternSeeBackgroundView.mas_centerX);
    }];
    
    [self.youSinkLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.suitableComputerRetAirHit.mas_bottom).offset(ZipCoulombs.locatorCanon.producesUsed);
        make.centerX.equalTo(self.eraExternSeeBackgroundView.mas_centerX);
        make.left.equalTo(self.eraExternSeeBackgroundView.mas_left).offset(ZipCoulombs.locatorCanon.sigmoidDeny);
        make.right.equalTo(self.eraExternSeeBackgroundView.mas_right).offset(-ZipCoulombs.locatorCanon.sigmoidDeny);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)postFlightText:(NSString *)text {
    self.youSinkLabel.text = text;
    
    
    CGFloat pullWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.youSinkLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[UndefinedManager shared] occurredCellWindow];
    CGFloat userRawWidth = MIN(MAX(120, pullWidth + 2 * 8), window.bounds.size.width);
    [self.eraExternSeeBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(userRawWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)sameTooWayDayWindow {
    [self softScannedRealThirdAirFixText:ZipCoulombs.airAgeGreekAnd.maxKnowStyle];
}

+ (void)softScannedRealThirdAirFixText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[UndefinedManager shared] occurredCellWindow];
        
        if (!binActionsAllView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            binActionsAllView = [[OddPlayingView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            binActionsAllView.center = window.center;
        }
        if (!binActionsAllView.superview) {
            [window addSubview:binActionsAllView];
        }
        [binActionsAllView postFlightText:text];
        [binActionsAllView startAnimating];
    });
}

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


+ (OddPlayingView *)heartHoursBitView:(UIView *)view {
    return [self heartHoursBitView:view withText:ZipCoulombs.airAgeGreekAnd.maxKnowStyle];
}

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

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

@end
