






#import "UndoFitBitView.h"
#import "StrictBigManager.h"
#import "AdverbTamil.h"
#import "Masonry.h"

@interface UndoFitBitView ()

@property (nonatomic, strong) UIView *replySymbolsBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *callEncryptedSmoothFlightException;
@property (nonatomic, strong) UILabel *funkSawLabel;
@end

@implementation UndoFitBitView


static UndoFitBitView *hostLemmaMindView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self stateView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self stateView];
    }
    return self;
}
- (void)stateView {
    
    
    self.replySymbolsBackgroundView = [UIView new];
    self.replySymbolsBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.replySymbolsBackgroundView.layer.cornerRadius = 2.0;
    self.replySymbolsBackgroundView.clipsToBounds = YES;
    [self addSubview:self.replySymbolsBackgroundView];
    
    
    self.callEncryptedSmoothFlightException = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.callEncryptedSmoothFlightException.color = AdverbTamil.sexCopperColor;
    [self.replySymbolsBackgroundView addSubview:self.callEncryptedSmoothFlightException];
    
    
    self.funkSawLabel = [[UILabel alloc] init];
    self.funkSawLabel.text = AdverbTamil.takeCellTagBus.liveIndirect;
    self.funkSawLabel.textColor = [UIColor whiteColor];
    self.funkSawLabel.font = [UIFont systemFontOfSize:14];
    self.funkSawLabel.numberOfLines = 0;
    self.funkSawLabel.textAlignment = NSTextAlignmentCenter;
    [self.replySymbolsBackgroundView addSubview:self.funkSawLabel];
    
    
    [self.replySymbolsBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(AdverbTamil.bedUndoReuse.addReuseIrish, AdverbTamil.bedUndoReuse.addReuseIrish));
        make.center.equalTo(self);
    }];
    
    [self.callEncryptedSmoothFlightException mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(AdverbTamil.bedUndoReuse.cupRectangle);
        make.centerX.equalTo(self.replySymbolsBackgroundView.mas_centerX);
    }];
    
    [self.funkSawLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.callEncryptedSmoothFlightException.mas_bottom).offset(AdverbTamil.bedUndoReuse.cupRectangle);
        make.centerX.equalTo(self.replySymbolsBackgroundView.mas_centerX);
        make.left.equalTo(self.replySymbolsBackgroundView.mas_left).offset(AdverbTamil.bedUndoReuse.smileWeight);
        make.right.equalTo(self.replySymbolsBackgroundView.mas_right).offset(-AdverbTamil.bedUndoReuse.smileWeight);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)allStepsonText:(NSString *)text {
    self.funkSawLabel.text = text;
    
    
    CGFloat joinWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.funkSawLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[StrictBigManager shared] criteriaPushWindow];
    CGFloat butUnitWidth = MIN(MAX(120, joinWidth + 2 * 8), window.bounds.size.width);
    [self.replySymbolsBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(butUnitWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)overhangRadixWindow {
    [self handlesSubmitPresenterEnergyTeluguProvinceText:AdverbTamil.takeCellTagBus.liveIndirect];
}

+ (void)handlesSubmitPresenterEnergyTeluguProvinceText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[StrictBigManager shared] criteriaPushWindow];
        
        if (!hostLemmaMindView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            hostLemmaMindView = [[UndoFitBitView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            hostLemmaMindView.center = window.center;
        }
        if (!hostLemmaMindView.superview) {
            [window addSubview:hostLemmaMindView];
        }
        [hostLemmaMindView allStepsonText:text];
        [hostLemmaMindView startAnimating];
    });
}

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


+ (UndoFitBitView *)flagExpectingView:(UIView *)view {
    return [self flagExpectingView:view withText:AdverbTamil.takeCellTagBus.liveIndirect];
}

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

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

@end
