// // YMSettingCell.m // MSYOUPAI // // Created by YoMi on 2024/2/21. // Copyright © 2024 MS. All rights reserved. // #import "YMSettingCell.h" #import "YMSettingCellViewModel.h" @interface YMSettingCell () /// 设置VM @property (nonatomic, strong) YMSettingCellViewModel *viewModel; /// 基础视图 @property (nonatomic, strong) UIView *baseView; /// 设置标题标签 @property (nonatomic, strong) UILabel *settingTitleLb; /// 设置详情标签 @property (nonatomic, strong) UILabel *settingDetailLb; /// 设置内容标签 @property (nonatomic, strong) UILabel *settingContentLb; /// 箭头图标 @property (nonatomic, strong) UIImageView *arrowIcon; @end @implementation YMSettingCell - (void)awakeFromNib { [super awakeFromNib]; // Initialization code } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } - (void)ym_setupViews{ [self.contentView addSubview:self.baseView]; [self.baseView addSubview:self.settingTitleLb]; [self.baseView addSubview:self.settingDetailLb]; [self.baseView addSubview:self.settingContentLb]; [self.baseView addSubview:self.arrowIcon]; [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.settingTitleLb mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.baseView.mas_centerY); make.left.equalTo(self.baseView).offset(adapt(15)); }]; [self.settingDetailLb mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.settingTitleLb.mas_centerY); make.left.equalTo(self.settingTitleLb.mas_right).offset(adapt(5)); }]; [self.settingContentLb mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.settingTitleLb.mas_centerY); make.right.equalTo(self.arrowIcon.mas_left).offset(adapt(-10)); }]; [self.arrowIcon mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.settingTitleLb.mas_centerY); make.right.equalTo(self).offset(adapt(-15)); make.width.mas_equalTo(adapt(10)); make.height.mas_equalTo(adapt(9)); }]; [super updateConstraints]; } - (void)ym_bindViewModel:(YMSettingCellViewModel *)viewModel{ if (!viewModel) { return; } _viewModel = viewModel; self.settingTitleLb.text = self.viewModel.settingTitle; self.settingDetailLb.text = self.viewModel.settingDetail; self.settingContentLb.text = self.viewModel.settingContent; } - (UIView *)baseView{ if (!_baseView) { _baseView = [[UIView alloc]init]; } return _baseView; } - (UILabel *)settingTitleLb{ if (!_settingTitleLb) { _settingTitleLb = [[UILabel alloc]init]; _settingTitleLb.font = LCFont(15); _settingTitleLb.textColor = HexColorFromRGB(0x333333); _settingTitleLb.textAlignment = NSTextAlignmentLeft; _settingTitleLb.text = @"功能"; } return _settingTitleLb; } - (UILabel *)settingDetailLb{ if (!_settingDetailLb) { _settingDetailLb = [[UILabel alloc]init]; _settingDetailLb.font = LCFont(12); _settingDetailLb.textColor = HexColorFromRGB(0x9c9c9c); _settingDetailLb.textAlignment = NSTextAlignmentLeft; } return _settingDetailLb; } - (UILabel *)settingContentLb{ if (!_settingContentLb) { _settingContentLb = [[UILabel alloc]init]; _settingContentLb.font = LCFont(13); _settingContentLb.textColor = HexColorFromRGB(0x9c9c9c); _settingContentLb.textAlignment = NSTextAlignmentRight; } return _settingContentLb; } - (UIImageView *)arrowIcon{ if (!_arrowIcon) { _arrowIcon = [[UIImageView alloc]init]; _arrowIcon.image = ImageByName(@"ym_edit_profile_arrow_icon"); } return _arrowIcon; } @end