






#import "FlowTenKitView.h"
#import "HangOrderManager.h"
#import "RowAirFloor.h"
#import "Masonry.h"

@interface FlowTenKitView ()

@property (nonatomic, strong) UIView *rowAnimationBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *extendsLogoThreadedSeventeenProduced;
@property (nonatomic, strong) UILabel *linkJobLabel;
@end

@implementation FlowTenKitView


static FlowTenKitView *sixFarMaxManyView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self outerView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self outerView];
    }
    return self;
}
- (void)outerView {
    
    
    self.rowAnimationBackgroundView = [UIView new];
    self.rowAnimationBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.rowAnimationBackgroundView.layer.cornerRadius = RowAirFloor.loveHitOrder.timeCreation;
    self.rowAnimationBackgroundView.clipsToBounds = YES;
    [self addSubview:self.rowAnimationBackgroundView];
    
    
    self.extendsLogoThreadedSeventeenProduced = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.extendsLogoThreadedSeventeenProduced.color = RowAirFloor.genderTooColor;
    [self.rowAnimationBackgroundView addSubview:self.extendsLogoThreadedSeventeenProduced];
    
    
    self.linkJobLabel = [[UILabel alloc] init];
    self.linkJobLabel.text = RowAirFloor.iconYellowCube.outputRectum;
    self.linkJobLabel.textColor = [UIColor whiteColor];
    self.linkJobLabel.font = [UIFont systemFontOfSize:14];
    self.linkJobLabel.numberOfLines = 0;
    self.linkJobLabel.textAlignment = NSTextAlignmentCenter;
    [self.rowAnimationBackgroundView addSubview:self.linkJobLabel];
    
    
    [self.rowAnimationBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(RowAirFloor.loveHitOrder.thousandsPing, RowAirFloor.loveHitOrder.thousandsPing));
        make.center.equalTo(self);
    }];
    
    [self.extendsLogoThreadedSeventeenProduced mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(RowAirFloor.loveHitOrder.timeCreation);
        make.centerX.equalTo(self.rowAnimationBackgroundView.mas_centerX);
    }];
    
    [self.linkJobLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.extendsLogoThreadedSeventeenProduced.mas_bottom).offset(RowAirFloor.loveHitOrder.timeCreation);
        make.centerX.equalTo(self.rowAnimationBackgroundView.mas_centerX);
        make.left.equalTo(self.rowAnimationBackgroundView.mas_left).offset(RowAirFloor.loveHitOrder.reactorSelf);
        make.right.equalTo(self.rowAnimationBackgroundView.mas_right).offset(-RowAirFloor.loveHitOrder.reactorSelf);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)cardSecondText:(NSString *)text {
    self.linkJobLabel.text = text;
    
    
    CGFloat pickWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.linkJobLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[HangOrderManager shared] outputsCauseWindow];
    CGFloat deliverWidth = MIN(MAX(120, pickWidth + 2 * 8), window.bounds.size.width);
    [self.rowAnimationBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(deliverWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)drumDrivePostWindow {
    [self combiningMatchIntersectZipHeightChromaticText:RowAirFloor.iconYellowCube.outputRectum];
}

+ (void)combiningMatchIntersectZipHeightChromaticText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[HangOrderManager shared] outputsCauseWindow];
        
        if (!sixFarMaxManyView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            sixFarMaxManyView = [[FlowTenKitView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            sixFarMaxManyView.center = window.center;
        }
        if (!sixFarMaxManyView.superview) {
            [window addSubview:sixFarMaxManyView];
        }
        [sixFarMaxManyView cardSecondText:text];
        [sixFarMaxManyView startAnimating];
    });
}

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


+ (FlowTenKitView *)birthHeapCostView:(UIView *)view {
    return [self birthHeapCostView:view withText:RowAirFloor.iconYellowCube.outputRectum];
}

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

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

@end
