1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- //
- // FKProductWeightCell.m
- // FirstLink
- //
- // Created by jack on 16/3/12.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKProductWeightCell.h"
- #import "FKProDetailViewModel.h"
- @interface FKProductWeightCell ()
- @property (nonatomic, strong) UILabel *titleLabel;
- @end
- @implementation FKProductWeightCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
-
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
- [self addAllSubviews];
- self.selectionStyle = UITableViewCellSelectionStyleNone;
- self.contentView.backgroundColor = UIColorFromRGB(0xf4f4f4);
- }
- return self;
- }
- - (void)addAllSubviews{
- [self.contentView addSubview:self.titleLabel];
- [self.contentView addSubview:self.infoBtn];
-
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).offset(15);
- make.centerY.equalTo(self.contentView);
- }];
-
- [self.infoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self.titleLabel.mas_right).offset(15);
- make.centerY.equalTo(self.contentView);
- make.height.mas_equalTo(self.contentView);
- make.width.mas_equalTo(50);
- }];
- }
- -(void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath{
- if ([viewModel isKindOfClass:[FKProDetailViewModel class]]) {
- FKProDetailViewModel *detailModel = (FKProDetailViewModel *)viewModel;
-
- NSString *title = [NSString stringWithFormat:@"商品重量:%@克/件", detailModel.dataItem.productInfo.weight];
- if (detailModel.selectBuyItem) {
- title = [NSString stringWithFormat:@"商品重量:%@克/件", detailModel.selectBuyItem.weight];
- }
- self.titleLabel.text = title;
- self.infoBtn.selected = detailModel.showWeightDetail;
- }
- }
- + (CGFloat)cellHeight{
- return 27.0f;
- }
- #pragma mark - property
- - (UILabel *)titleLabel{
- if (_titleLabel == nil) {
- _titleLabel = [[UILabel alloc]init];
- _titleLabel.textColor = UIColorFromRGB(0x999999);
- _titleLabel.font = [UIFont systemFontOfSize:13];
- }
- return _titleLabel;
- }
- - (UIButton *)infoBtn{
- if (_infoBtn == nil) {
- _infoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_infoBtn setImage:[UIImage imageNamed:@"basket_arrow_down"] forState:UIControlStateNormal];
- [_infoBtn setImage:[UIImage imageNamed:@"basket_arrow_up"] forState:UIControlStateSelected];
- }
- return _infoBtn;
- }
- @end
|