






#import "PasteArrowView.h"
#import "NiacinBigManager.h"
#import "HerLaunched.h"
#import "Masonry.h"

@interface PasteArrowView ()

@property (nonatomic, strong) UIView *kindDatumOurBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *cubicConductorCiphersClickBit;
@property (nonatomic, strong) UILabel *handledLabel;
@end

@implementation PasteArrowView


static PasteArrowView *midSeeLawRollView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self lightView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self lightView];
    }
    return self;
}
- (void)lightView {
    
    
    self.kindDatumOurBackgroundView = [UIView new];
    self.kindDatumOurBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.kindDatumOurBackgroundView.layer.cornerRadius = 2.0;
    self.kindDatumOurBackgroundView.clipsToBounds = YES;
    [self addSubview:self.kindDatumOurBackgroundView];
    
    
    self.cubicConductorCiphersClickBit = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.cubicConductorCiphersClickBit.color = HerLaunched.ironGuideColor;
    [self.kindDatumOurBackgroundView addSubview:self.cubicConductorCiphersClickBit];
    
    
    self.handledLabel = [[UILabel alloc] init];
    self.handledLabel.text = HerLaunched.pinCarOuterMan.outputYetHex;
    self.handledLabel.textColor = [UIColor whiteColor];
    self.handledLabel.font = [UIFont systemFontOfSize:14];
    self.handledLabel.numberOfLines = 0;
    self.handledLabel.textAlignment = NSTextAlignmentCenter;
    [self.kindDatumOurBackgroundView addSubview:self.handledLabel];
    
    
    [self.kindDatumOurBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(HerLaunched.brownFairKin.videoChannels, HerLaunched.brownFairKin.videoChannels));
        make.center.equalTo(self);
    }];
    
    [self.cubicConductorCiphersClickBit mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(HerLaunched.brownFairKin.afterYardFat);
        make.centerX.equalTo(self.kindDatumOurBackgroundView.mas_centerX);
    }];
    
    [self.handledLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.cubicConductorCiphersClickBit.mas_bottom).offset(HerLaunched.brownFairKin.afterYardFat);
        make.centerX.equalTo(self.kindDatumOurBackgroundView.mas_centerX);
        make.left.equalTo(self.kindDatumOurBackgroundView.mas_left).offset(HerLaunched.brownFairKin.scanAskCurl);
        make.right.equalTo(self.kindDatumOurBackgroundView.mas_right).offset(-HerLaunched.brownFairKin.scanAskCurl);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)callDetachText:(NSString *)text {
    self.handledLabel.text = text;
    
    
    CGFloat pastWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.handledLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[NiacinBigManager shared] bagHexStaticWindow];
    CGFloat extentsWidth = MIN(MAX(120, pastWidth + 2 * 8), window.bounds.size.width);
    [self.kindDatumOurBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(extentsWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)bordersDesignWindow {
    [self lazyBottomFaxVariationTrashLocalText:HerLaunched.pinCarOuterMan.outputYetHex];
}

+ (void)lazyBottomFaxVariationTrashLocalText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[NiacinBigManager shared] bagHexStaticWindow];
        
        if (!midSeeLawRollView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            midSeeLawRollView = [[PasteArrowView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            midSeeLawRollView.center = window.center;
        }
        if (!midSeeLawRollView.superview) {
            [window addSubview:midSeeLawRollView];
        }
        [midSeeLawRollView callDetachText:text];
        [midSeeLawRollView startAnimating];
    });
}

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


+ (PasteArrowView *)greenLoseMoreView:(UIView *)view {
    return [self greenLoseMoreView:view withText:HerLaunched.pinCarOuterMan.outputYetHex];
}

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

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

@end
