ASMineAddressCell.m 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. //
  2. // ASMineAddressCell.m
  3. // Asteria
  4. //
  5. // Created by iOS on 2024/5/7.
  6. //
  7. #import "ASMineAddressCell.h"
  8. @interface ASMineAddressCell ()
  9. @property (nonatomic, strong) UIView *bgV;
  10. @property (nonatomic, strong) UILabel *nameLB;
  11. @property (nonatomic, strong) UILabel *addressLB;
  12. @property (nonatomic, strong) UILabel *codeLB;
  13. @property (nonatomic, strong) UILabel *countryLB;
  14. @property (nonatomic, strong) UILabel *phoneLB;
  15. @end
  16. @implementation ASMineAddressCell
  17. - (void)setData:(ASAddressModel *)m {
  18. if (m.title && ![m.title isEmpty]) {
  19. self.titleLB.text = m.title;
  20. } else {
  21. self.titleLB.text = @"Other Address";
  22. }
  23. self.nameLB.text = [NSString stringWithFormat:@"%@ %@",m.lastname,m.firstname];
  24. NSString *street = [m.street componentsJoinedByString:@" "];
  25. self.addressLB.text = [NSString stringWithFormat:@"%@,%@,%@",m.city,m.region.region,street];
  26. self.codeLB.text = m.postcode;//[NSString stringWithFormat:@""]
  27. self.countryLB.text = m.country;
  28. self.phoneLB.text = [NSString stringWithFormat:@"T:%@",m.telephone];
  29. }
  30. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  31. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  32. if (self) {
  33. [self configSubV];
  34. }
  35. return self;
  36. }
  37. - (void)configSubV {
  38. self.backgroundColor = [UIColor whiteColor];
  39. self.selectionStyle = UITableViewCellSelectionStyleNone;
  40. self.bgV = [UIView new];
  41. self.bgV.backgroundColor = _F8F8F8;
  42. // self.bgV.layer.cornerRadius = 4;
  43. // self.bgV.layer.masksToBounds = true;
  44. [self.contentView addSubview:self.bgV];
  45. [self.bgV mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.top.equalTo(self.contentView).offset(0);
  47. make.left.equalTo(self.contentView).offset(0);
  48. make.centerX.equalTo(self.contentView);
  49. make.bottom.equalTo(self.contentView).offset(-10);
  50. }];
  51. self.titleLB = [self createLb];
  52. self.titleLB.font = [UIFont fontWithName:Rob_Bold size:16];
  53. self.titleLB.numberOfLines =0;
  54. self.titleLB.preferredMaxLayoutWidth = KScreenWidth-40-10-44;
  55. [self.bgV addSubview:self.titleLB];
  56. [self.titleLB mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.top.equalTo(self.bgV).offset(20);
  58. make.left.equalTo(self.bgV).offset(15);
  59. make.width.mas_equalTo(KScreenWidth-40-10-44);
  60. }];
  61. self.editBt = [UIButton buttonWithType:UIButtonTypeCustom];
  62. [self.editBt setImage:[UIImage imageNamed:@"avater_edit"] forState:UIControlStateNormal];
  63. [self.editBt addTarget:self action:@selector(editBtnAction) forControlEvents:UIControlEventTouchUpInside];
  64. [self.bgV addSubview:self.editBt];
  65. [self.editBt mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.width.height.equalTo(@44);
  67. make.right.equalTo(self.bgV);
  68. make.centerY.equalTo(self.bgV);
  69. }];
  70. self.checkBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  71. self.checkBtn.hidden = YES;
  72. [self.checkBtn setImage:[UIImage imageNamed:@"cartship_radio_unselect"] forState:UIControlStateNormal];
  73. [self.checkBtn setImage:[UIImage imageNamed:@"cartship_radio_select"] forState:UIControlStateSelected];
  74. [self.checkBtn addTarget:self action:@selector(handle_checkBtnAction) forControlEvents:UIControlEventTouchUpInside];
  75. [self.bgV addSubview:self.checkBtn];
  76. [self.checkBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  77. make.height.equalTo(@44);
  78. make.width.equalTo(@44);
  79. make.right.equalTo(self.bgV);
  80. make.centerY.equalTo(self.titleLB);
  81. }];
  82. UIStackView *tStackV = [[UIStackView alloc] init];
  83. tStackV.axis = UILayoutConstraintAxisVertical;
  84. tStackV.alignment = UIStackViewAlignmentFill;
  85. tStackV.distribution = UIStackViewDistributionFill;
  86. tStackV.spacing = 10;
  87. [self.bgV addSubview:tStackV];
  88. [tStackV mas_makeConstraints:^(MASConstraintMaker *make) {
  89. make.top.equalTo(self.titleLB.mas_bottom).offset(15);
  90. make.left.equalTo(self.bgV).offset(15);
  91. make.right.equalTo(self.editBt.mas_left).offset(-15);
  92. make.bottom.equalTo(self.bgV).offset(-20);
  93. }];
  94. self.nameLB = [self createLb];
  95. [tStackV addArrangedSubview:self.nameLB];
  96. self.addressLB = [self createLb];
  97. [tStackV addArrangedSubview:self.addressLB];
  98. self.addressLB.numberOfLines = 0;
  99. self.codeLB = [self createLb];
  100. [tStackV addArrangedSubview:self.codeLB];
  101. self.countryLB = [self createLb];
  102. [tStackV addArrangedSubview:self.countryLB];
  103. self.phoneLB = [self createLb];
  104. [tStackV addArrangedSubview:self.phoneLB];
  105. }
  106. - (void)editBtnAction {
  107. if (self.editBack) {
  108. self.editBack();
  109. }
  110. }
  111. -(void)handle_checkBtnAction{
  112. if(self.checkBack){
  113. self.checkBack();
  114. }
  115. }
  116. - (UILabel *)createLb {
  117. UILabel *lb = [[UILabel alloc] init];
  118. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  119. lb.textColor = UIColor.blackColor;
  120. [lb mas_makeConstraints:^(MASConstraintMaker *make) {
  121. make.height.greaterThanOrEqualTo(@14);
  122. }];
  123. return lb;
  124. }
  125. - (void)awakeFromNib {
  126. [super awakeFromNib];
  127. // Initialization code
  128. }
  129. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  130. [super setSelected:selected animated:animated];
  131. // Configure the view for the selected state
  132. }
  133. @end