// // FKCircleProImgCell.m // FirstLink // // Created by jack on 16/6/12. // Copyright © 2016年 FirstLink. All rights reserved. // #import "FKCircleProImgCell.h" #import "FKCircleBestViewModel.h" #import "FKMyCircleViewModel.h" @interface FKCircleProImgCell () @property (nonatomic, strong) UIView *containerView; @property (nonatomic, strong) UIImageView *tagImgView; @end @implementation FKCircleProImgCell - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { [self addAllSubviews]; self.selectionStyle = UITableViewCellSelectionStyleNone; self.backgroundColor = [UIColor clearColor]; } return self; } - (void)addAllSubviews{ [self.contentView addSubview:self.containerView]; [self.containerView addSubview:self.proImgView]; [self.containerView addSubview:self.tagImgView]; [self.containerView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.insets(UIEdgeInsetsMake(0, 5, 0, 5)); }]; [self.proImgView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.insets(UIEdgeInsetsZero); }]; [self.tagImgView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.proImgView).offset(12); make.left.equalTo(self.proImgView).offset(15); }]; } - (void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath{ if ([viewModel isKindOfClass:[FKCircleBestViewModel class]]) { FKCircleBestViewModel *bestViewModel = (FKCircleBestViewModel *)viewModel; FKCircleContentItem *contentItem = [bestViewModel circleContentItemForIndexPath:indexPath]; [self.proImgView setImageWithURL:contentItem.shareItem.firstPicUrl cdnWidth:UISCREENWIDTH - 10]; NSInteger recLevel = contentItem.shareItem.recommendLevel.integerValue; self.tagImgView.hidden = (recLevel == 2 ? NO : YES); } if ([viewModel isKindOfClass:[FKMyCircleViewModel class]]) { FKMyCircleViewModel *myCircleModel = (FKMyCircleViewModel *)viewModel; FKMyCircleContentItem *contentItem = [myCircleModel circleContentItemAtIndex:indexPath.section - 1]; [self.proImgView setImageWithURL:contentItem.shareItem.firstPicUrl cdnWidth:UISCREENWIDTH - 10]; NSInteger recLevel = contentItem.shareItem.recommendLevel.integerValue; self.tagImgView.hidden = (recLevel == 2 ? NO : YES); } } + (CGFloat)imageHeight{ return UISCREENWIDTH - 10; } + (CGFloat)cellHeight{ return [self imageHeight]; } + (CGSize)imageSize{ return CGSizeMake(UISCREENWIDTH - 10, UISCREENWIDTH - 10); } - (UIImageView *)proImgView{ if (_proImgView == nil) { _proImgView = [[UIImageView alloc]init]; _proImgView.contentMode = UIViewContentModeScaleAspectFit; } return _proImgView; } - (UIView *)containerView{ if (_containerView == nil) { _containerView = [[UIView alloc]init]; _containerView.backgroundColor = [UIColor whiteColor]; } return _containerView; } - (UIImageView *)tagImgView{ if (_tagImgView == nil) { _tagImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"bestCircle_icon"]]; } return _tagImgView; } @end