123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- //
- // FKCirDetailRecommendCell.m
- // FirstLink
- //
- // Created by jack on 16/6/14.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKCirDetailRecommendCell.h"
- #import "FKCircleDetailViewModel.h"
- @interface FKCirDetailRecommendCell ()
- @property (nonatomic, strong) UIView *vertLine;
- @property (nonatomic, strong) UILabel *timeLabel;
- @property (nonatomic, strong) UILabel *titleLabel;
- @property (nonatomic, strong) UILabel *descLabel;
- @end
- @implementation FKCirDetailRecommendCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
-
- [self addAllSubviews];
- self.selectionStyle = UITableViewCellSelectionStyleNone;
- self.contentView.backgroundColor = [UIColor whiteColor];
- }
- return self;
- }
- - (void)addAllSubviews{
- [self.contentView addSubview:self.vertLine];
- [self.contentView addSubview:self.timeLabel];
- [self.contentView addSubview:self.titleLabel];
- [self.contentView addSubview:self.descLabel];
- [self.vertLine mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).offset(15);
- make.top.equalTo(self.contentView).offset(20);
- make.size.mas_equalTo(CGSizeMake(3, 13));
- }];
-
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.vertLine.mas_right).offset(6);
- make.centerY.equalTo(self.vertLine);
- }];
-
- [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.titleLabel.mas_right).offset(12);
- make.centerY.equalTo(self.titleLabel);
- }];
-
- [self.descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.vertLine);
- make.right.equalTo(self.contentView).offset(- 15);
- make.top.equalTo(self.vertLine.mas_bottom).offset(15);
- }];
- }
- - (void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath{
- if ([viewModel isKindOfClass:[FKCircleDetailViewModel class]]) {
- FKCircleDetailViewModel *cirViewModel = (FKCircleDetailViewModel *)viewModel;
- FKCircleShareItem *shareItem = cirViewModel.dataItem.shareItem;
- if (shareItem){
- if ([shareItem getCircleType] == kCircleTypeUserShare) {
- self.titleLabel.text = @"晒单推荐";
- self.vertLine.backgroundColor = UIColorFromRGB(0xf5a623);
- }else if ([shareItem getCircleType] == kCircleTypeInfoShare){
- self.titleLabel.text = @"种草资讯";
- self.vertLine.backgroundColor = UIColorFromRGB(0xff6362);
- }
-
- self.timeLabel.text = [FLStringHelper convertToCommonFormateFromString:shareItem.createTime baseTime:cirViewModel.dataItem.serveTime];
- self.descLabel.text = shareItem.title;
- }
- }
- }
- + (CGFloat)cellHeigthForDesc:(NSString *)desc{
-
- if (!desc.length) return 43;
-
- CGFloat descH = [FLStringHelper rectOfString:desc
- font:[UIFont systemFontOfSize:14]
- width:UISCREENWIDTH - 30].size.height;
- return descH + 60;
- }
- #pragma mark - property
- - (UILabel *)titleLabel{
- if (_titleLabel == nil) {
- _titleLabel = [[UILabel alloc]init];
- _titleLabel.textColor = UIColorFromRGB(0x333333);
- _titleLabel.font = [UIFont systemFontOfSize:13];
- }
- return _titleLabel;
- }
- - (UILabel *)descLabel{
- if (_descLabel == nil) {
- _descLabel = [[UILabel alloc]init];
- _descLabel.textColor = UIColorFromRGB(0x262626);
- _descLabel.font = [UIFont systemFontOfSize:15];
- _descLabel.numberOfLines = 0;
- }
- return _descLabel;
- }
- - (UILabel *)timeLabel{
- if (_timeLabel == nil) {
- _timeLabel = [[UILabel alloc]init];
- _timeLabel.textColor = UIColorFromRGB(0x9b9b9b);
- _timeLabel.font = [UIFont systemFontOfSize:13];
- }
- return _timeLabel;
- }
- - (UIView *)vertLine{
- if (_vertLine == nil) {
- _vertLine = [[UIView alloc]init];
- _vertLine.backgroundColor = [UIColor redColor];
- }
- return _vertLine;
- }
- @end
|