// // DetailSourceCell.m // FirstLink // // Created by jack on 15/8/25. // Copyright (c) 2015年 FirstLink. All rights reserved. // #import "DetailSourceCell.h" @implementation DetailSourceCell - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { [self addAllSubviews]; self.selectionStyle = UITableViewCellSelectionStyleNone; } return self; } - (void)addAllSubviews{ [self.contentView addSubview:self.titleLabel]; [self.contentView addSubview:self.rightLabel]; [self.contentView addSubview:self.linkImgView]; [self.contentView addSubview:self.bottomLine]; self.topLine.hidden = YES; [self.topLine mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.contentView).offset(15); make.right.equalTo(self.contentView).offset(- 15); make.height.equalTo(@0.5); make.top.equalTo(self.contentView); }]; [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.contentView).offset(15); make.centerY.equalTo(self.contentView); }]; [self.linkImgView mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.contentView).offset(- 15); make.centerY.equalTo(self.contentView); }]; [self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.linkImgView.mas_left).offset(- 10); make.centerY.equalTo(self.contentView); }]; [self.bottomLine mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.contentView).offset(15); make.right.equalTo(self.contentView).offset(-15); make.bottom.equalTo(self.contentView); make.height.equalTo(@0.5); }]; } - (void)configWithDetailViewModel:(PindanDetailViewModel *)viewModel indexPath:(NSIndexPath *)indexPath{ kDetailCellType cellType = [viewModel cellTypeForIndexPath:indexPath]; if (cellType == kDetailCellTypeTransitLink) { self.rightLabel.text = @"商品原链接"; NSString *buyChannel = [viewModel buyChannel]; if ([buyChannel isKindOfClass:[NSString class]] && ![FLStringHelper isUrlString:buyChannel]){ // 如果不是Url显示出来 self.rightLabel.text = buyChannel; } }else if (cellType == kDetailCellTypeSpecGuige){ self.titleLabel.text = @"选择规格"; self.linkImgView.image = [UIImage imageNamed:@"Alpha3_more_icon"]; self.rightLabel.text = nil; self.bottomLine.hidden = YES; } } #pragma mark - property - (UILabel *)titleLabel { if (_titleLabel == nil) { _titleLabel = [[UILabel alloc]init]; _titleLabel.textColor = UIColorFromRGB(0x333333); _titleLabel.font = [UIFont systemFontOfSize:14]; _titleLabel.text = @"商品原链接"; } return _titleLabel; } - (UILabel *)rightLabel { if (_rightLabel == nil) { _rightLabel = [[UILabel alloc]init]; _rightLabel.textColor = UIColorFromRGB(0x999999); _rightLabel.font = [UIFont systemFontOfSize:14]; } return _rightLabel; } - (UIImageView *)linkImgView{ if (_linkImgView == nil) { _linkImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"detail_link"]]; } return _linkImgView; } - (UIView *)bottomLine { if (_bottomLine == nil) { _bottomLine = [[UIView alloc]init]; _bottomLine.backgroundColor = UIColorFromRGB(0xe5e5e5); } return _bottomLine; } @end