






#import "LogicalSonView.h"
#import "CountHostManager.h"
#import "HourEllipse.h"
#import "Masonry.h"

@interface LogicalSonView ()

@property (nonatomic, strong) UIView *cutterDogOptBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *hueModalSuspendedAbortedMen;
@property (nonatomic, strong) UILabel *declineLabel;
@end

@implementation LogicalSonView


static LogicalSonView *hisCutEntriesView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self learnView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self learnView];
    }
    return self;
}
- (void)learnView {
    
    
    self.cutterDogOptBackgroundView = [UIView new];
    self.cutterDogOptBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.cutterDogOptBackgroundView.layer.cornerRadius = 2.0;
    self.cutterDogOptBackgroundView.clipsToBounds = YES;
    [self addSubview:self.cutterDogOptBackgroundView];
    
    
    self.hueModalSuspendedAbortedMen = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.hueModalSuspendedAbortedMen.color = HourEllipse.screenKinColor;
    [self.cutterDogOptBackgroundView addSubview:self.hueModalSuspendedAbortedMen];
    
    
    self.declineLabel = [[UILabel alloc] init];
    self.declineLabel.text = HourEllipse.alienSemaphore.polarLoopWay;
    self.declineLabel.textColor = [UIColor whiteColor];
    self.declineLabel.font = [UIFont systemFontOfSize:14];
    self.declineLabel.numberOfLines = 0;
    self.declineLabel.textAlignment = NSTextAlignmentCenter;
    [self.cutterDogOptBackgroundView addSubview:self.declineLabel];
    
    
    [self.cutterDogOptBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(HourEllipse.howSignaling.moleUnderline, HourEllipse.howSignaling.moleUnderline));
        make.center.equalTo(self);
    }];
    
    [self.hueModalSuspendedAbortedMen mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(HourEllipse.howSignaling.midMidRemote);
        make.centerX.equalTo(self.cutterDogOptBackgroundView.mas_centerX);
    }];
    
    [self.declineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.hueModalSuspendedAbortedMen.mas_bottom).offset(HourEllipse.howSignaling.midMidRemote);
        make.centerX.equalTo(self.cutterDogOptBackgroundView.mas_centerX);
        make.left.equalTo(self.cutterDogOptBackgroundView.mas_left).offset(HourEllipse.howSignaling.peakIndexes);
        make.right.equalTo(self.cutterDogOptBackgroundView.mas_right).offset(-HourEllipse.howSignaling.peakIndexes);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)sendWhoArtText:(NSString *)text {
    self.declineLabel.text = text;
    
    
    CGFloat ruleWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.declineLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[CountHostManager shared] maxForceDarkWindow];
    CGFloat takeMidWidth = MIN(MAX(120, ruleWidth + 2 * 8), window.bounds.size.width);
    [self.cutterDogOptBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(takeMidWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)fitRatioRomanWindow {
    [self parseManganeseConstantsDiskBarsFormatsText:HourEllipse.alienSemaphore.polarLoopWay];
}

+ (void)parseManganeseConstantsDiskBarsFormatsText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[CountHostManager shared] maxForceDarkWindow];
        
        if (!hisCutEntriesView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            hisCutEntriesView = [[LogicalSonView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            hisCutEntriesView.center = window.center;
        }
        if (!hisCutEntriesView.superview) {
            [window addSubview:hisCutEntriesView];
        }
        [hisCutEntriesView sendWhoArtText:text];
        [hisCutEntriesView startAnimating];
    });
}

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


+ (LogicalSonView *)sleepInstallsView:(UIView *)view {
    return [self sleepInstallsView:view withText:HourEllipse.alienSemaphore.polarLoopWay];
}

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

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

@end
