

#import "BirthLowerView.h"
#import "LazyFlowBecomeCell.h"
#import "UIImageView+WebCache.h"
#import "UIView+WebCache.h"

@interface BirthLowerView ()
@property (nonatomic, strong) UIImageView *guestCanadianImageView;
@end

@implementation BirthLowerView

- (void)ringFriendsRareParagraphHostingBigModel:(AreEldestOptInfo *)model {

    NSMutableArray *dance = [NSMutableArray new];
    for (int i = 0; i<model.busDrumPub; i++) {
        LazyFlowBecomeCell *each = [[LazyFlowBecomeCell alloc]init];
        each.dialogTarget = model.stringBlur;
        each.channelCount = 1;
        each.adjust = 6;
        each.lookTrySixAtom = CGFLOAT_MIN;
        CGRect tagsRect = [model.jumpStillFar boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:model.materialMotionPutFlippedSnowPeriodic] forKey:NSFontAttributeName] context:nil];
        each.unitTipSize = CGSizeMake(tagsRect.size.width+8, tagsRect.size.height+4);
        each.model = model;
        [dance addObject:each];
    }
    [self viewAppearSnow:dance];
}

- (void)attachTheResponderSlashFadeAffinitySentModel:(AreEldestOptInfo *)model {
    NSString *url = model.bagActiveBitSheStrategyOur;

    if (url.length == 0) {
        _guestCanadianImageView.hidden = YES;
        _guestCanadianImageView.image = nil;
        return;
    }

    UIImageView *own = self.guestCanadianImageView;
    own.hidden = NO;
    if (own.superview != self) {
        [self insertSubview:own atIndex:0];
    } else {
        [self sendSubviewToBack:own];
    }

    [own sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        if (image) [self ownerCoulombsImageView:own image:image];
    }];
}

- (void)ownerCoulombsImageView:(UIImageView *)own image:(UIImage *)image {
    CGFloat width = self.bounds.size.width;
    CGFloat height = self.bounds.size.height;
    if (image.size.width > 0) {
        CGFloat potential = image.size.height / image.size.width * width;
        
        CGFloat theIron = (height - potential) * 0.5;
        own.frame = CGRectMake(0, theIron, width, potential);
    } else {
        own.frame = self.bounds;
    }
}

- (UIImageView *)guestCanadianImageView {
    if (!_guestCanadianImageView) {
        _guestCanadianImageView = [[UIImageView alloc] init];
        _guestCanadianImageView.contentMode = UIViewContentModeScaleToFill;
        _guestCanadianImageView.userInteractionEnabled = NO;
        _guestCanadianImageView.clipsToBounds = NO;
    }
    return _guestCanadianImageView;
}


- (void)yetPostWebpagePictureNonceExpert {
    if (_guestCanadianImageView) {
        [_guestCanadianImageView sd_cancelLatestImageLoad];
        [_guestCanadianImageView removeFromSuperview];
        _guestCanadianImageView.image = nil;
        _guestCanadianImageView = nil;
    }
}

- (void)stop {
    [super stop];
    [self yetPostWebpagePictureNonceExpert];
}

- (void)removeFromSuperview {
    [self yetPostWebpagePictureNonceExpert];
    [super removeFromSuperview];
}

@end
