Brak opisu

DetailSourceCell.m 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //
  2. // DetailSourceCell.m
  3. // FirstLink
  4. //
  5. // Created by jack on 15/8/25.
  6. // Copyright (c) 2015年 FirstLink. All rights reserved.
  7. //
  8. #import "DetailSourceCell.h"
  9. @implementation DetailSourceCell
  10. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  11. {
  12. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  13. if (self) {
  14. [self addAllSubviews];
  15. self.selectionStyle = UITableViewCellSelectionStyleNone;
  16. }
  17. return self;
  18. }
  19. - (void)addAllSubviews{
  20. [self.contentView addSubview:self.titleLabel];
  21. [self.contentView addSubview:self.rightLabel];
  22. [self.contentView addSubview:self.linkImgView];
  23. [self.contentView addSubview:self.bottomLine];
  24. self.topLine.hidden = YES;
  25. [self.topLine mas_makeConstraints:^(MASConstraintMaker *make) {
  26. make.left.equalTo(self.contentView).offset(15);
  27. make.right.equalTo(self.contentView).offset(- 15);
  28. make.height.equalTo(@0.5);
  29. make.top.equalTo(self.contentView);
  30. }];
  31. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  32. make.left.equalTo(self.contentView).offset(15);
  33. make.centerY.equalTo(self.contentView);
  34. }];
  35. [self.linkImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.right.equalTo(self.contentView).offset(- 15);
  37. make.centerY.equalTo(self.contentView);
  38. }];
  39. [self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.right.equalTo(self.linkImgView.mas_left).offset(- 10);
  41. make.centerY.equalTo(self.contentView);
  42. }];
  43. [self.bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.left.equalTo(self.contentView).offset(15);
  45. make.right.equalTo(self.contentView).offset(-15);
  46. make.bottom.equalTo(self.contentView);
  47. make.height.equalTo(@0.5);
  48. }];
  49. }
  50. - (void)configWithDetailViewModel:(PindanDetailViewModel *)viewModel indexPath:(NSIndexPath *)indexPath{
  51. kDetailCellType cellType = [viewModel cellTypeForIndexPath:indexPath];
  52. if (cellType == kDetailCellTypeTransitLink) {
  53. self.rightLabel.text = @"商品原链接";
  54. NSString *buyChannel = [viewModel buyChannel];
  55. if ([buyChannel isKindOfClass:[NSString class]] && ![FLStringHelper isUrlString:buyChannel]){
  56. // 如果不是Url显示出来
  57. self.rightLabel.text = buyChannel;
  58. }
  59. }else if (cellType == kDetailCellTypeSpecGuige){
  60. self.titleLabel.text = @"选择规格";
  61. self.linkImgView.image = [UIImage imageNamed:@"Alpha3_more_icon"];
  62. self.rightLabel.text = nil;
  63. self.bottomLine.hidden = YES;
  64. }
  65. }
  66. #pragma mark - property
  67. - (UILabel *)titleLabel
  68. {
  69. if (_titleLabel == nil) {
  70. _titleLabel = [[UILabel alloc]init];
  71. _titleLabel.textColor = UIColorFromRGB(0x333333);
  72. _titleLabel.font = [UIFont systemFontOfSize:14];
  73. _titleLabel.text = @"商品原链接";
  74. }
  75. return _titleLabel;
  76. }
  77. - (UILabel *)rightLabel
  78. {
  79. if (_rightLabel == nil) {
  80. _rightLabel = [[UILabel alloc]init];
  81. _rightLabel.textColor = UIColorFromRGB(0x999999);
  82. _rightLabel.font = [UIFont systemFontOfSize:14];
  83. }
  84. return _rightLabel;
  85. }
  86. - (UIImageView *)linkImgView{
  87. if (_linkImgView == nil) {
  88. _linkImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"detail_link"]];
  89. }
  90. return _linkImgView;
  91. }
  92. - (UIView *)bottomLine
  93. {
  94. if (_bottomLine == nil) {
  95. _bottomLine = [[UIView alloc]init];
  96. _bottomLine.backgroundColor = UIColorFromRGB(0xe5e5e5);
  97. }
  98. return _bottomLine;
  99. }
  100. @end