// // RQProfileUserInfoCell.m // SDJK // // Created by 张嵘 on 2021/7/30. // #import "RQProfileUserInfoCell.h" @interface RQProfileUserInfoCell () @property (nonatomic, readwrite, strong) RQProfileUserInfoItemViewModel *viewModel; @property (weak, nonatomic) IBOutlet UIImageView *headImageView; @property (weak, nonatomic) IBOutlet UILabel *nickNameLabel; @property (weak, nonatomic) IBOutlet UILabel *telePhoneLabel; @end @implementation RQProfileUserInfoCell #pragma mark - PublicMethods + (instancetype)cellWithTableView:(UITableView *)tableView { static NSString *ID = @"RQProfileUserInfoCell"; RQProfileUserInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; if (!cell) { cell = [self rq_viewFromXib]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } return cell; } - (void)bindViewModel:(RQProfileUserInfoItemViewModel *)viewModel { _viewModel = viewModel; @weakify(self); [[RACObserve(viewModel, headImageName) takeUntil:self.rac_prepareForReuseSignal] subscribeNext:^(NSString *imageName) { @strongify(self); [self.headImageView yy_setImageWithURL:[NSURL URLWithString:imageName] placeholder:RQWebAvatarImagePlaceholder() options:RQWebImageOptionAutomatic completion:^(UIImage * _Nullable image, NSURL * _Nonnull url, YYWebImageFromType from, YYWebImageStage stage, NSError * _Nullable error) { if(image) { image = [image scaledToSize:CGSizeMake(46, 46)]; image = [image qmui_imageWithClippedCornerRadius:23]; self.headImageView.image = image; } }]; }]; RAC(_nickNameLabel, text) = [RACObserve(viewModel, nickname) takeUntil:self.rac_prepareForReuseSignal]; // RAC(_telePhoneLabel, text) = [RACObserve(viewModel, telePhone) takeUntil:self.rac_prepareForReuseSignal]; } #pragma mark - SystemMethods - (void)awakeFromNib { [super awakeFromNib]; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end