YMMyEarningsWithdrawalAmountCell.m 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. //
  2. // YMMyEarningsWithdrawalAmountCell.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/29.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMMyEarningsWithdrawalAmountCell.h"
  9. #import "YMMyEarningsWithdrawalAmountCellViewModel.h"
  10. @interface YMMyEarningsWithdrawalAmountCell()
  11. /// ViewModel
  12. @property (nonatomic, strong) YMMyEarningsWithdrawalAmountCellViewModel *viewModel;
  13. /// 基础视图
  14. @property (nonatomic, strong) UIView *baseView;
  15. /// 提现金额标签
  16. @property (nonatomic, strong) UIImageView *iconImgv;
  17. /// 提现金额标签
  18. @property (nonatomic, strong) UILabel *withdrawalAmountLb;
  19. /// 提现金币要求标签
  20. @property (nonatomic, strong) UILabel *withdrawalPointsRequirementLb;
  21. /// 选中标记
  22. @property (nonatomic, strong) UIImageView *selectedManrkImgv;
  23. @end
  24. @implementation YMMyEarningsWithdrawalAmountCell
  25. - (void)setSelected:(BOOL)selected{
  26. [super setSelected:selected];
  27. if (selected) {
  28. //self.baseView.layer.borderWidth = adapt(1);
  29. //self.baseView.backgroundColor = HexColorFromRGB(0xFFFFFF);
  30. self.selectedManrkImgv.image = ImageByName(@"ym_account_balance_selected");
  31. }else{
  32. //self.baseView.layer.borderWidth = 0;
  33. //self.baseView.backgroundColor = HexColorFromRGB(0xF2F5FF);
  34. self.selectedManrkImgv.image = ImageByName(@"ym_account_balance_unselect");
  35. }
  36. }
  37. - (void)ym_setupViews{
  38. self.contentView.backgroundColor = UIColor.clearColor;
  39. self.backgroundColor = UIColor.clearColor;
  40. [self.contentView addSubview:self.baseView];
  41. [self.baseView addSubview:self.selectedManrkImgv];
  42. [self.baseView addSubview:self.iconImgv];
  43. [self.baseView addSubview:self.withdrawalAmountLb];
  44. [self.baseView addSubview:self.withdrawalPointsRequirementLb];
  45. [self setNeedsUpdateConstraints];
  46. [self updateConstraintsIfNeeded];
  47. }
  48. - (void)updateConstraints {
  49. [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.top.equalTo(self.contentView);
  51. make.left.equalTo(self.contentView);
  52. make.right.equalTo(self.contentView);
  53. make.bottom.equalTo(self.contentView);
  54. }];
  55. [self.selectedManrkImgv mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.top.left.bottom.right.equalTo(self.baseView);
  57. }];
  58. [self.withdrawalAmountLb mas_makeConstraints:^(MASConstraintMaker *make) {
  59. make.centerX.equalTo(self.baseView.mas_centerX);
  60. make.bottom.equalTo(self.baseView.mas_centerY).offset(adapt(3));
  61. }];
  62. [self.withdrawalPointsRequirementLb mas_makeConstraints:^(MASConstraintMaker *make) {
  63. make.top.equalTo(self.withdrawalAmountLb.mas_bottom).offset(adapt(5));
  64. make.centerX.equalTo(self.baseView.mas_centerX).offset(adapt(7));
  65. }];
  66. [self.iconImgv mas_makeConstraints:^(MASConstraintMaker *make) {
  67. make.centerY.equalTo(self.withdrawalPointsRequirementLb.mas_centerY);
  68. make.right.equalTo(self.withdrawalPointsRequirementLb.mas_left).offset(adapt(0));
  69. make.width.height.mas_equalTo(adapt(14));
  70. }];
  71. [super updateConstraints];
  72. }
  73. - (void)ym_bindViewModel:(YMMyEarningsWithdrawalAmountCellViewModel*)viewModel{
  74. if (!viewModel) {
  75. return;
  76. }
  77. _viewModel = viewModel;
  78. self.withdrawalAmountLb.text = stringFormat(@"%ld元",self.viewModel.withdrawalAmount);
  79. self.withdrawalPointsRequirementLb.text = stringFormat(@"%ld金币",self.viewModel.withdrawalPointsRequirement);
  80. }
  81. - (UIView *)baseView{
  82. if (!_baseView) {
  83. _baseView = [[UIView alloc]init];
  84. //_baseView.backgroundColor = HexColorFromRGB(0xF2F5FF);
  85. _baseView.backgroundColor = UIColor.clearColor;
  86. _baseView.layer.borderColor = HexColorFromRGB(0xFC5E9E).CGColor;
  87. _baseView.layer.borderWidth = 0;
  88. _baseView.layer.cornerRadius = adapt(12);
  89. _baseView.layer.masksToBounds = YES;
  90. }
  91. return _baseView;
  92. }
  93. - (UIImageView *)iconImgv {
  94. if (!_iconImgv) {
  95. _iconImgv = [[UIImageView alloc]init];
  96. _iconImgv.image = ImageByName(@"ym_my_earnings_coin");
  97. }
  98. return _iconImgv;
  99. }
  100. - (UILabel *)withdrawalAmountLb{
  101. if (!_withdrawalAmountLb) {
  102. _withdrawalAmountLb = [[UILabel alloc]init];
  103. _withdrawalAmountLb.font = LCBoldFont(18);
  104. _withdrawalAmountLb.textColor = HexColorFromRGB(0x000000);
  105. _withdrawalAmountLb.textAlignment = NSTextAlignmentCenter;
  106. _withdrawalAmountLb.text = @"*****元";
  107. }
  108. return _withdrawalAmountLb;
  109. }
  110. - (UILabel *)withdrawalPointsRequirementLb{
  111. if (!_withdrawalPointsRequirementLb) {
  112. _withdrawalPointsRequirementLb = [[UILabel alloc]init];
  113. _withdrawalPointsRequirementLb.font = LCFont(12);
  114. _withdrawalPointsRequirementLb.textColor = HexColorFromRGBA(0x545D79,1);
  115. _withdrawalPointsRequirementLb.textAlignment = NSTextAlignmentCenter;
  116. _withdrawalPointsRequirementLb.text = @"*****金币";
  117. }
  118. return _withdrawalPointsRequirementLb;
  119. }
  120. - (UIImageView *)selectedManrkImgv {
  121. if (!_selectedManrkImgv) {
  122. _selectedManrkImgv = [[UIImageView alloc] init];
  123. _selectedManrkImgv.hidden = NO;
  124. _selectedManrkImgv.image = ImageByName(@"ym_account_balance_unselect");
  125. }
  126. return _selectedManrkImgv;
  127. }
  128. @end