RQProfileUserInfoCell.m 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // RQProfileUserInfoCell.m
  3. // SDJK
  4. //
  5. // Created by 张嵘 on 2021/7/30.
  6. //
  7. #import "RQProfileUserInfoCell.h"
  8. @interface RQProfileUserInfoCell ()
  9. @property (nonatomic, readwrite, strong) RQProfileUserInfoItemViewModel *viewModel;
  10. @property (weak, nonatomic) IBOutlet UIImageView *headImageView;
  11. @property (weak, nonatomic) IBOutlet UILabel *nickNameLabel;
  12. @property (weak, nonatomic) IBOutlet UILabel *telePhoneLabel;
  13. @end
  14. @implementation RQProfileUserInfoCell
  15. #pragma mark - PublicMethods
  16. + (instancetype)cellWithTableView:(UITableView *)tableView {
  17. static NSString *ID = @"RQProfileUserInfoCell";
  18. RQProfileUserInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  19. if (!cell) {
  20. cell = [self rq_viewFromXib];
  21. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  22. }
  23. return cell;
  24. }
  25. - (void)bindViewModel:(RQProfileUserInfoItemViewModel *)viewModel {
  26. _viewModel = viewModel;
  27. @weakify(self);
  28. [[RACObserve(viewModel, headImageName) takeUntil:self.rac_prepareForReuseSignal] subscribeNext:^(NSString *imageName) {
  29. @strongify(self);
  30. [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) {
  31. if(image) {
  32. image = [image scaledToSize:CGSizeMake(46, 46)];
  33. image = [image qmui_imageWithClippedCornerRadius:23];
  34. self.headImageView.image = image;
  35. }
  36. }];
  37. }];
  38. RAC(_nickNameLabel, text) = [RACObserve(viewModel, nickname) takeUntil:self.rac_prepareForReuseSignal];
  39. // RAC(_telePhoneLabel, text) = [RACObserve(viewModel, telePhone) takeUntil:self.rac_prepareForReuseSignal];
  40. }
  41. #pragma mark - SystemMethods
  42. - (void)awakeFromNib {
  43. [super awakeFromNib];
  44. }
  45. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  46. [super setSelected:selected animated:animated];
  47. // Configure the view for the selected state
  48. }
  49. @end