// // FKProActivityInProgressCell.m // FirstLink // // Created by ascii on 2016/11/11. // Copyright © 2016年 FirstLink. All rights reserved. // #import "FKProActivityInProgressCell.h" #import "FKProDetailViewModel.h" #import "FLStringHelper.h" @implementation FKProActivityInProgressCell /* // Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation. - (void)drawRect:(CGRect)rect { // Drawing code } */ - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { [self addAllSubviews]; } return self; } - (void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath { if ([viewModel isKindOfClass:[FKProDetailViewModel class]]) { FKProDetailViewModel *detailModel = (FKProDetailViewModel*)viewModel; [self.leftIconView sd_setImageWithURL:[NSURL URLWithString:detailModel.dataItem.promotionItem.iconURL]]; self.titleLabel.text = @"限时活动抢购中"; self.countDownView.descLabel.text = @"距结束时间:"; NSTimeInterval serverTime = [FLStringHelper timeIntervalFromString:detailModel.dataItem.serverTime]; NSTimeInterval endTime = [FLStringHelper timeIntervalFromString:detailModel.dataItem.promotionItem.endTime]; [self.countDownView startWithTimeInterval:(endTime - serverTime)]; } } #pragma mark - Layout - (void)addAllSubviews { [self.contentView addSubview:self.leftIconView]; [self.leftIconView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.top.bottom.equalTo(self.contentView); make.width.mas_equalTo(60); }]; [self.contentView addSubview:self.countDownView]; [self.countDownView mas_makeConstraints:^(MASConstraintMaker *make) { make.right.top.bottom.equalTo(self.contentView); make.width.mas_equalTo([FKProActivityBaseCell countDownViewWidth]); }]; [self.contentView addSubview:self.titleLabel]; [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.leftIconView.mas_right).offset(4); make.right.equalTo(self.countDownView.mas_left).offset(-12); make.centerY.equalTo(self.contentView); }]; } #pragma mark - Property @end