// // YMEditProfileIntroView.m // MSYOUPAI // // Created by YoMi on 2024/2/18. // Copyright © 2024 MS. All rights reserved. // #import "YMEditProfileIntroView.h" #import "YMEditProfileViewModel.h" @interface YMEditProfileIntroView () /// 信息VM @property (nonatomic, strong) YMEditProfileViewModel *viewModel; /// 介绍标题标签 @property (nonatomic, strong) UILabel *introTitleLb; /// 介绍详情标签 @property (nonatomic, strong) UILabel *introDetailLb; /// 介绍内容标签 @property (nonatomic, strong) UILabel *introContentLb; /// 箭头图标 @property (nonatomic, strong) UIImageView *arrowIcon; @end @implementation YMEditProfileIntroView - (void)ym_setupViews{ [self addSubview:self.introTitleLb]; [self addSubview:self.introDetailLb]; [self addSubview:self.introContentLb]; [self addSubview:self.arrowIcon]; [self setNeedsUpdateConstraints]; [self updateConstraintsIfNeeded]; } - (void)updateConstraints{ [self.introTitleLb mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self).offset(adapt(10)); make.left.equalTo(self).offset(adapt(15)); make.height.mas_equalTo(adapt(25)); }]; [self.introDetailLb mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.introTitleLb.mas_centerY); make.right.equalTo(self.arrowIcon.mas_left).offset(adapt(-10)); }]; [self.introContentLb mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.introTitleLb.mas_bottom).offset(adapt(10)); make.left.equalTo(self).offset(adapt(15)); make.right.equalTo(self).offset(adapt(-15)); make.bottom.equalTo(self).offset(adapt(-20)); }]; [self.arrowIcon mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.introTitleLb.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:(YMEditProfileViewModel *)viewModel{ if (!viewModel) { return; } _viewModel = viewModel; @weakify(self) [[[[RACObserve(self.viewModel, userIntro) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSString * userIntro) { @strongify(self) self.introContentLb.text = OCStringIsEmpty(userIntro) ? @"添加自我介绍,更容易获得别人的关注哦~" : userIntro; self.introDetailLb.hidden = !OCStringIsEmpty(userIntro) ? YES : NO; }]; } - (UILabel *)introTitleLb{ if (!_introTitleLb) { _introTitleLb = [[UILabel alloc]init]; _introTitleLb.font = LCBoldFont(16); _introTitleLb.textColor = HexColorFromRGB(0x333333); _introTitleLb.textAlignment = NSTextAlignmentLeft; _introTitleLb.text = @"个性签名"; } return _introTitleLb; } - (UILabel *)introDetailLb{ if (!_introDetailLb) { _introDetailLb = [[UILabel alloc]init]; _introDetailLb.font = LCFont(13); _introDetailLb.textColor = HexColorFromRGB(0x9c9c9c); _introDetailLb.textAlignment = NSTextAlignmentRight; _introDetailLb.text = @"去完善"; } return _introDetailLb; } - (UILabel *)introContentLb{ if (!_introContentLb) { _introContentLb = [[UILabel alloc]init]; _introContentLb.font = LCFont(12); _introContentLb.textColor = HexColorFromRGB(0x9c9c9c); _introContentLb.textAlignment = NSTextAlignmentLeft; _introContentLb.text = @"添加自我介绍,更容易获得别人的关注哦~"; } return _introContentLb; } - (UIImageView *)arrowIcon{ if (!_arrowIcon) { _arrowIcon = [[UIImageView alloc]init]; _arrowIcon.image = ImageByName(@"ym_edit_profile_arrow_icon"); } return _arrowIcon; } @end