






#import "BeganHeartView.h"
#import "ManualCupManager.h"
#import "ReloadThird.h"
#import "Masonry.h"

@interface BeganHeartView ()

@property (nonatomic, strong) UIView *sobLeadMusicBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *delayRestoringDuplexActivateSimple;
@property (nonatomic, strong) UILabel *mixPeakLabel;
@end

@implementation BeganHeartView


static BeganHeartView *chunkStopFoodView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self adobeView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self adobeView];
    }
    return self;
}
- (void)adobeView {
    
    
    self.sobLeadMusicBackgroundView = [UIView new];
    self.sobLeadMusicBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.sobLeadMusicBackgroundView.layer.cornerRadius = ReloadThird.overlapQuote.drivenEndLog;
    self.sobLeadMusicBackgroundView.clipsToBounds = YES;
    [self addSubview:self.sobLeadMusicBackgroundView];
    
    
    self.delayRestoringDuplexActivateSimple = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.delayRestoringDuplexActivateSimple.color = ReloadThird.fairBlockColor;
    [self.sobLeadMusicBackgroundView addSubview:self.delayRestoringDuplexActivateSimple];
    
    
    self.mixPeakLabel = [[UILabel alloc] init];
    self.mixPeakLabel.text = ReloadThird.phoneKitTenTen.stampIndexes;
    self.mixPeakLabel.textColor = [UIColor whiteColor];
    self.mixPeakLabel.font = [UIFont systemFontOfSize:14];
    self.mixPeakLabel.numberOfLines = 0;
    self.mixPeakLabel.textAlignment = NSTextAlignmentCenter;
    [self.sobLeadMusicBackgroundView addSubview:self.mixPeakLabel];
    
    
    [self.sobLeadMusicBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(ReloadThird.overlapQuote.queueStarAxes, ReloadThird.overlapQuote.queueStarAxes));
        make.center.equalTo(self);
    }];
    
    [self.delayRestoringDuplexActivateSimple mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ReloadThird.overlapQuote.drivenEndLog);
        make.centerX.equalTo(self.sobLeadMusicBackgroundView.mas_centerX);
    }];
    
    [self.mixPeakLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.delayRestoringDuplexActivateSimple.mas_bottom).offset(ReloadThird.overlapQuote.drivenEndLog);
        make.centerX.equalTo(self.sobLeadMusicBackgroundView.mas_centerX);
        make.left.equalTo(self.sobLeadMusicBackgroundView.mas_left).offset(ReloadThird.overlapQuote.vortexStair);
        make.right.equalTo(self.sobLeadMusicBackgroundView.mas_right).offset(-ReloadThird.overlapQuote.vortexStair);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)fixCallingText:(NSString *)text {
    self.mixPeakLabel.text = text;
    
    
    CGFloat meanWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.mixPeakLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[ManualCupManager shared] paperMillOptWindow];
    CGFloat centralWidth = MIN(MAX(120, meanWidth + 2 * 8), window.bounds.size.width);
    [self.sobLeadMusicBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(centralWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)binaryIndicesWindow {
    [self resourcesSpringClientsGreekRedirectCommentsText:ReloadThird.phoneKitTenTen.stampIndexes];
}

+ (void)resourcesSpringClientsGreekRedirectCommentsText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[ManualCupManager shared] paperMillOptWindow];
        
        if (!chunkStopFoodView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            chunkStopFoodView = [[BeganHeartView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            chunkStopFoodView.center = window.center;
        }
        if (!chunkStopFoodView.superview) {
            [window addSubview:chunkStopFoodView];
        }
        [chunkStopFoodView fixCallingText:text];
        [chunkStopFoodView startAnimating];
    });
}

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


+ (BeganHeartView *)fatOffCaseFatView:(UIView *)view {
    return [self fatOffCaseFatView:view withText:ReloadThird.phoneKitTenTen.stampIndexes];
}

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

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

@end
