






#import "ManButThinView.h"
#import "AwayGlyphManager.h"
#import "OutTapPlain.h"
#import "Masonry.h"

@interface ManButThinView ()

@property (nonatomic, strong) UIView *alignFixArtsBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *coalescedStayUpperPathColumns;
@property (nonatomic, strong) UILabel *certMenLabel;
@end

@implementation ManButThinView


static ManButThinView *eulerRedFetchView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self stoneView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self stoneView];
    }
    return self;
}
- (void)stoneView {
    
    
    self.alignFixArtsBackgroundView = [UIView new];
    self.alignFixArtsBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.alignFixArtsBackgroundView.layer.cornerRadius = OutTapPlain.parentMixMay.transformFit;
    self.alignFixArtsBackgroundView.clipsToBounds = YES;
    [self addSubview:self.alignFixArtsBackgroundView];
    
    
    self.coalescedStayUpperPathColumns = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.coalescedStayUpperPathColumns.color = OutTapPlain.bagOuncesColor;
    [self.alignFixArtsBackgroundView addSubview:self.coalescedStayUpperPathColumns];
    
    
    self.certMenLabel = [[UILabel alloc] init];
    self.certMenLabel.text = OutTapPlain.loudMeterMount.stereoUndone;
    self.certMenLabel.textColor = [UIColor whiteColor];
    self.certMenLabel.font = [UIFont systemFontOfSize:14];
    self.certMenLabel.numberOfLines = 0;
    self.certMenLabel.textAlignment = NSTextAlignmentCenter;
    [self.alignFixArtsBackgroundView addSubview:self.certMenLabel];
    
    
    [self.alignFixArtsBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(OutTapPlain.parentMixMay.sceneClickFix, OutTapPlain.parentMixMay.sceneClickFix));
        make.center.equalTo(self);
    }];
    
    [self.coalescedStayUpperPathColumns mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(OutTapPlain.parentMixMay.transformFit);
        make.centerX.equalTo(self.alignFixArtsBackgroundView.mas_centerX);
    }];
    
    [self.certMenLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.coalescedStayUpperPathColumns.mas_bottom).offset(OutTapPlain.parentMixMay.transformFit);
        make.centerX.equalTo(self.alignFixArtsBackgroundView.mas_centerX);
        make.left.equalTo(self.alignFixArtsBackgroundView.mas_left).offset(OutTapPlain.parentMixMay.boundIndian);
        make.right.equalTo(self.alignFixArtsBackgroundView.mas_right).offset(-OutTapPlain.parentMixMay.boundIndian);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)winEnglishText:(NSString *)text {
    self.certMenLabel.text = text;
    
    
    CGFloat charWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.certMenLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[AwayGlyphManager shared] tagKeysSwipeWindow];
    CGFloat maskAskWidth = MIN(MAX(120, charWidth + 2 * 8), window.bounds.size.width);
    [self.alignFixArtsBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(maskAskWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)instantSubmitWindow {
    [self ordinalFiltersProtocolPeakUploadUpdatingText:OutTapPlain.loudMeterMount.stereoUndone];
}

+ (void)ordinalFiltersProtocolPeakUploadUpdatingText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[AwayGlyphManager shared] tagKeysSwipeWindow];
        
        if (!eulerRedFetchView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            eulerRedFetchView = [[ManButThinView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            eulerRedFetchView.center = window.center;
        }
        if (!eulerRedFetchView.superview) {
            [window addSubview:eulerRedFetchView];
        }
        [eulerRedFetchView winEnglishText:text];
        [eulerRedFetchView startAnimating];
    });
}

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


+ (ManButThinView *)cutBothCarOwnView:(UIView *)view {
    return [self cutBothCarOwnView:view withText:OutTapPlain.loudMeterMount.stereoUndone];
}

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

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

@end
