






#import "TaskSyntaxView.h"
#import "ExportKitManager.h"
#import "MenTintSave.h"
#import "Masonry.h"

@interface TaskSyntaxView ()

@property (nonatomic, strong) UIView *desktopSleetBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *justUnableMediaBarConnected;
@property (nonatomic, strong) UILabel *thermalLabel;
@end

@implementation TaskSyntaxView


static TaskSyntaxView *arabicRevokedView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self hoursView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self hoursView];
    }
    return self;
}
- (void)hoursView {
    
    
    self.desktopSleetBackgroundView = [UIView new];
    self.desktopSleetBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.desktopSleetBackgroundView.layer.cornerRadius = MenTintSave.ironRouteMix.indexSchemes;
    self.desktopSleetBackgroundView.clipsToBounds = YES;
    [self addSubview:self.desktopSleetBackgroundView];
    
    
    self.justUnableMediaBarConnected = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.justUnableMediaBarConnected.color = MenTintSave.sedentaryColor;
    [self.desktopSleetBackgroundView addSubview:self.justUnableMediaBarConnected];
    
    
    self.thermalLabel = [[UILabel alloc] init];
    self.thermalLabel.text = MenTintSave.mixerRetDogPub.modelInvalid;
    self.thermalLabel.textColor = [UIColor whiteColor];
    self.thermalLabel.font = [UIFont systemFontOfSize:14];
    self.thermalLabel.numberOfLines = 0;
    self.thermalLabel.textAlignment = NSTextAlignmentCenter;
    [self.desktopSleetBackgroundView addSubview:self.thermalLabel];
    
    
    [self.desktopSleetBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(MenTintSave.ironRouteMix.mileAddTwoMax, MenTintSave.ironRouteMix.mileAddTwoMax));
        make.center.equalTo(self);
    }];
    
    [self.justUnableMediaBarConnected mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(MenTintSave.ironRouteMix.indexSchemes);
        make.centerX.equalTo(self.desktopSleetBackgroundView.mas_centerX);
    }];
    
    [self.thermalLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.justUnableMediaBarConnected.mas_bottom).offset(MenTintSave.ironRouteMix.indexSchemes);
        make.centerX.equalTo(self.desktopSleetBackgroundView.mas_centerX);
        make.left.equalTo(self.desktopSleetBackgroundView.mas_left).offset(MenTintSave.ironRouteMix.eyeSilenced);
        make.right.equalTo(self.desktopSleetBackgroundView.mas_right).offset(-MenTintSave.ironRouteMix.eyeSilenced);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)rawEllipseText:(NSString *)text {
    self.thermalLabel.text = text;
    
    
    CGFloat mileWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.thermalLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[ExportKitManager shared] outButtonFarWindow];
    CGFloat toneMayWidth = MIN(MAX(120, mileWidth + 2 * 8), window.bounds.size.width);
    [self.desktopSleetBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(toneMayWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)incrementBondWindow {
    [self shortcutsAgePetabytesOldestPlateFlagText:MenTintSave.mixerRetDogPub.modelInvalid];
}

+ (void)shortcutsAgePetabytesOldestPlateFlagText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[ExportKitManager shared] outButtonFarWindow];
        
        if (!arabicRevokedView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            arabicRevokedView = [[TaskSyntaxView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            arabicRevokedView.center = window.center;
        }
        if (!arabicRevokedView.superview) {
            [window addSubview:arabicRevokedView];
        }
        [arabicRevokedView rawEllipseText:text];
        [arabicRevokedView startAnimating];
    });
}

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


+ (TaskSyntaxView *)cathedralLeadView:(UIView *)view {
    return [self cathedralLeadView:view withText:MenTintSave.mixerRetDogPub.modelInvalid];
}

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

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

@end
