No Description

FKProductWeightCell.m 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //
  2. // FKProductWeightCell.m
  3. // FirstLink
  4. //
  5. // Created by jack on 16/3/12.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKProductWeightCell.h"
  9. #import "FKProDetailViewModel.h"
  10. @interface FKProductWeightCell ()
  11. @property (nonatomic, strong) UILabel *titleLabel;
  12. @end
  13. @implementation FKProductWeightCell
  14. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  15. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  16. [self addAllSubviews];
  17. self.selectionStyle = UITableViewCellSelectionStyleNone;
  18. self.contentView.backgroundColor = UIColorFromRGB(0xf4f4f4);
  19. }
  20. return self;
  21. }
  22. - (void)addAllSubviews{
  23. [self.contentView addSubview:self.titleLabel];
  24. [self.contentView addSubview:self.infoBtn];
  25. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  26. make.left.equalTo(self.contentView).offset(15);
  27. make.centerY.equalTo(self.contentView);
  28. }];
  29. [self.infoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.centerX.equalTo(self.titleLabel.mas_right).offset(15);
  31. make.centerY.equalTo(self.contentView);
  32. make.height.mas_equalTo(self.contentView);
  33. make.width.mas_equalTo(50);
  34. }];
  35. }
  36. -(void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath{
  37. if ([viewModel isKindOfClass:[FKProDetailViewModel class]]) {
  38. FKProDetailViewModel *detailModel = (FKProDetailViewModel *)viewModel;
  39. NSString *title = [NSString stringWithFormat:@"商品重量:%@克/件", detailModel.dataItem.productInfo.weight];
  40. if (detailModel.selectBuyItem) {
  41. title = [NSString stringWithFormat:@"商品重量:%@克/件", detailModel.selectBuyItem.weight];
  42. }
  43. self.titleLabel.text = title;
  44. self.infoBtn.selected = detailModel.showWeightDetail;
  45. }
  46. }
  47. + (CGFloat)cellHeight{
  48. return 27.0f;
  49. }
  50. #pragma mark - property
  51. - (UILabel *)titleLabel{
  52. if (_titleLabel == nil) {
  53. _titleLabel = [[UILabel alloc]init];
  54. _titleLabel.textColor = UIColorFromRGB(0x999999);
  55. _titleLabel.font = [UIFont systemFontOfSize:13];
  56. }
  57. return _titleLabel;
  58. }
  59. - (UIButton *)infoBtn{
  60. if (_infoBtn == nil) {
  61. _infoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  62. [_infoBtn setImage:[UIImage imageNamed:@"basket_arrow_down"] forState:UIControlStateNormal];
  63. [_infoBtn setImage:[UIImage imageNamed:@"basket_arrow_up"] forState:UIControlStateSelected];
  64. }
  65. return _infoBtn;
  66. }
  67. @end