No Description

FKCirclePublicProcuctCell.m 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. //
  2. // FKCirclePublicProcuctCell.m
  3. // FirstLink
  4. //
  5. // Created by ascii on 16/6/8.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKCirclePublicProcuctCell.h"
  9. #import "FKCircleChoiceProductItem.h"
  10. #import "FLStringHelper.h"
  11. @interface FKCirclePublicProcuctCell ()
  12. @property (nonatomic, strong) UIView *bgView;
  13. @property (nonatomic, strong) UIImageView *photoView;
  14. @property (nonatomic, strong) UILabel *titleLabel;
  15. @property (nonatomic, strong) UILabel *priceLabel;
  16. @property (nonatomic, strong) UILabel *sourceLabel;
  17. @end
  18. @implementation FKCirclePublicProcuctCell
  19. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  20. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  21. self.selectionStyle = UITableViewCellSelectionStyleNone;
  22. self.contentView.backgroundColor = [UIColor whiteColor];
  23. [self addAllSubviews];
  24. }
  25. return self;
  26. }
  27. - (void)configWith:(id)item {
  28. if ([item isKindOfClass:[FKCircleChoiceProductItem class]]) {
  29. FKCircleChoiceProductItem *productItem = (FKCircleChoiceProductItem*)item;
  30. [self.photoView sd_setImageWithURL:[NSURL URLWithString:productItem.photoURL]];
  31. [self.titleLabel setText:productItem.title];
  32. [self.priceLabel setText:[NSString stringWithFormat:@"¥%.2lf", [FLStringHelper convertFenStringToYuanValue:productItem.price]]];
  33. }
  34. }
  35. #pragma mark - Layout
  36. - (void)addAllSubviews {
  37. [self.contentView addSubview:self.bgView];
  38. [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.left.equalTo(self.contentView).offset(10);
  40. make.centerY.equalTo(self.contentView);
  41. make.right.equalTo(self.contentView).offset(-20);
  42. make.height.mas_equalTo(78);
  43. }];
  44. [self.bgView addSubview:self.photoView];
  45. [self.photoView mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.left.equalTo(self.bgView).offset(8);
  47. make.centerY.equalTo(self.bgView);
  48. make.size.mas_equalTo(CGSizeMake(54, 54));
  49. }];
  50. [self.bgView addSubview:self.titleLabel];
  51. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.left.equalTo(self.photoView.mas_right).offset(10);
  53. make.right.equalTo(self.bgView).offset(-10);
  54. make.top.equalTo(self.bgView).offset(20);
  55. }];
  56. [self.bgView addSubview:self.priceLabel];
  57. [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.left.equalTo(self.titleLabel);
  59. make.bottom.equalTo(self.bgView).offset(-20);
  60. }];
  61. // [self.bgView addSubview:self.sourceLabel];
  62. // [self.sourceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  63. // make.left.equalTo(self.priceLabel.mas_right).offset(16);
  64. // make.right.lessThanOrEqualTo(self.bgView).offset(-20);
  65. // make.centerY.equalTo(self.priceLabel);
  66. // }];
  67. [self.contentView addSubview:self.deleteButton];
  68. [self.deleteButton mas_makeConstraints:^(MASConstraintMaker *make) {
  69. make.right.equalTo(self.contentView).offset(0);
  70. make.top.equalTo(self.contentView).offset(-8);
  71. make.size.mas_equalTo(CGSizeMake(50, 40));
  72. }];
  73. }
  74. #pragma mark - Method
  75. + (CGFloat)height {
  76. return 78;
  77. }
  78. #pragma mark - Property
  79. - (UIButton *)deleteButton {
  80. if (!_deleteButton) {
  81. _deleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
  82. _deleteButton.imageEdgeInsets = UIEdgeInsetsMake(-20, 0, 0, -10);
  83. [_deleteButton setImage:[UIImage imageNamed:@"CircleDeleteIcon"] forState:UIControlStateNormal];
  84. }
  85. return _deleteButton;
  86. }
  87. - (UIView *)bgView {
  88. if (!_bgView) {
  89. _bgView = [UIView new];
  90. _bgView.backgroundColor = UIColorFromRGB(0xf4f4f4);
  91. _bgView.layer.cornerRadius = 4;
  92. }
  93. return _bgView;
  94. }
  95. - (UIImageView *)photoView {
  96. if (!_photoView) {
  97. _photoView = [UIImageView new];
  98. _photoView.contentMode = UIViewContentModeScaleAspectFit;
  99. }
  100. return _photoView;
  101. }
  102. - (UILabel *)titleLabel {
  103. if (!_titleLabel) {
  104. _titleLabel = [UILabel new];
  105. _titleLabel.textColor = UIColorFromRGB(0x333333);
  106. _titleLabel.font = [UIFont systemFontOfSize:14];
  107. }
  108. return _titleLabel;
  109. }
  110. - (UILabel *)priceLabel {
  111. if (!_priceLabel) {
  112. _priceLabel = [UILabel new];
  113. _priceLabel.textColor = UIColorFromRGB(0xff6362);
  114. _priceLabel.font = [UIFont systemFontOfSize:14];
  115. }
  116. return _priceLabel;
  117. }
  118. - (UILabel *)sourceLabel {
  119. if (!_sourceLabel) {
  120. _sourceLabel = [UILabel new];
  121. _sourceLabel.textColor = UIColorFromRGB(0x999999);
  122. _sourceLabel.font = [UIFont systemFontOfSize:14];
  123. }
  124. return _sourceLabel;
  125. }
  126. @end