// // YMReportReasonCell.m // MSYOUPAI // // Created by YoMi on 2024/3/5. // Copyright © 2024 MS. All rights reserved. // #import "YMReportReasonCell.h" #import "YMReportReasonCellViewModel.h" @interface YMReportReasonCell() /// ViewModel @property (nonatomic, strong) YMReportReasonCellViewModel *viewModel; /// 基础视图 @property (nonatomic, strong) UIView *baseView; /// 举报原因名称标签 @property (nonatomic, strong) UILabel *reportReasonNameLb; /// 选中图标 @property (nonatomic, strong) UIImageView *selectedIcon; @end @implementation YMReportReasonCell - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; if (selected) { self.selectedIcon.image = ImageByName(@"ym_member_center_pay_selected_icon"); } else { self.selectedIcon.image = ImageByName(@"ym_member_center_pay_normal_icon"); } } - (void)ym_setupViews{ self.contentView.backgroundColor = UIColor.clearColor; self.backgroundColor = UIColor.clearColor; [self.contentView addSubview:self.baseView]; [self.baseView addSubview:self.reportReasonNameLb]; [self.baseView addSubview:self.selectedIcon]; [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.reportReasonNameLb mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.baseView.mas_centerY); make.left.equalTo(self.baseView).offset(adapt(15)); }]; [self.selectedIcon mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.baseView.mas_centerY); make.right.equalTo(self.baseView).offset(adapt(-15)); make.width.height.mas_equalTo(adapt(30)); }]; [super updateConstraints]; } - (void)ym_bindViewModel:(YMReportReasonCellViewModel*)viewModel{ if (!viewModel) { return; } _viewModel = viewModel; self.reportReasonNameLb.text = self.viewModel.reportReasonName; } - (UIView *)baseView{ if (!_baseView) { _baseView = [[UIView alloc]init]; } return _baseView; } - (UILabel *)reportReasonNameLb{ if (!_reportReasonNameLb) { _reportReasonNameLb = [[UILabel alloc]init]; _reportReasonNameLb.font = LCFont(14); _reportReasonNameLb.textColor = HexColorFromRGB(0x333333); _reportReasonNameLb.textAlignment = NSTextAlignmentLeft; _reportReasonNameLb.text = @"******"; } return _reportReasonNameLb; } - (UIImageView *)selectedIcon{ if (!_selectedIcon) { _selectedIcon = [[UIImageView alloc]init]; _selectedIcon.image = ImageByName(@"ym_member_center_pay_normal_icon"); } return _selectedIcon; } @end