// // SubmitOrderTableCells.m // FirstLink // // Created by jack on 15/6/18. // Copyright (c) 2015年 FirstLink. All rights reserved. // #import "SubmitDefaultAddressCell.h" #import "OrderDetailItem.h" #import "FKBaseOrderViewModel.h" @interface SubmitDefaultAddressCell () @property (nonatomic, strong) UIImageView *rightArrow; @property (nonatomic, strong) UIView *bottomLine; @end @implementation SubmitDefaultAddressCell - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { self.selectionStyle = UITableViewCellSelectionStyleNone; [self addAllSubviews]; self.bottomColorLine.hidden = YES; self.topColorLine.hidden = YES; } return self; } #pragma mark - Function + (CGFloat)heightWithAddress:(NSString *)text { CGFloat defaultHeight = (14 + 17 + 4); CGSize size = [FLStringHelper sizeOfAttributeString:text font:[UIFont systemFontOfSize:14] width:(UISCREENWIDTH - 15 - 32) maxRow:100]; return (defaultHeight + size.height + 14); } #pragma mark - - (void)addAllSubviews { [self.contentView addSubview:self.consigneeTextLabel]; [self.consigneeTextLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.contentView).offset(15); make.right.equalTo(self.contentView).offset(-32); make.top.equalTo(self.contentView).offset(14); }]; [self.contentView addSubview:self.addressTextLabel]; [self.addressTextLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.contentView).offset(15); make.top.equalTo(self.consigneeTextLabel.mas_bottom).offset(4); make.right.equalTo(self.contentView).offset(-32); }]; [self.contentView addSubview:self.rightArrow]; [self.rightArrow mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.contentView).offset(-15); make.centerY.equalTo(self.contentView); }]; [self.contentView addSubview:self.bottomLine]; [self.bottomLine mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.contentView).offset(15); make.height.equalTo(@0.5); make.bottom.right.equalTo(self.contentView); }]; [self.contentView addSubview:self.topColorLine]; [self.topColorLine mas_makeConstraints:^(MASConstraintMaker *make) { make.left.top.right.equalTo(self.contentView); make.height.mas_equalTo(@2); }]; [self.contentView addSubview:self.bottomColorLine]; [self.bottomColorLine mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.contentView).offset(14); make.bottom.equalTo(self.contentView); make.right.equalTo(self.contentView).offset(14); make.height.mas_equalTo(@2); }]; } - (void)fk_configWithViewModel:(FKSubmitOrderViewModel *)viewModel indexPath:(NSIndexPath *)indexPath{ if ([viewModel isKindOfClass:[FKSubmitOrderViewModel class]]){ self.consigneeTextLabel.text = [NSString stringWithFormat:@"收件人: %@ %@", viewModel.selectedAddress.receiver, viewModel.selectedAddress.receiverPhone]; self.addressTextLabel.text = [viewModel.selectedAddress detailAddressWithTip]; self.topColorLine.hidden = NO; self.bottomColorLine.hidden = ([viewModel.needIdCardType isEqualToString:@"3"] ? YES : NO); } } #pragma mark - Property - (UILabel *)consigneeTextLabel { if (!_consigneeTextLabel) { _consigneeTextLabel = [UILabel new]; _consigneeTextLabel.textColor = UIColorFromRGB(0x333333); _consigneeTextLabel.font = [UIFont systemFontOfSize:14]; } return _consigneeTextLabel; } - (UILabel *)addressTextLabel { if (!_addressTextLabel) { _addressTextLabel = [UILabel new]; _addressTextLabel.textColor = UIColorFromRGB(0x999999); _addressTextLabel.font = [UIFont systemFontOfSize:14]; _addressTextLabel.numberOfLines = 0; } return _addressTextLabel; } - (UIImageView *)rightArrow { if (!_rightArrow) { _rightArrow = [UIImageView new]; _rightArrow.image = [UIImage imageNamed:@"Cell_More_Icon"]; } return _rightArrow; } - (UIView *)bottomLine { if (!_bottomLine) { _bottomLine = [[UIView alloc]init]; _bottomLine.backgroundColor = UIColorFromRGB(0xe5e5e5); } return _bottomLine; } - (UIImageView *)topColorLine{ if (_topColorLine == nil) { UIImage *resizeImg = [[UIImage imageNamed:@"submit_colorLine"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 4, 0, 4) resizingMode:UIImageResizingModeTile]; _topColorLine = [[UIImageView alloc]initWithImage:resizeImg]; } return _topColorLine; } - (UIImageView *)bottomColorLine{ if (_bottomColorLine == nil) { UIImage *resizeImg = [[UIImage imageNamed:@"submit_colorLine"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 4, 0, 4) resizingMode:UIImageResizingModeTile]; _bottomColorLine = [[UIImageView alloc]initWithImage:resizeImg]; } return _bottomColorLine; } @end