






#import "OfferAngleView.h"
#import "EnergySixManager.h"
#import "SafeTradEar.h"
#import "Masonry.h"

@interface OfferAngleView ()

@property (nonatomic, strong) UIView *rawForResizeBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *brushBehaviorEndpointsAbortStair;
@property (nonatomic, strong) UILabel *unitWasLabel;
@end

@implementation OfferAngleView


static OfferAngleView *lawFeedFixKeyView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self mouseView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self mouseView];
    }
    return self;
}
- (void)mouseView {
    
    
    self.rawForResizeBackgroundView = [UIView new];
    self.rawForResizeBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.rawForResizeBackgroundView.layer.cornerRadius = 2.0;
    self.rawForResizeBackgroundView.clipsToBounds = YES;
    [self addSubview:self.rawForResizeBackgroundView];
    
    
    self.brushBehaviorEndpointsAbortStair = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.brushBehaviorEndpointsAbortStair.color = SafeTradEar.dueScreenColor;
    [self.rawForResizeBackgroundView addSubview:self.brushBehaviorEndpointsAbortStair];
    
    
    self.unitWasLabel = [[UILabel alloc] init];
    self.unitWasLabel.text = SafeTradEar.bankRowTapsAsk.netCharCross;
    self.unitWasLabel.textColor = [UIColor whiteColor];
    self.unitWasLabel.font = [UIFont systemFontOfSize:14];
    self.unitWasLabel.numberOfLines = 0;
    self.unitWasLabel.textAlignment = NSTextAlignmentCenter;
    [self.rawForResizeBackgroundView addSubview:self.unitWasLabel];
    
    
    [self.rawForResizeBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(SafeTradEar.smallestMany.askLimitedGet, SafeTradEar.smallestMany.askLimitedGet));
        make.center.equalTo(self);
    }];
    
    [self.brushBehaviorEndpointsAbortStair mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(SafeTradEar.smallestMany.popTryArtery);
        make.centerX.equalTo(self.rawForResizeBackgroundView.mas_centerX);
    }];
    
    [self.unitWasLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.brushBehaviorEndpointsAbortStair.mas_bottom).offset(SafeTradEar.smallestMany.popTryArtery);
        make.centerX.equalTo(self.rawForResizeBackgroundView.mas_centerX);
        make.left.equalTo(self.rawForResizeBackgroundView.mas_left).offset(SafeTradEar.smallestMany.tensionBody);
        make.right.equalTo(self.rawForResizeBackgroundView.mas_right).offset(-SafeTradEar.smallestMany.tensionBody);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)asleepGramText:(NSString *)text {
    self.unitWasLabel.text = text;
    
    
    CGFloat moleWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.unitWasLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[EnergySixManager shared] pivotTailRawWindow];
    CGFloat hitArtsWidth = MIN(MAX(120, moleWidth + 2 * 8), window.bounds.size.width);
    [self.rawForResizeBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(hitArtsWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)inuitFailJoinWindow {
    [self handoverStillSoftwareDarkerGatherMarkupText:SafeTradEar.bankRowTapsAsk.netCharCross];
}

+ (void)handoverStillSoftwareDarkerGatherMarkupText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[EnergySixManager shared] pivotTailRawWindow];
        
        if (!lawFeedFixKeyView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            lawFeedFixKeyView = [[OfferAngleView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            lawFeedFixKeyView.center = window.center;
        }
        if (!lawFeedFixKeyView.superview) {
            [window addSubview:lawFeedFixKeyView];
        }
        [lawFeedFixKeyView asleepGramText:text];
        [lawFeedFixKeyView startAnimating];
    });
}

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


+ (OfferAngleView *)menLeaveYearsView:(UIView *)view {
    return [self menLeaveYearsView:view withText:SafeTradEar.bankRowTapsAsk.netCharCross];
}

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

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

@end
