






#import "SerialLossView.h"
#import "RelevanceManager.h"
#import "FixChunkBad.h"
#import "Masonry.h"

@interface SerialLossView ()

@property (nonatomic, strong) UIView *mapBusLargerBackgroundView;
@property (nonatomic, strong) UIActivityIndicatorView *topUnwrapShowersCanUsage;
@property (nonatomic, strong) UILabel *pairSumLabel;
@end

@implementation SerialLossView


static SerialLossView *beforeLexiconView = nil;



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self thickView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self thickView];
    }
    return self;
}
- (void)thickView {
    
    
    self.mapBusLargerBackgroundView = [UIView new];
    self.mapBusLargerBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.mapBusLargerBackgroundView.layer.cornerRadius = 2.0;
    self.mapBusLargerBackgroundView.clipsToBounds = YES;
    [self addSubview:self.mapBusLargerBackgroundView];
    
    
    self.topUnwrapShowersCanUsage = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
    self.topUnwrapShowersCanUsage.color = FixChunkBad.topOpaqueColor;
    [self.mapBusLargerBackgroundView addSubview:self.topUnwrapShowersCanUsage];
    
    
    self.pairSumLabel = [[UILabel alloc] init];
    self.pairSumLabel.text = FixChunkBad.passLazyUnique.tabArtTelugu;
    self.pairSumLabel.textColor = [UIColor whiteColor];
    self.pairSumLabel.font = [UIFont systemFontOfSize:14];
    self.pairSumLabel.numberOfLines = 0;
    self.pairSumLabel.textAlignment = NSTextAlignmentCenter;
    [self.mapBusLargerBackgroundView addSubview:self.pairSumLabel];
    
    
    [self.mapBusLargerBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(FixChunkBad.swedishTwist.exactSampling, FixChunkBad.swedishTwist.exactSampling));
        make.center.equalTo(self);
    }];
    
    [self.topUnwrapShowersCanUsage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(FixChunkBad.swedishTwist.dryAddChrome);
        make.centerX.equalTo(self.mapBusLargerBackgroundView.mas_centerX);
    }];
    
    [self.pairSumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.topUnwrapShowersCanUsage.mas_bottom).offset(FixChunkBad.swedishTwist.dryAddChrome);
        make.centerX.equalTo(self.mapBusLargerBackgroundView.mas_centerX);
        make.left.equalTo(self.mapBusLargerBackgroundView.mas_left).offset(FixChunkBad.swedishTwist.youngerSend);
        make.right.equalTo(self.mapBusLargerBackgroundView.mas_right).offset(-FixChunkBad.swedishTwist.youngerSend);
    }];
    
    
    self.hidden = YES;
}



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

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

- (void)nearestBitText:(NSString *)text {
    self.pairSumLabel.text = text;
    
    
    CGFloat likeWidth = [text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName: self.pairSumLabel.font}
                                          context:nil].size.width;
    UIWindow *window = [[RelevanceManager shared] ropeAnimatorWindow];
    CGFloat countryWidth = MIN(MAX(120, likeWidth + 2 * 8), window.bounds.size.width);
    [self.mapBusLargerBackgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(countryWidth);
    }];
    
    [self layoutIfNeeded];
}


+ (void)loopsMirroredWindow {
    [self badStructureBedPriceSubsetFrenchText:FixChunkBad.passLazyUnique.tabArtTelugu];
}

+ (void)badStructureBedPriceSubsetFrenchText:(NSString *)text {
    dispatch_async(dispatch_get_main_queue(), ^{
        UIWindow *window = [[RelevanceManager shared] ropeAnimatorWindow];
        
        if (!beforeLexiconView) {
            CGSize size = UIScreen.mainScreen.bounds.size;
            beforeLexiconView = [[SerialLossView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            beforeLexiconView.center = window.center;
        }
        if (!beforeLexiconView.superview) {
            [window addSubview:beforeLexiconView];
        }
        [beforeLexiconView nearestBitText:text];
        [beforeLexiconView startAnimating];
    });
}

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


+ (SerialLossView *)rawSlantAloneView:(UIView *)view {
    return [self rawSlantAloneView:view withText:FixChunkBad.passLazyUnique.tabArtTelugu];
}

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

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

@end
