RQSpecialPointCell.m 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // RQSpecialPointCell.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2022/6/22.
  6. // Copyright © 2022 JCZ. All rights reserved.
  7. //
  8. #import "RQSpecialPointCell.h"
  9. @interface RQSpecialPointCell ()
  10. @property (nonatomic, readwrite, strong) RQSpecialPointItemViewModel *viewModel;
  11. @property (weak, nonatomic) IBOutlet UIButton *numBtn;
  12. @property (weak, nonatomic) IBOutlet UILabel *myTitleLabel;
  13. @property (weak, nonatomic) IBOutlet UILabel *mySubTitleLabel;
  14. @end
  15. @implementation RQSpecialPointCell
  16. #pragma mark - PublicMethods
  17. + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath {
  18. static NSString *ID = @"RQSpecialPointCell";
  19. [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID];
  20. RQSpecialPointCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
  21. if (!cell) cell = [self rq_viewFromXib];
  22. cell.numBtn.layer.cornerRadius = RQ_FIT_HORIZONTAL(18.f) / 2.f;
  23. return cell;
  24. }
  25. - (void)bindViewModel:(RQSpecialPointItemViewModel *)viewModel {
  26. _viewModel = viewModel;
  27. [_numBtn setTitleNormal:viewModel.numStr];
  28. _myTitleLabel.text = viewModel.title;
  29. RAC(self.mySubTitleLabel, text) = [[[RACObserve(viewModel, subtitle) deliverOnMainThread] map:^id _Nullable(id _Nullable value) {
  30. return RQStringIsEmpty(viewModel.subtitle)? @"..." : viewModel.subtitle;
  31. }] takeUntil:self.rac_prepareForReuseSignal];
  32. }
  33. #pragma mark - SystemMethods
  34. - (void)awakeFromNib {
  35. [super awakeFromNib];
  36. }
  37. @end