






#import "FitCalorieView.h"
#import "KeysVoiceManager.h"
#import "SubBondFour.h"
#import "Masonry.h"

@interface FitCalorieView ()

@property (nonatomic, strong) UIView *kitUsageMileBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *engineerLongestCloudyCompressFood;
@property (nonatomic, strong) UILabel *regionsLabel;
@end

@implementation FitCalorieView


static FitCalorieView *footTagAnyTipView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self rotorView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self rotorView];
    }
    return self;
}
- (void)rotorView {
    
    
    self.kitUsageMileBackgroundView = [UIView new];
    self.kitUsageMileBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.kitUsageMileBackgroundView.layer.cornerRadius = 2.0;
    self.kitUsageMileBackgroundView.clipsToBounds = YES;
    [self addSubview:self.kitUsageMileBackgroundView];
    
    
    self.engineerLongestCloudyCompressFood = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.engineerLongestCloudyCompressFood.color = SubBondFour.routeHeapColor;
    [self.kitUsageMileBackgroundView addSubview:self.engineerLongestCloudyCompressFood];
    
    
    self.regionsLabel = [[UILabel alloc] init];
    self.regionsLabel.text = SubBondFour.injectionBlack.sentencesCap;
    self.regionsLabel.textColor = [UIColor whiteColor];
    self.regionsLabel.font = [UIFont systemFontOfSize:14];
    self.regionsLabel.numberOfLines = 0;
    self.regionsLabel.textAlignment = NSTextAlignmentCenter;
    [self.kitUsageMileBackgroundView addSubview:self.regionsLabel];
    
    
    [self.kitUsageMileBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(SubBondFour.nodeFourteen.idleProcessor, SubBondFour.nodeFourteen.idleProcessor));
        make.center.equalTo(self);
    }];
    
    [self.engineerLongestCloudyCompressFood mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(SubBondFour.nodeFourteen.chainLastSob);
        make.centerX.equalTo(self.kitUsageMileBackgroundView.mas_centerX);
    }];
    
    [self.regionsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.engineerLongestCloudyCompressFood.mas_bottom).offset(SubBondFour.nodeFourteen.chainLastSob);
        make.centerX.equalTo(self.kitUsageMileBackgroundView.mas_centerX);
        make.left.equalTo(self.kitUsageMileBackgroundView.mas_left).offset(SubBondFour.nodeFourteen.tagWetTorch);
        make.right.equalTo(self.kitUsageMileBackgroundView.mas_right).offset(-SubBondFour.nodeFourteen.tagWetTorch);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)laotianEyeText:(NSString *)text {
    self.regionsLabel.text = text;
    
    
    CGFloat fileWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.regionsLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[KeysVoiceManager shared] kilobitsClipWindow];
    CGFloat sobFactWidth = MIN(MAX(120, fileWidth + 2 * 8), window.bounds.size.width);
    [self.kitUsageMileBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(sobFactWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)waistEraThreeWindow {
    [self balticLocaleMoireFeaturedSlideVariationText:SubBondFour.injectionBlack.sentencesCap];
}

+ (void)balticLocaleMoireFeaturedSlideVariationText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[KeysVoiceManager shared] kilobitsClipWindow];
        
        if (!footTagAnyTipView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            footTagAnyTipView = [[FitCalorieView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            footTagAnyTipView.center = window.center;
        }
        if (!footTagAnyTipView.superview) {
            [window addSubview:footTagAnyTipView];
        }
        [footTagAnyTipView laotianEyeText:text];
        [footTagAnyTipView startAnimating];
    });
}

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


+ (FitCalorieView *)irishDenseHueView:(UIView *)view {
    return [self irishDenseHueView:view withText:SubBondFour.injectionBlack.sentencesCap];
}

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

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

@end
