YMWithdrawalAccountListCell.m 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. //
  2. // YMWithdrawalAccountListCell.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/3/6.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMWithdrawalAccountListCell.h"
  9. #import "YMWithdrawalAccountListCellViewModel.h"
  10. @interface YMWithdrawalAccountListCell ()
  11. /// 提现账号列表VM
  12. @property (nonatomic, strong) YMWithdrawalAccountListCellViewModel *viewModel;
  13. /// 基础视图
  14. @property (nonatomic, strong) UIView *baseView;
  15. /// 提现账号持有人标题标签
  16. @property (nonatomic, strong) UILabel *withdrawalAccountHolderTitleLb;
  17. /// 提现账号持有人标题标签
  18. @property (nonatomic, strong) UILabel *withdrawalAccountHolderContentLb;
  19. /// 提现账号标题标签
  20. @property (nonatomic, strong) UILabel *withdrawalAccountTitleLb;
  21. /// 提现账号内容标签
  22. @property (nonatomic, strong) UILabel *withdrawalAccountContentLb;
  23. /// 编辑按钮
  24. @property (nonatomic, strong) UIButton *editBtn;
  25. @end
  26. @implementation YMWithdrawalAccountListCell
  27. - (void)awakeFromNib {
  28. [super awakeFromNib];
  29. // Initialization code
  30. }
  31. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  32. [super setSelected:selected animated:animated];
  33. // Configure the view for the selected state
  34. }
  35. - (void)ym_setupViews{
  36. [self.contentView addSubview:self.baseView];
  37. [self.baseView addSubview:self.withdrawalAccountHolderTitleLb];
  38. [self.baseView addSubview:self.withdrawalAccountHolderContentLb];
  39. [self.baseView addSubview:self.withdrawalAccountTitleLb];
  40. [self.baseView addSubview:self.withdrawalAccountContentLb];
  41. [self.baseView addSubview:self.editBtn];
  42. [self setNeedsUpdateConstraints];
  43. [self updateConstraintsIfNeeded];
  44. }
  45. - (void)updateConstraints{
  46. [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
  47. make.top.equalTo(self.contentView).offset(adapt(10));
  48. make.left.equalTo(self.contentView).offset(adapt(10));
  49. make.right.equalTo(self.contentView).offset(adapt(-10));
  50. make.bottom.equalTo(self.contentView);
  51. }];
  52. [self.withdrawalAccountHolderTitleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.bottom.equalTo(self.baseView.mas_centerY).offset(adapt(-5));
  54. make.left.equalTo(self.baseView).offset(adapt(12));
  55. }];
  56. [self.withdrawalAccountHolderContentLb mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.centerY.equalTo(self.withdrawalAccountHolderTitleLb.mas_centerY);
  58. make.left.equalTo(self.withdrawalAccountHolderTitleLb.mas_right).offset(adapt(3));
  59. make.right.equalTo(self.editBtn.mas_left).offset(adapt(-10));
  60. }];
  61. [self.withdrawalAccountTitleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.top.equalTo(self.baseView.mas_centerY).offset(adapt(5));
  63. make.left.equalTo(self.baseView).offset(adapt(12));
  64. }];
  65. [self.withdrawalAccountContentLb mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.centerY.equalTo(self.withdrawalAccountTitleLb.mas_centerY);
  67. make.left.equalTo(self.withdrawalAccountTitleLb.mas_right).offset(adapt(3));
  68. make.right.equalTo(self.editBtn.mas_left).offset(adapt(-10));
  69. }];
  70. [self.editBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  71. make.centerY.equalTo(self.baseView.mas_centerY);
  72. make.right.equalTo(self.baseView).offset(adapt(-10));
  73. make.width.mas_equalTo(adapt(60));
  74. make.height.mas_equalTo(adapt(30));
  75. }];
  76. [super updateConstraints];
  77. }
  78. - (void)ym_bindViewModel:(YMWithdrawalAccountListCellViewModel *)viewModel{
  79. if (!viewModel) {
  80. return;
  81. }
  82. _viewModel = viewModel;
  83. self.withdrawalAccountHolderTitleLb.text = stringFormat(@"%@姓名:",self.viewModel.withdrawalAccountTypeName);
  84. self.withdrawalAccountHolderContentLb.text = self.viewModel.withdrawalAccountHolder;
  85. self.withdrawalAccountTitleLb.text = stringFormat(@"%@提现账号:",self.viewModel.withdrawalAccountTypeName);
  86. self.withdrawalAccountContentLb.text = self.viewModel.withdrawalAccount;
  87. self.editBtn.hidden = self.viewModel.isHideEditButton;
  88. }
  89. - (UIView *)baseView{
  90. if (!_baseView) {
  91. _baseView = [[UIView alloc]init];
  92. _baseView.backgroundColor = HexColorFromRGB(0xF6F6F6);
  93. _baseView.layer.cornerRadius = adapt(10);
  94. _baseView.layer.masksToBounds = YES;
  95. }
  96. return _baseView;
  97. }
  98. - (UILabel *)withdrawalAccountHolderTitleLb{
  99. if (!_withdrawalAccountHolderTitleLb) {
  100. _withdrawalAccountHolderTitleLb = [[UILabel alloc]init];
  101. _withdrawalAccountHolderTitleLb.font = LCFont(13);
  102. _withdrawalAccountHolderTitleLb.textColor = HexColorFromRGB(0x1B2739);
  103. _withdrawalAccountHolderTitleLb.textAlignment = NSTextAlignmentLeft;
  104. _withdrawalAccountHolderTitleLb.text = @"******";
  105. /**
  106. *抗拉伸 setContentHuggingPriority(值越高,越不容易拉伸)
  107. */
  108. [_withdrawalAccountHolderTitleLb setContentHuggingPriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
  109. /**
  110. *抗压缩 setContentCompressionResistancePriority(值越高,越不容易压缩)
  111. **/
  112. [_withdrawalAccountHolderTitleLb setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
  113. }
  114. return _withdrawalAccountHolderTitleLb;
  115. }
  116. - (UILabel *)withdrawalAccountHolderContentLb{
  117. if (!_withdrawalAccountHolderContentLb) {
  118. _withdrawalAccountHolderContentLb = [[UILabel alloc]init];
  119. _withdrawalAccountHolderContentLb.font = LCFont(13);
  120. _withdrawalAccountHolderContentLb.textColor = HexColorFromRGB(0x1B2739);
  121. _withdrawalAccountHolderContentLb.textAlignment = NSTextAlignmentLeft;
  122. _withdrawalAccountHolderContentLb.text = @"******";
  123. /**
  124. *抗拉伸 setContentHuggingPriority(值越高,越不容易拉伸)
  125. */
  126. [_withdrawalAccountHolderContentLb setContentHuggingPriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
  127. /**
  128. *抗压缩 setContentCompressionResistancePriority(值越高,越不容易压缩)
  129. **/
  130. [_withdrawalAccountHolderContentLb setContentCompressionResistancePriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
  131. }
  132. return _withdrawalAccountHolderContentLb;
  133. }
  134. - (UILabel *)withdrawalAccountTitleLb{
  135. if (!_withdrawalAccountTitleLb) {
  136. _withdrawalAccountTitleLb = [[UILabel alloc]init];
  137. _withdrawalAccountTitleLb.font = LCFont(13);
  138. _withdrawalAccountTitleLb.textColor = HexColorFromRGB(0x1B2739);
  139. _withdrawalAccountTitleLb.textAlignment = NSTextAlignmentLeft;
  140. _withdrawalAccountTitleLb.text = @"******";
  141. /**
  142. *抗拉伸 setContentHuggingPriority(值越高,越不容易拉伸)
  143. */
  144. [_withdrawalAccountTitleLb setContentHuggingPriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
  145. /**
  146. *抗压缩 setContentCompressionResistancePriority(值越高,越不容易压缩)
  147. **/
  148. [_withdrawalAccountTitleLb setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
  149. }
  150. return _withdrawalAccountTitleLb;
  151. }
  152. - (UILabel *)withdrawalAccountContentLb{
  153. if (!_withdrawalAccountContentLb) {
  154. _withdrawalAccountContentLb = [[UILabel alloc]init];
  155. _withdrawalAccountContentLb.font = LCFont(13);
  156. _withdrawalAccountContentLb.textColor = HexColorFromRGB(0x1B2739);
  157. _withdrawalAccountContentLb.textAlignment = NSTextAlignmentLeft;
  158. _withdrawalAccountContentLb.text = @"******";
  159. /**
  160. *抗拉伸 setContentHuggingPriority(值越高,越不容易拉伸)
  161. */
  162. [_withdrawalAccountContentLb setContentHuggingPriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
  163. /**
  164. *抗压缩 setContentCompressionResistancePriority(值越高,越不容易压缩)
  165. **/
  166. [_withdrawalAccountContentLb setContentCompressionResistancePriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
  167. }
  168. return _withdrawalAccountContentLb;
  169. }
  170. - (UIButton *)editBtn{
  171. if (!_editBtn) {
  172. _editBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  173. _editBtn.titleLabel.font = LCFont(13);
  174. [_editBtn setTitleColor:MAINGRIDTitleC forState:UIControlStateNormal];
  175. [_editBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
  176. [_editBtn setTitle:@"编辑" forState:UIControlStateNormal];
  177. _editBtn.layer.cornerRadius = adapt(8);
  178. _editBtn.layer.masksToBounds = YES;
  179. WS(weakSelf)
  180. [[[_editBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  181. [weakSelf.viewModel gotoBindWithdrawalAccount];
  182. }];
  183. }
  184. return _editBtn;
  185. }
  186. @end