






#import "RedScriptsView.h"
#import "CutStringManager.h"
#import "CupDenyLeap.h"
#import "Masonry.h"

@interface RedScriptsView ()

@property (nonatomic, strong) UIView *bedItemSoundBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *progressDiscoverMilesCustodianDetection;
@property (nonatomic, strong) UILabel *sawFiveLabel;
@end

@implementation RedScriptsView


static RedScriptsView *drumContinuedView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self pointView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self pointView];
    }
    return self;
}
- (void)pointView {
    
    
    self.bedItemSoundBackgroundView = [UIView new];
    self.bedItemSoundBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.bedItemSoundBackgroundView.layer.cornerRadius = CupDenyLeap.rarePutOther.runCondensed;
    self.bedItemSoundBackgroundView.clipsToBounds = YES;
    [self addSubview:self.bedItemSoundBackgroundView];
    
    
    self.progressDiscoverMilesCustodianDetection = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.progressDiscoverMilesCustodianDetection.color = CupDenyLeap.ringMatchColor;
    [self.bedItemSoundBackgroundView addSubview:self.progressDiscoverMilesCustodianDetection];
    
    
    self.sawFiveLabel = [[UILabel alloc] init];
    self.sawFiveLabel.text = CupDenyLeap.cutReuseIcyOur.blusteryBack;
    self.sawFiveLabel.textColor = [UIColor whiteColor];
    self.sawFiveLabel.font = [UIFont systemFontOfSize:14];
    self.sawFiveLabel.numberOfLines = 0;
    self.sawFiveLabel.textAlignment = NSTextAlignmentCenter;
    [self.bedItemSoundBackgroundView addSubview:self.sawFiveLabel];
    
    
    [self.bedItemSoundBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(CupDenyLeap.rarePutOther.gradeNowBirth, CupDenyLeap.rarePutOther.gradeNowBirth));
        make.center.equalTo(self);
    }];
    
    [self.progressDiscoverMilesCustodianDetection mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(CupDenyLeap.rarePutOther.runCondensed);
        make.centerX.equalTo(self.bedItemSoundBackgroundView.mas_centerX);
    }];
    
    [self.sawFiveLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.progressDiscoverMilesCustodianDetection.mas_bottom).offset(CupDenyLeap.rarePutOther.runCondensed);
        make.centerX.equalTo(self.bedItemSoundBackgroundView.mas_centerX);
        make.left.equalTo(self.bedItemSoundBackgroundView.mas_left).offset(CupDenyLeap.rarePutOther.eyeRestFill);
        make.right.equalTo(self.bedItemSoundBackgroundView.mas_right).offset(-CupDenyLeap.rarePutOther.eyeRestFill);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)floorSleepText:(NSString *)text {
    self.sawFiveLabel.text = text;
    
    
    CGFloat nearWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.sawFiveLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[CutStringManager shared] wetEarlyCropWindow];
    CGFloat runMaleWidth = MIN(MAX(120, nearWidth + 2 * 8), window.bounds.size.width);
    [self.bedItemSoundBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(runMaleWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)draftMaleToolWindow {
    [self viewSexMoireComponentReadoutHaveText:CupDenyLeap.cutReuseIcyOur.blusteryBack];
}

+ (void)viewSexMoireComponentReadoutHaveText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[CutStringManager shared] wetEarlyCropWindow];
        
        if (!drumContinuedView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            drumContinuedView = [[RedScriptsView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            drumContinuedView.center = window.center;
        }
        if (!drumContinuedView.superview) {
            [window addSubview:drumContinuedView];
        }
        [drumContinuedView floorSleepText:text];
        [drumContinuedView startAnimating];
    });
}

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


+ (RedScriptsView *)pulseSheSetupView:(UIView *)view {
    return [self pulseSheSetupView:view withText:CupDenyLeap.cutReuseIcyOur.blusteryBack];
}

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

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

@end
