// // YMEditProfileInfoCell.m // MSYOUPAI // // Created by YoMi on 2024/2/18. // Copyright © 2024 MS. All rights reserved. // #import "YMEditProfileInfoCell.h" #import "YMEditProfileInfoCellViewModel.h" @interface YMEditProfileInfoCell () /// 信息VM @property (nonatomic, strong) YMEditProfileInfoCellViewModel *viewModel; /// 基础视图 @property (nonatomic, strong) UIView *baseView; /// 信息标题标签 @property (nonatomic, strong) UILabel *infoTitleLb; /// 信息内容标签 @property (nonatomic, strong) UILabel *infoContentLb; /// 箭头图标 @property (nonatomic, strong) UIImageView *arrowIcon; @end @implementation YMEditProfileInfoCell - (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.infoTitleLb]; [self.baseView addSubview:self.infoContentLb]; [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.infoTitleLb mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.baseView.mas_centerY); make.left.equalTo(self.baseView).offset(adapt(15)); }]; [self.infoContentLb mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.infoTitleLb.mas_centerY); make.right.equalTo(self.arrowIcon.mas_left).offset(adapt(-10)); }]; [self.arrowIcon mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.infoTitleLb.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:(YMEditProfileInfoCellViewModel *)viewModel{ if (!viewModel) { return; } _viewModel = viewModel; self.infoTitleLb.text = self.viewModel.infoTitle; self.infoContentLb.text = self.viewModel.infoContent; self.infoContentLb.textColor = self.viewModel.infoContentColor; } - (UIView *)baseView{ if (!_baseView) { _baseView = [[UIView alloc]init]; } return _baseView; } - (UILabel *)infoTitleLb{ if (!_infoTitleLb) { _infoTitleLb = [[UILabel alloc]init]; _infoTitleLb.font = LCBoldFont(16); _infoTitleLb.textColor = HexColorFromRGB(0x333333); _infoTitleLb.textAlignment = NSTextAlignmentLeft; _infoTitleLb.text = @"信息"; } return _infoTitleLb; } - (UILabel *)infoContentLb{ if (!_infoContentLb) { _infoContentLb = [[UILabel alloc]init]; _infoContentLb.font = LCFont(13); _infoContentLb.textColor = HexColorFromRGB(0x9c9c9c); _infoContentLb.textAlignment = NSTextAlignmentRight; _infoContentLb.text = @"去完善"; } return _infoContentLb; } - (UIImageView *)arrowIcon{ if (!_arrowIcon) { _arrowIcon = [[UIImageView alloc]init]; _arrowIcon.image = ImageByName(@"ym_edit_profile_arrow_icon"); } return _arrowIcon; } @end