No Description

SubmitDefaultAddressCell.m 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. //
  2. // SubmitOrderTableCells.m
  3. // FirstLink
  4. //
  5. // Created by jack on 15/6/18.
  6. // Copyright (c) 2015年 FirstLink. All rights reserved.
  7. //
  8. #import "SubmitDefaultAddressCell.h"
  9. #import "OrderDetailItem.h"
  10. #import "FKBaseOrderViewModel.h"
  11. @interface SubmitDefaultAddressCell ()
  12. @property (nonatomic, strong) UIImageView *rightArrow;
  13. @property (nonatomic, strong) UIView *bottomLine;
  14. @end
  15. @implementation SubmitDefaultAddressCell
  16. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  17. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  18. self.selectionStyle = UITableViewCellSelectionStyleNone;
  19. [self addAllSubviews];
  20. self.bottomColorLine.hidden = YES;
  21. self.topColorLine.hidden = YES;
  22. }
  23. return self;
  24. }
  25. #pragma mark - Function
  26. + (CGFloat)heightWithAddress:(NSString *)text {
  27. CGFloat defaultHeight = (14 + 17 + 4);
  28. CGSize size = [FLStringHelper sizeOfAttributeString:text
  29. font:[UIFont systemFontOfSize:14]
  30. width:(UISCREENWIDTH - 15 - 32)
  31. maxRow:100];
  32. return (defaultHeight + size.height + 14);
  33. }
  34. #pragma mark -
  35. - (void)addAllSubviews {
  36. [self.contentView addSubview:self.consigneeTextLabel];
  37. [self.consigneeTextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.left.equalTo(self.contentView).offset(15);
  39. make.right.equalTo(self.contentView).offset(-32);
  40. make.top.equalTo(self.contentView).offset(14);
  41. }];
  42. [self.contentView addSubview:self.addressTextLabel];
  43. [self.addressTextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.left.equalTo(self.contentView).offset(15);
  45. make.top.equalTo(self.consigneeTextLabel.mas_bottom).offset(4);
  46. make.right.equalTo(self.contentView).offset(-32);
  47. }];
  48. [self.contentView addSubview:self.rightArrow];
  49. [self.rightArrow mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.right.equalTo(self.contentView).offset(-15);
  51. make.centerY.equalTo(self.contentView);
  52. }];
  53. [self.contentView addSubview:self.bottomLine];
  54. [self.bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
  55. make.left.equalTo(self.contentView).offset(15);
  56. make.height.equalTo(@0.5);
  57. make.bottom.right.equalTo(self.contentView);
  58. }];
  59. [self.contentView addSubview:self.topColorLine];
  60. [self.topColorLine mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.left.top.right.equalTo(self.contentView);
  62. make.height.mas_equalTo(@2);
  63. }];
  64. [self.contentView addSubview:self.bottomColorLine];
  65. [self.bottomColorLine mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.left.equalTo(self.contentView).offset(14);
  67. make.bottom.equalTo(self.contentView);
  68. make.right.equalTo(self.contentView).offset(14);
  69. make.height.mas_equalTo(@2);
  70. }];
  71. }
  72. - (void)fk_configWithViewModel:(FKSubmitOrderViewModel *)viewModel indexPath:(NSIndexPath *)indexPath{
  73. if ([viewModel isKindOfClass:[FKSubmitOrderViewModel class]]){
  74. self.consigneeTextLabel.text = [NSString stringWithFormat:@"收件人: %@ %@", viewModel.selectedAddress.receiver, viewModel.selectedAddress.receiverPhone];
  75. self.addressTextLabel.text = [viewModel.selectedAddress detailAddressWithTip];
  76. self.topColorLine.hidden = NO;
  77. self.bottomColorLine.hidden = ([viewModel.needIdCardType isEqualToString:@"3"] ? YES : NO);
  78. }
  79. }
  80. #pragma mark - Property
  81. - (UILabel *)consigneeTextLabel {
  82. if (!_consigneeTextLabel) {
  83. _consigneeTextLabel = [UILabel new];
  84. _consigneeTextLabel.textColor = UIColorFromRGB(0x333333);
  85. _consigneeTextLabel.font = [UIFont systemFontOfSize:14];
  86. }
  87. return _consigneeTextLabel;
  88. }
  89. - (UILabel *)addressTextLabel {
  90. if (!_addressTextLabel) {
  91. _addressTextLabel = [UILabel new];
  92. _addressTextLabel.textColor = UIColorFromRGB(0x999999);
  93. _addressTextLabel.font = [UIFont systemFontOfSize:14];
  94. _addressTextLabel.numberOfLines = 0;
  95. }
  96. return _addressTextLabel;
  97. }
  98. - (UIImageView *)rightArrow {
  99. if (!_rightArrow) {
  100. _rightArrow = [UIImageView new];
  101. _rightArrow.image = [UIImage imageNamed:@"Cell_More_Icon"];
  102. }
  103. return _rightArrow;
  104. }
  105. - (UIView *)bottomLine {
  106. if (!_bottomLine) {
  107. _bottomLine = [[UIView alloc]init];
  108. _bottomLine.backgroundColor = UIColorFromRGB(0xe5e5e5);
  109. }
  110. return _bottomLine;
  111. }
  112. - (UIImageView *)topColorLine{
  113. if (_topColorLine == nil) {
  114. UIImage *resizeImg = [[UIImage imageNamed:@"submit_colorLine"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 4, 0, 4) resizingMode:UIImageResizingModeTile];
  115. _topColorLine = [[UIImageView alloc]initWithImage:resizeImg];
  116. }
  117. return _topColorLine;
  118. }
  119. - (UIImageView *)bottomColorLine{
  120. if (_bottomColorLine == nil) {
  121. UIImage *resizeImg = [[UIImage imageNamed:@"submit_colorLine"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 4, 0, 4) resizingMode:UIImageResizingModeTile];
  122. _bottomColorLine = [[UIImageView alloc]initWithImage:resizeImg];
  123. }
  124. return _bottomColorLine;
  125. }
  126. @end