






#import "BaseLookupView.h"
#import "OpaqueKeyManager.h"
#import "FrictionShe.h"
#import "Masonry.h"

@interface BaseLookupView ()

@property (nonatomic, strong) UIView *walkingStoodBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *limitedFreestyleSchedulerItsMonitored;
@property (nonatomic, strong) UILabel *fixFireLabel;
@end

@implementation BaseLookupView


static BaseLookupView *errorVisitHerView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self largeView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self largeView];
    }
    return self;
}
- (void)largeView {
    
    
    self.walkingStoodBackgroundView = [UIView new];
    self.walkingStoodBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.walkingStoodBackgroundView.layer.cornerRadius = 2.0;
    self.walkingStoodBackgroundView.clipsToBounds = YES;
    [self addSubview:self.walkingStoodBackgroundView];
    
    
    self.limitedFreestyleSchedulerItsMonitored = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.limitedFreestyleSchedulerItsMonitored.color = FrictionShe.collectorColor;
    [self.walkingStoodBackgroundView addSubview:self.limitedFreestyleSchedulerItsMonitored];
    
    
    self.fixFireLabel = [[UILabel alloc] init];
    self.fixFireLabel.text = FrictionShe.saltBurstFinal.pagerPlayTen;
    self.fixFireLabel.textColor = [UIColor whiteColor];
    self.fixFireLabel.font = [UIFont systemFontOfSize:14];
    self.fixFireLabel.numberOfLines = 0;
    self.fixFireLabel.textAlignment = NSTextAlignmentCenter;
    [self.walkingStoodBackgroundView addSubview:self.fixFireLabel];
    
    
    [self.walkingStoodBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(FrictionShe.headphoneMay.sonAppleRelay, FrictionShe.headphoneMay.sonAppleRelay));
        make.center.equalTo(self);
    }];
    
    [self.limitedFreestyleSchedulerItsMonitored mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(FrictionShe.headphoneMay.cloudHasGram);
        make.centerX.equalTo(self.walkingStoodBackgroundView.mas_centerX);
    }];
    
    [self.fixFireLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.limitedFreestyleSchedulerItsMonitored.mas_bottom).offset(FrictionShe.headphoneMay.cloudHasGram);
        make.centerX.equalTo(self.walkingStoodBackgroundView.mas_centerX);
        make.left.equalTo(self.walkingStoodBackgroundView.mas_left).offset(FrictionShe.headphoneMay.chainAccept);
        make.right.equalTo(self.walkingStoodBackgroundView.mas_right).offset(-FrictionShe.headphoneMay.chainAccept);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)decoderRawText:(NSString *)text {
    self.fixFireLabel.text = text;
    
    
    CGFloat mindWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.fixFireLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[OpaqueKeyManager shared] onlineResignWindow];
    CGFloat spacingWidth = MIN(MAX(120, mindWidth + 2 * 8), window.bounds.size.width);
    [self.walkingStoodBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(spacingWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)mergeMoleFeetWindow {
    [self sidebarYardDeciliterWrittenUnlearnRetainedText:FrictionShe.saltBurstFinal.pagerPlayTen];
}

+ (void)sidebarYardDeciliterWrittenUnlearnRetainedText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[OpaqueKeyManager shared] onlineResignWindow];
        
        if (!errorVisitHerView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            errorVisitHerView = [[BaseLookupView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            errorVisitHerView.center = window.center;
        }
        if (!errorVisitHerView.superview) {
            [window addSubview:errorVisitHerView];
        }
        [errorVisitHerView decoderRawText:text];
        [errorVisitHerView startAnimating];
    });
}

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


+ (BaseLookupView *)manBadSignMidView:(UIView *)view {
    return [self manBadSignMidView:view withText:FrictionShe.saltBurstFinal.pagerPlayTen];
}

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

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

@end
