ASMineAddressCell.m 5.2 KB

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