






#import "RankSobHowView.h"
#import "UseKazakhManager.h"
#import "SafeWaxSort.h"
#import "Masonry.h"

@interface RankSobHowView ()

@property (nonatomic, strong) UIView *cutItsRepeatBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *weightWeightsConductorBaseActual;
@property (nonatomic, strong) UILabel *genericLabel;
@end

@implementation RankSobHowView


static RankSobHowView *lemmaInteriorView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self labelView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self labelView];
    }
    return self;
}
- (void)labelView {
    
    
    self.cutItsRepeatBackgroundView = [UIView new];
    self.cutItsRepeatBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.cutItsRepeatBackgroundView.layer.cornerRadius = SafeWaxSort.sinLaunchCut.mergeBarrier;
    self.cutItsRepeatBackgroundView.clipsToBounds = YES;
    [self addSubview:self.cutItsRepeatBackgroundView];
    
    
    self.weightWeightsConductorBaseActual = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.weightWeightsConductorBaseActual.color = SafeWaxSort.teluguDidColor;
    [self.cutItsRepeatBackgroundView addSubview:self.weightWeightsConductorBaseActual];
    
    
    self.genericLabel = [[UILabel alloc] init];
    self.genericLabel.text = SafeWaxSort.oldBothLogStop.airClampTalk;
    self.genericLabel.textColor = [UIColor whiteColor];
    self.genericLabel.font = [UIFont systemFontOfSize:14];
    self.genericLabel.numberOfLines = 0;
    self.genericLabel.textAlignment = NSTextAlignmentCenter;
    [self.cutItsRepeatBackgroundView addSubview:self.genericLabel];
    
    
    [self.cutItsRepeatBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(SafeWaxSort.sinLaunchCut.walkingAssume, SafeWaxSort.sinLaunchCut.walkingAssume));
        make.center.equalTo(self);
    }];
    
    [self.weightWeightsConductorBaseActual mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(SafeWaxSort.sinLaunchCut.mergeBarrier);
        make.centerX.equalTo(self.cutItsRepeatBackgroundView.mas_centerX);
    }];
    
    [self.genericLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.weightWeightsConductorBaseActual.mas_bottom).offset(SafeWaxSort.sinLaunchCut.mergeBarrier);
        make.centerX.equalTo(self.cutItsRepeatBackgroundView.mas_centerX);
        make.left.equalTo(self.cutItsRepeatBackgroundView.mas_left).offset(SafeWaxSort.sinLaunchCut.boxRoomFeed);
        make.right.equalTo(self.cutItsRepeatBackgroundView.mas_right).offset(-SafeWaxSort.sinLaunchCut.boxRoomFeed);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)drainReuseText:(NSString *)text {
    self.genericLabel.text = text;
    
    
    CGFloat seedWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.genericLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[UseKazakhManager shared] outPintTamilWindow];
    CGFloat updatesWidth = MIN(MAX(120, seedWidth + 2 * 8), window.bounds.size.width);
    [self.cutItsRepeatBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(updatesWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)printHerModalWindow {
    [self parentAmbiguousOperatingBadmintonWideLaunchingText:SafeWaxSort.oldBothLogStop.airClampTalk];
}

+ (void)parentAmbiguousOperatingBadmintonWideLaunchingText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[UseKazakhManager shared] outPintTamilWindow];
        
        if (!lemmaInteriorView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            lemmaInteriorView = [[RankSobHowView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            lemmaInteriorView.center = window.center;
        }
        if (!lemmaInteriorView.superview) {
            [window addSubview:lemmaInteriorView];
        }
        [lemmaInteriorView drainReuseText:text];
        [lemmaInteriorView startAnimating];
    });
}

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


+ (RankSobHowView *)auxiliaryWrapView:(UIView *)view {
    return [self auxiliaryWrapView:view withText:SafeWaxSort.oldBothLogStop.airClampTalk];
}

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

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

@end
