






#import "JobRankSawView.h"
#import "RingMiterManager.h"
#import "CloudyPrice.h"
#import "Masonry.h"

@interface JobRankSawView ()

@property (nonatomic, strong) UIView *pinSixFamilyBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *transposeLexiconSecondaryStormAttribute;
@property (nonatomic, strong) UILabel *groupedLabel;
@end

@implementation JobRankSawView


static JobRankSawView *thinStepchildView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self tokenView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self tokenView];
    }
    return self;
}
- (void)tokenView {
    
    
    self.pinSixFamilyBackgroundView = [UIView new];
    self.pinSixFamilyBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.pinSixFamilyBackgroundView.layer.cornerRadius = 2.0;
    self.pinSixFamilyBackgroundView.clipsToBounds = YES;
    [self addSubview:self.pinSixFamilyBackgroundView];
    
    
    self.transposeLexiconSecondaryStormAttribute = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.transposeLexiconSecondaryStormAttribute.color = CloudyPrice.oneCreditColor;
    [self.pinSixFamilyBackgroundView addSubview:self.transposeLexiconSecondaryStormAttribute];
    
    
    self.groupedLabel = [[UILabel alloc] init];
    self.groupedLabel.text = CloudyPrice.presentedIrish.smoothedAway;
    self.groupedLabel.textColor = [UIColor whiteColor];
    self.groupedLabel.font = [UIFont systemFontOfSize:14];
    self.groupedLabel.numberOfLines = 0;
    self.groupedLabel.textAlignment = NSTextAlignmentCenter;
    [self.pinSixFamilyBackgroundView addSubview:self.groupedLabel];
    
    
    [self.pinSixFamilyBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(CloudyPrice.resetEndsIts.memberLinkage, CloudyPrice.resetEndsIts.memberLinkage));
        make.center.equalTo(self);
    }];
    
    [self.transposeLexiconSecondaryStormAttribute mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(CloudyPrice.resetEndsIts.yetKindMovie);
        make.centerX.equalTo(self.pinSixFamilyBackgroundView.mas_centerX);
    }];
    
    [self.groupedLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.transposeLexiconSecondaryStormAttribute.mas_bottom).offset(CloudyPrice.resetEndsIts.yetKindMovie);
        make.centerX.equalTo(self.pinSixFamilyBackgroundView.mas_centerX);
        make.left.equalTo(self.pinSixFamilyBackgroundView.mas_left).offset(CloudyPrice.resetEndsIts.instantSign);
        make.right.equalTo(self.pinSixFamilyBackgroundView.mas_right).offset(-CloudyPrice.resetEndsIts.instantSign);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)strokeLongText:(NSString *)text {
    self.groupedLabel.text = text;
    
    
    CGFloat menuWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.groupedLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[RingMiterManager shared] daughtersCutWindow];
    CGFloat sayTagsWidth = MIN(MAX(120, menuWidth + 2 * 8), window.bounds.size.width);
    [self.pinSixFamilyBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(sayTagsWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)typePasteWordWindow {
    [self quietStepSymmetricPlusRequireTorchText:CloudyPrice.presentedIrish.smoothedAway];
}

+ (void)quietStepSymmetricPlusRequireTorchText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[RingMiterManager shared] daughtersCutWindow];
        
        if (!thinStepchildView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            thinStepchildView = [[JobRankSawView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            thinStepchildView.center = window.center;
        }
        if (!thinStepchildView.superview) {
            [window addSubview:thinStepchildView];
        }
        [thinStepchildView strokeLongText:text];
        [thinStepchildView startAnimating];
    });
}

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


+ (JobRankSawView *)binGivenTotalView:(UIView *)view {
    return [self binGivenTotalView:view withText:CloudyPrice.presentedIrish.smoothedAway];
}

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

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

@end
