YMMyEarningsWithdrawalAmountCell.m 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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) UILabel *withdrawalAmountLb;
  17. /// 提现金币要求标签
  18. @property (nonatomic, strong) UILabel *withdrawalPointsRequirementLb;
  19. @end
  20. @implementation YMMyEarningsWithdrawalAmountCell
  21. - (void)setSelected:(BOOL)selected{
  22. [super setSelected:selected];
  23. if (selected) {
  24. self.baseView.layer.borderWidth = adapt(1);
  25. self.baseView.backgroundColor = HexColorFromRGBA(0xFFBEF1, 0.3);
  26. }else{
  27. self.baseView.layer.borderWidth = 0;
  28. self.baseView.backgroundColor = HexColorFromRGB(0xF9F9FA);
  29. }
  30. }
  31. - (void)ym_setupViews{
  32. self.contentView.backgroundColor = UIColor.clearColor;
  33. self.backgroundColor = UIColor.clearColor;
  34. [self.contentView addSubview:self.baseView];
  35. [self.baseView addSubview:self.withdrawalAmountLb];
  36. [self.baseView addSubview:self.withdrawalPointsRequirementLb];
  37. [self setNeedsUpdateConstraints];
  38. [self updateConstraintsIfNeeded];
  39. }
  40. - (void)updateConstraints {
  41. [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.top.equalTo(self.contentView);
  43. make.left.equalTo(self.contentView);
  44. make.right.equalTo(self.contentView);
  45. make.bottom.equalTo(self.contentView);
  46. }];
  47. [self.withdrawalAmountLb mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.centerX.equalTo(self.baseView.mas_centerX);
  49. make.bottom.equalTo(self.baseView.mas_centerY).offset(adapt(-5));
  50. }];
  51. [self.withdrawalPointsRequirementLb mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.centerX.equalTo(self.baseView.mas_centerX);
  53. make.top.equalTo(self.baseView.mas_centerY).offset(adapt(5));
  54. }];
  55. [super updateConstraints];
  56. }
  57. - (void)ym_bindViewModel:(YMMyEarningsWithdrawalAmountCellViewModel*)viewModel{
  58. if (!viewModel) {
  59. return;
  60. }
  61. _viewModel = viewModel;
  62. self.withdrawalAmountLb.text = stringFormat(@"%ld元",self.viewModel.withdrawalAmount);
  63. self.withdrawalPointsRequirementLb.text = stringFormat(@"%ld金币",self.viewModel.withdrawalPointsRequirement);
  64. }
  65. - (UIView *)baseView{
  66. if (!_baseView) {
  67. _baseView = [[UIView alloc]init];
  68. _baseView.backgroundColor = HexColorFromRGB(0xF9F9FA);
  69. _baseView.layer.borderColor = HexColorFromRGB(0x9500D6).CGColor;
  70. _baseView.layer.borderWidth = 0;
  71. _baseView.layer.cornerRadius = adapt(4);
  72. _baseView.layer.masksToBounds = YES;
  73. }
  74. return _baseView;
  75. }
  76. - (UILabel *)withdrawalAmountLb{
  77. if (!_withdrawalAmountLb) {
  78. _withdrawalAmountLb = [[UILabel alloc]init];
  79. _withdrawalAmountLb.font = LCBoldFont(16);
  80. _withdrawalAmountLb.textColor = HexColorFromRGB(0x000000);
  81. _withdrawalAmountLb.textAlignment = NSTextAlignmentCenter;
  82. _withdrawalAmountLb.text = @"*****元";
  83. }
  84. return _withdrawalAmountLb;
  85. }
  86. - (UILabel *)withdrawalPointsRequirementLb{
  87. if (!_withdrawalPointsRequirementLb) {
  88. _withdrawalPointsRequirementLb = [[UILabel alloc]init];
  89. _withdrawalPointsRequirementLb.font = LCFont(12);
  90. _withdrawalPointsRequirementLb.textColor = HexColorFromRGBA(0x000000,0.45);
  91. _withdrawalPointsRequirementLb.textAlignment = NSTextAlignmentCenter;
  92. _withdrawalPointsRequirementLb.text = @"*****金币";
  93. }
  94. return _withdrawalPointsRequirementLb;
  95. }
  96. @end