NYLIVipAuthorityNewCell.m 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // NYLIVipAuthorityNewCell.m
  3. // jiaPei
  4. //
  5. // Created by Ning.ge on 2025/2/6.
  6. // Copyright © 2025 JCZ. All rights reserved.
  7. //
  8. #import "NYLIVipAuthorityNewCell.h"
  9. @interface NYLIVipAuthorityNewCell ()
  10. @property (nonatomic, readwrite, strong) NYLIVipAuthorityNewItemViewModel *viewModel;
  11. @property (weak, nonatomic) IBOutlet UIImageView *bgImageView;
  12. @property (weak, nonatomic) IBOutlet UILabel *title_label01;
  13. @property (weak, nonatomic) IBOutlet UILabel *title_label02;
  14. @property (weak, nonatomic) IBOutlet UILabel *title_label03;
  15. @end
  16. @implementation NYLIVipAuthorityNewCell
  17. #pragma mark - PublicMethods
  18. + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath {
  19. static NSString *ID = @"NYLIVipAuthorityNewCell";
  20. [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID];
  21. NYLIVipAuthorityNewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
  22. if (!cell) cell = [self rq_viewFromXib];
  23. return cell;
  24. }
  25. - (void)bindViewModel:(NYLIVipAuthorityNewItemViewModel *)viewModel {
  26. @weakify(self)
  27. _viewModel = viewModel;
  28. [[[RACObserve(viewModel, bgImageName) deliverOnMainThread] takeUntil:self.rac_prepareForReuseSignal] subscribeNext:^(id _Nullable x) {
  29. @strongify(self)
  30. self.bgImageView.image = RQImageNamed(viewModel.bgImageName);
  31. }];
  32. RAC(self.title_label01, text) = [[RACObserve(viewModel, authorityTitle) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
  33. RAC(self.title_label02, text) = [[RACObserve(viewModel, authorityTitle01) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
  34. RAC(self.title_label03, text) = [[RACObserve(viewModel, authorityTitle02) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
  35. }
  36. #pragma mark - SystemMethods
  37. - (void)awakeFromNib {
  38. [super awakeFromNib];
  39. // Initialization code
  40. }
  41. @end