Nav apraksta

FKPersonOrderProductCell.m 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. //
  2. // FKPersonOrderProductCell.m
  3. // FirstLink
  4. //
  5. // Created by ascii on 16/2/23.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKPersonOrderProductCell.h"
  9. #import "FKPersonOrderViewModel.h"
  10. #import "FKOrderGoodItem.h"
  11. @interface FKPersonOrderProductCell ()
  12. @property (nonatomic, strong) UIView *productBgView;
  13. @property (nonatomic, strong) TTTAttributedLabel *titleLabel;
  14. @end
  15. @implementation FKPersonOrderProductCell
  16. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  17. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  18. if (self) {
  19. self.contentView.backgroundColor = [UIColor whiteColor];
  20. [self addAllSubviews];
  21. }
  22. return self;
  23. }
  24. #pragma mark - Layout
  25. - (void)addAllSubviews {
  26. [self.contentView addSubview:self.productBgView];
  27. [self.productBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  28. make.left.top.right.equalTo(self.contentView);
  29. make.bottom.equalTo(self.contentView).offset(-2);
  30. }];
  31. [self.productBgView addSubview:self.productImgView];
  32. [self.productImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.left.equalTo(self.productBgView).offset(15);
  34. make.centerY.equalTo(self.productBgView);
  35. make.size.mas_equalTo(CGSizeMake(75, 75));
  36. }];
  37. [self.productBgView addSubview:self.titleLabel];
  38. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.left.equalTo(self.productImgView.mas_right).offset(12);
  40. make.right.equalTo(self.productBgView).offset(-36);
  41. make.top.equalTo(self.productImgView).offset(20);
  42. make.height.mas_equalTo(40);
  43. }];
  44. }
  45. #pragma mark - FKPersonOrderCellDelegate
  46. - (void)configPersonOrderCell:(NSIndexPath *)indexPath classify:(FKPersonOrderClassify)classify viewModel:(FKPersonOrderViewModel *)viewModel {
  47. FKOrderGoodItem *goodItem = [viewModel goodItemAtIndex:indexPath classify:classify];
  48. [self.productImgView setImageWithURL:goodItem.photoURL cdnWidth:75];
  49. self.titleLabel.text = goodItem.title;
  50. self.tag = indexPath.section;
  51. }
  52. #pragma mark - Property
  53. - (UIView *)productBgView {
  54. if (!_productBgView) {
  55. _productBgView = [UIView new];
  56. _productBgView.backgroundColor = UIColorFromRGB(0xf9f9f9);
  57. }
  58. return _productBgView;
  59. }
  60. - (UIImageView*)productImgView {
  61. if (!_productImgView) {
  62. _productImgView = [UIImageView new];
  63. _productImgView.contentMode = UIViewContentModeScaleAspectFit;
  64. _productImgView.backgroundColor = [UIColor whiteColor];
  65. }
  66. return _productImgView;
  67. }
  68. - (TTTAttributedLabel *)titleLabel {
  69. if (!_titleLabel) {
  70. _titleLabel = [[TTTAttributedLabel alloc] init];
  71. _titleLabel.verticalAlignment = TTTAttributedLabelVerticalAlignmentTop;
  72. _titleLabel.leading = 4.0;
  73. _titleLabel.textColor = UIColorFromRGB(0x666666);
  74. _titleLabel.font = [UIFont systemFontOfSize:14];
  75. _titleLabel.numberOfLines = 0;
  76. }
  77. return _titleLabel;
  78. }
  79. @end