説明なし

FKCirDetailRecommendCell.m 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. //
  2. // FKCirDetailRecommendCell.m
  3. // FirstLink
  4. //
  5. // Created by jack on 16/6/14.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKCirDetailRecommendCell.h"
  9. #import "FKCircleDetailViewModel.h"
  10. @interface FKCirDetailRecommendCell ()
  11. @property (nonatomic, strong) UIView *vertLine;
  12. @property (nonatomic, strong) UILabel *timeLabel;
  13. @property (nonatomic, strong) UILabel *titleLabel;
  14. @property (nonatomic, strong) UILabel *descLabel;
  15. @end
  16. @implementation FKCirDetailRecommendCell
  17. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  18. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  19. [self addAllSubviews];
  20. self.selectionStyle = UITableViewCellSelectionStyleNone;
  21. self.contentView.backgroundColor = [UIColor whiteColor];
  22. }
  23. return self;
  24. }
  25. - (void)addAllSubviews{
  26. [self.contentView addSubview:self.vertLine];
  27. [self.contentView addSubview:self.timeLabel];
  28. [self.contentView addSubview:self.titleLabel];
  29. [self.contentView addSubview:self.descLabel];
  30. [self.vertLine mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.left.equalTo(self.contentView).offset(15);
  32. make.top.equalTo(self.contentView).offset(20);
  33. make.size.mas_equalTo(CGSizeMake(3, 13));
  34. }];
  35. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.left.equalTo(self.vertLine.mas_right).offset(6);
  37. make.centerY.equalTo(self.vertLine);
  38. }];
  39. [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.left.equalTo(self.titleLabel.mas_right).offset(12);
  41. make.centerY.equalTo(self.titleLabel);
  42. }];
  43. [self.descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.left.equalTo(self.vertLine);
  45. make.right.equalTo(self.contentView).offset(- 15);
  46. make.top.equalTo(self.vertLine.mas_bottom).offset(15);
  47. }];
  48. }
  49. - (void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath{
  50. if ([viewModel isKindOfClass:[FKCircleDetailViewModel class]]) {
  51. FKCircleDetailViewModel *cirViewModel = (FKCircleDetailViewModel *)viewModel;
  52. FKCircleShareItem *shareItem = cirViewModel.dataItem.shareItem;
  53. if (shareItem){
  54. if ([shareItem getCircleType] == kCircleTypeUserShare) {
  55. self.titleLabel.text = @"晒单推荐";
  56. self.vertLine.backgroundColor = UIColorFromRGB(0xf5a623);
  57. }else if ([shareItem getCircleType] == kCircleTypeInfoShare){
  58. self.titleLabel.text = @"种草资讯";
  59. self.vertLine.backgroundColor = UIColorFromRGB(0xff6362);
  60. }
  61. self.timeLabel.text = [FLStringHelper convertToCommonFormateFromString:shareItem.createTime baseTime:cirViewModel.dataItem.serveTime];
  62. self.descLabel.text = shareItem.title;
  63. }
  64. }
  65. }
  66. + (CGFloat)cellHeigthForDesc:(NSString *)desc{
  67. if (!desc.length) return 43;
  68. CGFloat descH = [FLStringHelper rectOfString:desc
  69. font:[UIFont systemFontOfSize:14]
  70. width:UISCREENWIDTH - 30].size.height;
  71. return descH + 60;
  72. }
  73. #pragma mark - property
  74. - (UILabel *)titleLabel{
  75. if (_titleLabel == nil) {
  76. _titleLabel = [[UILabel alloc]init];
  77. _titleLabel.textColor = UIColorFromRGB(0x333333);
  78. _titleLabel.font = [UIFont systemFontOfSize:13];
  79. }
  80. return _titleLabel;
  81. }
  82. - (UILabel *)descLabel{
  83. if (_descLabel == nil) {
  84. _descLabel = [[UILabel alloc]init];
  85. _descLabel.textColor = UIColorFromRGB(0x262626);
  86. _descLabel.font = [UIFont systemFontOfSize:15];
  87. _descLabel.numberOfLines = 0;
  88. }
  89. return _descLabel;
  90. }
  91. - (UILabel *)timeLabel{
  92. if (_timeLabel == nil) {
  93. _timeLabel = [[UILabel alloc]init];
  94. _timeLabel.textColor = UIColorFromRGB(0x9b9b9b);
  95. _timeLabel.font = [UIFont systemFontOfSize:13];
  96. }
  97. return _timeLabel;
  98. }
  99. - (UIView *)vertLine{
  100. if (_vertLine == nil) {
  101. _vertLine = [[UIView alloc]init];
  102. _vertLine.backgroundColor = [UIColor redColor];
  103. }
  104. return _vertLine;
  105. }
  106. @end