// // YMMyEarningsWithdrawalAmountCell.m // MSYOUPAI // // Created by YoMi on 2024/2/29. // Copyright © 2024 MS. All rights reserved. // #import "YMMyEarningsWithdrawalAmountCell.h" #import "YMMyEarningsWithdrawalAmountCellViewModel.h" @interface YMMyEarningsWithdrawalAmountCell() /// ViewModel @property (nonatomic, strong) YMMyEarningsWithdrawalAmountCellViewModel *viewModel; /// 基础视图 @property (nonatomic, strong) UIView *baseView; /// 提现金额标签 @property (nonatomic, strong) UILabel *withdrawalAmountLb; /// 提现金币要求标签 @property (nonatomic, strong) UILabel *withdrawalPointsRequirementLb; @end @implementation YMMyEarningsWithdrawalAmountCell - (void)setSelected:(BOOL)selected{ [super setSelected:selected]; if (selected) { self.baseView.layer.borderWidth = adapt(1); self.baseView.backgroundColor = HexColorFromRGBA(0xFFBEF1, 0.3); }else{ self.baseView.layer.borderWidth = 0; self.baseView.backgroundColor = HexColorFromRGB(0xF9F9FA); } } - (void)ym_setupViews{ self.contentView.backgroundColor = UIColor.clearColor; self.backgroundColor = UIColor.clearColor; [self.contentView addSubview:self.baseView]; [self.baseView addSubview:self.withdrawalAmountLb]; [self.baseView addSubview:self.withdrawalPointsRequirementLb]; [self setNeedsUpdateConstraints]; [self updateConstraintsIfNeeded]; } - (void)updateConstraints { [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.contentView); make.left.equalTo(self.contentView); make.right.equalTo(self.contentView); make.bottom.equalTo(self.contentView); }]; [self.withdrawalAmountLb mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.baseView.mas_centerX); make.bottom.equalTo(self.baseView.mas_centerY).offset(adapt(-5)); }]; [self.withdrawalPointsRequirementLb mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.baseView.mas_centerX); make.top.equalTo(self.baseView.mas_centerY).offset(adapt(5)); }]; [super updateConstraints]; } - (void)ym_bindViewModel:(YMMyEarningsWithdrawalAmountCellViewModel*)viewModel{ if (!viewModel) { return; } _viewModel = viewModel; self.withdrawalAmountLb.text = stringFormat(@"%ld元",self.viewModel.withdrawalAmount); self.withdrawalPointsRequirementLb.text = stringFormat(@"%ld金币",self.viewModel.withdrawalPointsRequirement); } - (UIView *)baseView{ if (!_baseView) { _baseView = [[UIView alloc]init]; _baseView.backgroundColor = HexColorFromRGB(0xF9F9FA); _baseView.layer.borderColor = HexColorFromRGB(0x9500D6).CGColor; _baseView.layer.borderWidth = 0; _baseView.layer.cornerRadius = adapt(4); _baseView.layer.masksToBounds = YES; } return _baseView; } - (UILabel *)withdrawalAmountLb{ if (!_withdrawalAmountLb) { _withdrawalAmountLb = [[UILabel alloc]init]; _withdrawalAmountLb.font = LCBoldFont(16); _withdrawalAmountLb.textColor = HexColorFromRGB(0x000000); _withdrawalAmountLb.textAlignment = NSTextAlignmentCenter; _withdrawalAmountLb.text = @"*****元"; } return _withdrawalAmountLb; } - (UILabel *)withdrawalPointsRequirementLb{ if (!_withdrawalPointsRequirementLb) { _withdrawalPointsRequirementLb = [[UILabel alloc]init]; _withdrawalPointsRequirementLb.font = LCFont(12); _withdrawalPointsRequirementLb.textColor = HexColorFromRGBA(0x000000,0.45); _withdrawalPointsRequirementLb.textAlignment = NSTextAlignmentCenter; _withdrawalPointsRequirementLb.text = @"*****金币"; } return _withdrawalPointsRequirementLb; } @end