






#import "RespondHowView.h"
#import "AutoIntroManager.h"
#import "WinSubAbove.h"
#import "Masonry.h"

@interface RespondHowView ()

@property (nonatomic, strong) UIView *genreSpecialBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *preferredCatalogRawHisFormat;
@property (nonatomic, strong) UILabel *dogHintLabel;
@end

@implementation RespondHowView


static RespondHowView *visionEntropyView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self slantView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self slantView];
    }
    return self;
}
- (void)slantView {
    
    
    self.genreSpecialBackgroundView = [UIView new];
    self.genreSpecialBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.genreSpecialBackgroundView.layer.cornerRadius = WinSubAbove.swipeFlagDay.zipCacheEnds;
    self.genreSpecialBackgroundView.clipsToBounds = YES;
    [self addSubview:self.genreSpecialBackgroundView];
    
    
    self.preferredCatalogRawHisFormat = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.preferredCatalogRawHisFormat.color = WinSubAbove.nearbyAreColor;
    [self.genreSpecialBackgroundView addSubview:self.preferredCatalogRawHisFormat];
    
    
    self.dogHintLabel = [[UILabel alloc] init];
    self.dogHintLabel.text = WinSubAbove.resourcesCanon.hitEggFunnel;
    self.dogHintLabel.textColor = [UIColor whiteColor];
    self.dogHintLabel.font = [UIFont systemFontOfSize:14];
    self.dogHintLabel.numberOfLines = 0;
    self.dogHintLabel.textAlignment = NSTextAlignmentCenter;
    [self.genreSpecialBackgroundView addSubview:self.dogHintLabel];
    
    
    [self.genreSpecialBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(WinSubAbove.swipeFlagDay.pauseShowLook, WinSubAbove.swipeFlagDay.pauseShowLook));
        make.center.equalTo(self);
    }];
    
    [self.preferredCatalogRawHisFormat mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(WinSubAbove.swipeFlagDay.zipCacheEnds);
        make.centerX.equalTo(self.genreSpecialBackgroundView.mas_centerX);
    }];
    
    [self.dogHintLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.preferredCatalogRawHisFormat.mas_bottom).offset(WinSubAbove.swipeFlagDay.zipCacheEnds);
        make.centerX.equalTo(self.genreSpecialBackgroundView.mas_centerX);
        make.left.equalTo(self.genreSpecialBackgroundView.mas_left).offset(WinSubAbove.swipeFlagDay.peakGrammar);
        make.right.equalTo(self.genreSpecialBackgroundView.mas_right).offset(-WinSubAbove.swipeFlagDay.peakGrammar);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)proceedBedText:(NSString *)text {
    self.dogHintLabel.text = text;
    
    
    CGFloat pushWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.dogHintLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[AutoIntroManager shared] drySlightBagWindow];
    CGFloat gallonsWidth = MIN(MAX(120, pushWidth + 2 * 8), window.bounds.size.width);
    [self.genreSpecialBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(gallonsWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)discardedBoldWindow {
    [self rationalMetadataIntegrityAfterYetEpisodeText:WinSubAbove.resourcesCanon.hitEggFunnel];
}

+ (void)rationalMetadataIntegrityAfterYetEpisodeText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[AutoIntroManager shared] drySlightBagWindow];
        
        if (!visionEntropyView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            visionEntropyView = [[RespondHowView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            visionEntropyView.center = window.center;
        }
        if (!visionEntropyView.superview) {
            [window addSubview:visionEntropyView];
        }
        [visionEntropyView proceedBedText:text];
        [visionEntropyView startAnimating];
    });
}

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


+ (RespondHowView *)causeTapVideoView:(UIView *)view {
    return [self causeTapVideoView:view withText:WinSubAbove.resourcesCanon.hitEggFunnel];
}

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

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

@end
