// // 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) UIImageView *iconImgv; /// 提现金额标签 @property (nonatomic, strong) UILabel *withdrawalAmountLb; /// 提现金币要求标签 @property (nonatomic, strong) UILabel *withdrawalPointsRequirementLb; /// 选中标记 @property (nonatomic, strong) UIImageView *selectedManrkImgv; @end @implementation YMMyEarningsWithdrawalAmountCell - (void)setSelected:(BOOL)selected{ [super setSelected:selected]; if (selected) { //self.baseView.layer.borderWidth = adapt(1); //self.baseView.backgroundColor = HexColorFromRGB(0xFFFFFF); self.selectedManrkImgv.image = ImageByName(@"ym_account_balance_selected"); }else{ //self.baseView.layer.borderWidth = 0; //self.baseView.backgroundColor = HexColorFromRGB(0xF2F5FF); self.selectedManrkImgv.image = ImageByName(@"ym_account_balance_unselect"); } } - (void)ym_setupViews{ self.contentView.backgroundColor = UIColor.clearColor; self.backgroundColor = UIColor.clearColor; [self.contentView addSubview:self.baseView]; [self.baseView addSubview:self.selectedManrkImgv]; [self.baseView addSubview:self.iconImgv]; [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.selectedManrkImgv mas_makeConstraints:^(MASConstraintMaker *make) { make.top.left.bottom.right.equalTo(self.baseView); }]; [self.withdrawalAmountLb mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.baseView.mas_centerX); make.bottom.equalTo(self.baseView.mas_centerY).offset(adapt(3)); }]; [self.withdrawalPointsRequirementLb mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.withdrawalAmountLb.mas_bottom).offset(adapt(5)); make.centerX.equalTo(self.baseView.mas_centerX).offset(adapt(7)); }]; [self.iconImgv mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.withdrawalPointsRequirementLb.mas_centerY); make.right.equalTo(self.withdrawalPointsRequirementLb.mas_left).offset(adapt(0)); make.width.height.mas_equalTo(adapt(14)); }]; [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(0xF2F5FF); _baseView.backgroundColor = UIColor.clearColor; _baseView.layer.borderColor = HexColorFromRGB(0xFC5E9E).CGColor; _baseView.layer.borderWidth = 0; _baseView.layer.cornerRadius = adapt(12); _baseView.layer.masksToBounds = YES; } return _baseView; } - (UIImageView *)iconImgv { if (!_iconImgv) { _iconImgv = [[UIImageView alloc]init]; _iconImgv.image = ImageByName(@"ym_my_earnings_coin"); } return _iconImgv; } - (UILabel *)withdrawalAmountLb{ if (!_withdrawalAmountLb) { _withdrawalAmountLb = [[UILabel alloc]init]; _withdrawalAmountLb.font = LCBoldFont(18); _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(0x545D79,1); _withdrawalPointsRequirementLb.textAlignment = NSTextAlignmentCenter; _withdrawalPointsRequirementLb.text = @"*****金币"; } return _withdrawalPointsRequirementLb; } - (UIImageView *)selectedManrkImgv { if (!_selectedManrkImgv) { _selectedManrkImgv = [[UIImageView alloc] init]; _selectedManrkImgv.hidden = NO; _selectedManrkImgv.image = ImageByName(@"ym_account_balance_unselect"); } return _selectedManrkImgv; } @end