No Description

SubmitAddNewCell.m 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. //
  2. // SubmitAddNewAddressCell.m
  3. // FirstLink
  4. //
  5. // Created by jack on 15/6/18.
  6. // Copyright (c) 2015年 FirstLink. All rights reserved.
  7. //
  8. #import "SubmitAddNewCell.h"
  9. @interface SubmitAddNewCell ()
  10. @property (nonatomic, strong) UIImageView *iconView;
  11. @property (nonatomic, strong) UILabel *titleLabel;
  12. @property (nonatomic, strong) UIImageView *rightArrow;
  13. @property (nonatomic, strong) UIView *bottomLine;
  14. @end
  15. @implementation SubmitAddNewCell
  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 = self.topColorLine.hidden = YES;
  21. }
  22. return self;
  23. }
  24. - (void)addAllSubviews {
  25. [self.contentView addSubview:self.iconView];
  26. [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
  27. make.left.equalTo(self.contentView).offset(15);
  28. make.centerY.equalTo(self.contentView).offset(-2);
  29. make.size.mas_equalTo(CGSizeMake(30, 30));
  30. }];
  31. [self.contentView addSubview:self.rightArrow];
  32. [self.rightArrow mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.right.equalTo(self.contentView).offset(-15);
  34. make.centerY.equalTo(self.contentView);
  35. }];
  36. [self.contentView addSubview:self.titleLabel];
  37. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.left.equalTo(self.iconView.mas_right).offset(15);
  39. make.right.equalTo(self.contentView).offset(-30);
  40. make.centerY.equalTo(self.contentView);
  41. }];
  42. [self.contentView addSubview:self.bottomLine];
  43. [self.bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.left.equalTo(self.contentView).offset(15);
  45. make.height.equalTo(@0.5);
  46. make.bottom.right.equalTo(self.contentView);
  47. }];
  48. [self.contentView addSubview:self.topColorLine];
  49. [self.topColorLine mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.left.top.right.equalTo(self.contentView);
  51. make.height.mas_equalTo(@2);
  52. }];
  53. [self.contentView addSubview:self.bottomColorLine];
  54. [self.bottomColorLine mas_makeConstraints:^(MASConstraintMaker *make) {
  55. make.left.equalTo(self.contentView).offset(14);
  56. make.bottom.equalTo(self.contentView);
  57. make.right.equalTo(self.contentView).offset(14);
  58. make.height.mas_equalTo(@2);
  59. }];
  60. }
  61. #pragma mark - Function
  62. - (void)fk_configWithViewModel:(FKSubmitOrderViewModel *)viewModel indexPath:(NSIndexPath *)indexPath{
  63. kSubmitProCellType type = [viewModel cellTypeForIndexPath:indexPath];
  64. if (type == kSubmitProCellTypeAddAddress){
  65. [self configCellWith:@"AddNewAddressIcon" title:[SubmitAddNewCell addNewAddressTipString]];
  66. self.topColorLine.hidden = NO;
  67. self.bottomColorLine.hidden = ([viewModel.needIdCardType isEqualToString:@"3"] ? YES : NO);
  68. }else if (type == kSubmitProCellTypeAddIDCard){
  69. [self configCellWith:@"AddNewIdCardIcon" title:[SubmitAddNewCell addNewIDCardTipString]];
  70. self.topColorLine.hidden = ([viewModel.needIdCardType isEqualToString:@"3"] ? YES : NO);
  71. self.bottomColorLine.hidden = NO;
  72. if ([viewModel.needIdCardType isEqualToString:@"3"]) {
  73. [self.bottomColorLine mas_remakeConstraints:^(MASConstraintMaker *make) {
  74. make.left.equalTo(self.contentView);
  75. make.bottom.equalTo(self.contentView);
  76. make.right.equalTo(self.contentView);
  77. make.height.mas_equalTo(@2);
  78. }];
  79. } else {
  80. [self.bottomColorLine mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.left.equalTo(self.contentView).offset(14);
  82. make.bottom.equalTo(self.contentView);
  83. make.right.equalTo(self.contentView).offset(14);
  84. make.height.mas_equalTo(@2);
  85. }];
  86. }
  87. }
  88. }
  89. - (void)configCellWith:(NSString *)iconName title:(NSAttributedString *)attributedTitle {
  90. self.iconView.image = [UIImage imageNamed:iconName];
  91. self.titleLabel.attributedText = attributedTitle;
  92. }
  93. + (NSAttributedString *)addNewAddressTipString {
  94. NSString *string = @"新增收货地址";
  95. NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc] initWithString:string];
  96. [attributeString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, string.length)];
  97. [attributeString addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0x333333) range:NSMakeRange(0, string.length)];
  98. return attributeString;
  99. }
  100. + (NSAttributedString *)addNewIDCardTipString {
  101. NSString *string = @"新增身份信息(必填)";
  102. NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc] initWithString:string];
  103. [attributeString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, 6)];
  104. [attributeString addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0x333333) range:NSMakeRange(0, 6)];
  105. [attributeString addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xff6362) range:NSMakeRange(6, 4)];
  106. return attributeString;
  107. }
  108. #pragma mark - Property
  109. - (UIImageView *)iconView {
  110. if (!_iconView) {
  111. _iconView = [UIImageView new];
  112. }
  113. return _iconView;
  114. }
  115. - (UILabel *)titleLabel {
  116. if (!_titleLabel) {
  117. _titleLabel = [UILabel new];
  118. _titleLabel.font = [UIFont systemFontOfSize:14];
  119. _titleLabel.textColor = UIColorFromRGB(0x999999);
  120. // _titleLabel.text = @"新增收货地址";
  121. }
  122. return _titleLabel;
  123. }
  124. - (UIImageView *)rightArrow {
  125. if (!_rightArrow) {
  126. _rightArrow = [UIImageView new];
  127. _rightArrow.image = [UIImage imageNamed:@"Cell_More_Icon"];
  128. }
  129. return _rightArrow;
  130. }
  131. - (UIView *)bottomLine {
  132. if (!_bottomLine) {
  133. _bottomLine = [[UIView alloc]init];
  134. _bottomLine.backgroundColor = UIColorFromRGB(0xe5e5e5);
  135. }
  136. return _bottomLine;
  137. }
  138. - (UIImageView *)topColorLine{
  139. if (_topColorLine == nil) {
  140. UIImage *resizeImg = [[UIImage imageNamed:@"submit_colorLine"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 4, 0, 4) resizingMode:UIImageResizingModeTile];
  141. _topColorLine = [[UIImageView alloc]initWithImage:resizeImg];
  142. }
  143. return _topColorLine;
  144. }
  145. - (UIImageView *)bottomColorLine{
  146. if (_bottomColorLine == nil) {
  147. UIImage *resizeImg = [[UIImage imageNamed:@"submit_colorLine"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 4, 0, 4) resizingMode:UIImageResizingModeTile];
  148. _bottomColorLine = [[UIImageView alloc]initWithImage:resizeImg];
  149. }
  150. return _bottomColorLine;
  151. }
  152. @end