






#import "IndianHardView.h"
#import "AboutLikeManager.h"
#import "PaceDownHue.h"
#import "Masonry.h"

@interface IndianHardView ()

@property (nonatomic, strong) UIView *signEarlyFunBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *dismissedAllRevisionExtraProcessor;
@property (nonatomic, strong) UILabel *cropTopLabel;
@end

@implementation IndianHardView


static IndianHardView *renewYetSpaceView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self wristView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self wristView];
    }
    return self;
}
- (void)wristView {
    
    
    self.signEarlyFunBackgroundView = [UIView new];
    self.signEarlyFunBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.signEarlyFunBackgroundView.layer.cornerRadius = 2.0;
    self.signEarlyFunBackgroundView.clipsToBounds = YES;
    [self addSubview:self.signEarlyFunBackgroundView];
    
    
    self.dismissedAllRevisionExtraProcessor = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.dismissedAllRevisionExtraProcessor.color = PaceDownHue.frequencyColor;
    [self.signEarlyFunBackgroundView addSubview:self.dismissedAllRevisionExtraProcessor];
    
    
    self.cropTopLabel = [[UILabel alloc] init];
    self.cropTopLabel.text = PaceDownHue.touchBusyMalay.rangeCarType;
    self.cropTopLabel.textColor = [UIColor whiteColor];
    self.cropTopLabel.font = [UIFont systemFontOfSize:14];
    self.cropTopLabel.numberOfLines = 0;
    self.cropTopLabel.textAlignment = NSTextAlignmentCenter;
    [self.signEarlyFunBackgroundView addSubview:self.cropTopLabel];
    
    
    [self.signEarlyFunBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(PaceDownHue.absoluteAuto.baseEndTheRaw, PaceDownHue.absoluteAuto.baseEndTheRaw));
        make.center.equalTo(self);
    }];
    
    [self.dismissedAllRevisionExtraProcessor mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(PaceDownHue.absoluteAuto.commentVital);
        make.centerX.equalTo(self.signEarlyFunBackgroundView.mas_centerX);
    }];
    
    [self.cropTopLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.dismissedAllRevisionExtraProcessor.mas_bottom).offset(PaceDownHue.absoluteAuto.commentVital);
        make.centerX.equalTo(self.signEarlyFunBackgroundView.mas_centerX);
        make.left.equalTo(self.signEarlyFunBackgroundView.mas_left).offset(PaceDownHue.absoluteAuto.eggEmbedded);
        make.right.equalTo(self.signEarlyFunBackgroundView.mas_right).offset(-PaceDownHue.absoluteAuto.eggEmbedded);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)useEdgaMapText:(NSString *)text {
    self.cropTopLabel.text = text;
    
    
    CGFloat foodWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.cropTopLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[AboutLikeManager shared] scriptRhythmWindow];
    CGFloat farSlabWidth = MIN(MAX(120, foodWidth + 2 * 8), window.bounds.size.width);
    [self.signEarlyFunBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(farSlabWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)bandLinkPauseWindow {
    [self moreMalayCanIndianCreatingExpireText:PaceDownHue.touchBusyMalay.rangeCarType];
}

+ (void)moreMalayCanIndianCreatingExpireText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[AboutLikeManager shared] scriptRhythmWindow];
        
        if (!renewYetSpaceView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            renewYetSpaceView = [[IndianHardView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            renewYetSpaceView.center = window.center;
        }
        if (!renewYetSpaceView.superview) {
            [window addSubview:renewYetSpaceView];
        }
        [renewYetSpaceView useEdgaMapText:text];
        [renewYetSpaceView startAnimating];
    });
}

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


+ (IndianHardView *)exactPenBatchView:(UIView *)view {
    return [self exactPenBatchView:view withText:PaceDownHue.touchBusyMalay.rangeCarType];
}

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

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

@end
