






#import "DoneBasqueView.h"
#import "BalticFixManager.h"
#import "BinFaxEight.h"
#import "Masonry.h"

@interface DoneBasqueView ()

@property (nonatomic, strong) UIView *anyPullPriceBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *actionsBothPlugMisplacedRest;
@property (nonatomic, strong) UILabel *swappedLabel;
@end

@implementation DoneBasqueView


static DoneBasqueView *fontScheduledView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self genreView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self genreView];
    }
    return self;
}
- (void)genreView {
    
    
    self.anyPullPriceBackgroundView = [UIView new];
    self.anyPullPriceBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.anyPullPriceBackgroundView.layer.cornerRadius = BinFaxEight.icyAboutDrum.canTagEleven;
    self.anyPullPriceBackgroundView.clipsToBounds = YES;
    [self addSubview:self.anyPullPriceBackgroundView];
    
    
    self.actionsBothPlugMisplacedRest = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.actionsBothPlugMisplacedRest.color = BinFaxEight.indentJobColor;
    [self.anyPullPriceBackgroundView addSubview:self.actionsBothPlugMisplacedRest];
    
    
    self.swappedLabel = [[UILabel alloc] init];
    self.swappedLabel.text = BinFaxEight.signRoomModify.foundArmMenu;
    self.swappedLabel.textColor = [UIColor whiteColor];
    self.swappedLabel.font = [UIFont systemFontOfSize:14];
    self.swappedLabel.numberOfLines = 0;
    self.swappedLabel.textAlignment = NSTextAlignmentCenter;
    [self.anyPullPriceBackgroundView addSubview:self.swappedLabel];
    
    
    [self.anyPullPriceBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(BinFaxEight.icyAboutDrum.icyAllPassIll, BinFaxEight.icyAboutDrum.icyAllPassIll));
        make.center.equalTo(self);
    }];
    
    [self.actionsBothPlugMisplacedRest mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(BinFaxEight.icyAboutDrum.canTagEleven);
        make.centerX.equalTo(self.anyPullPriceBackgroundView.mas_centerX);
    }];
    
    [self.swappedLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.actionsBothPlugMisplacedRest.mas_bottom).offset(BinFaxEight.icyAboutDrum.canTagEleven);
        make.centerX.equalTo(self.anyPullPriceBackgroundView.mas_centerX);
        make.left.equalTo(self.anyPullPriceBackgroundView.mas_left).offset(BinFaxEight.icyAboutDrum.howShakeSix);
        make.right.equalTo(self.anyPullPriceBackgroundView.mas_right).offset(-BinFaxEight.icyAboutDrum.howShakeSix);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)firstShapeText:(NSString *)text {
    self.swappedLabel.text = text;
    
    
    CGFloat justWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.swappedLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[BalticFixManager shared] plateSuchRetWindow];
    CGFloat kitGoalWidth = MIN(MAX(120, justWidth + 2 * 8), window.bounds.size.width);
    [self.anyPullPriceBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(kitGoalWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)makeNeedBreakWindow {
    [self excludedResponsesRetainedPerformerMediaSymbolicText:BinFaxEight.signRoomModify.foundArmMenu];
}

+ (void)excludedResponsesRetainedPerformerMediaSymbolicText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[BalticFixManager shared] plateSuchRetWindow];
        
        if (!fontScheduledView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            fontScheduledView = [[DoneBasqueView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            fontScheduledView.center = window.center;
        }
        if (!fontScheduledView.superview) {
            [window addSubview:fontScheduledView];
        }
        [fontScheduledView firstShapeText:text];
        [fontScheduledView startAnimating];
    });
}

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


+ (DoneBasqueView *)lowSayPopSeedView:(UIView *)view {
    return [self lowSayPopSeedView:view withText:BinFaxEight.signRoomModify.foundArmMenu];
}

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

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

@end
