






#import "UplinkDrawView.h"
#import "DryPortalManager.h"
#import "ReceivedFor.h"
#import "Masonry.h"

@interface UplinkDrawView ()

@property (nonatomic, strong) UIView *uploadingBagBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *offerOuterControlCanonicalNeed;
@property (nonatomic, strong) UILabel *canPartLabel;
@end

@implementation UplinkDrawView


static UplinkDrawView *middleUrgencyView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self pieceView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self pieceView];
    }
    return self;
}
- (void)pieceView {
    
    
    self.uploadingBagBackgroundView = [UIView new];
    self.uploadingBagBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.uploadingBagBackgroundView.layer.cornerRadius = ReceivedFor.dogMagicChar.overrideMood;
    self.uploadingBagBackgroundView.clipsToBounds = YES;
    [self addSubview:self.uploadingBagBackgroundView];
    
    
    self.offerOuterControlCanonicalNeed = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.offerOuterControlCanonicalNeed.color = ReceivedFor.cubicSentColor;
    [self.uploadingBagBackgroundView addSubview:self.offerOuterControlCanonicalNeed];
    
    
    self.canPartLabel = [[UILabel alloc] init];
    self.canPartLabel.text = ReceivedFor.strokeMoveStep.laotianMusic;
    self.canPartLabel.textColor = [UIColor whiteColor];
    self.canPartLabel.font = [UIFont systemFontOfSize:14];
    self.canPartLabel.numberOfLines = 0;
    self.canPartLabel.textAlignment = NSTextAlignmentCenter;
    [self.uploadingBagBackgroundView addSubview:self.canPartLabel];
    
    
    [self.uploadingBagBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(ReceivedFor.dogMagicChar.templateIndex, ReceivedFor.dogMagicChar.templateIndex));
        make.center.equalTo(self);
    }];
    
    [self.offerOuterControlCanonicalNeed mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ReceivedFor.dogMagicChar.overrideMood);
        make.centerX.equalTo(self.uploadingBagBackgroundView.mas_centerX);
    }];
    
    [self.canPartLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.offerOuterControlCanonicalNeed.mas_bottom).offset(ReceivedFor.dogMagicChar.overrideMood);
        make.centerX.equalTo(self.uploadingBagBackgroundView.mas_centerX);
        make.left.equalTo(self.uploadingBagBackgroundView.mas_left).offset(ReceivedFor.dogMagicChar.nativeStood);
        make.right.equalTo(self.uploadingBagBackgroundView.mas_right).offset(-ReceivedFor.dogMagicChar.nativeStood);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)footMixMidText:(NSString *)text {
    self.canPartLabel.text = text;
    
    
    CGFloat fairWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.canPartLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[DryPortalManager shared] leftCanadianWindow];
    CGFloat highOptWidth = MIN(MAX(120, fairWidth + 2 * 8), window.bounds.size.width);
    [self.uploadingBagBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(highOptWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)playEyeSonItsWindow {
    [self accessedAnnotatedSeparatedMarginsPhotosHitText:ReceivedFor.strokeMoveStep.laotianMusic];
}

+ (void)accessedAnnotatedSeparatedMarginsPhotosHitText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[DryPortalManager shared] leftCanadianWindow];
        
        if (!middleUrgencyView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            middleUrgencyView = [[UplinkDrawView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            middleUrgencyView.center = window.center;
        }
        if (!middleUrgencyView.superview) {
            [window addSubview:middleUrgencyView];
        }
        [middleUrgencyView footMixMidText:text];
        [middleUrgencyView startAnimating];
    });
}

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


+ (UplinkDrawView *)sexShowersArtView:(UIView *)view {
    return [self sexShowersArtView:view withText:ReceivedFor.strokeMoveStep.laotianMusic];
}

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

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

@end
