// // RQSpecialQuestionCell.m // jiaPei // // Created by 张嵘 on 2022/6/22. // Copyright © 2022 JCZ. All rights reserved. // #import "RQSpecialQuestionCell.h" @interface RQSpecialQuestionCell () @property (nonatomic, readwrite, strong) RQSpecialQuestionItemViewModel *viewModel; @property (weak, nonatomic) IBOutlet UIImageView *myIconImageView; @property (weak, nonatomic) IBOutlet UILabel *myTitleLabel; @property (weak, nonatomic) IBOutlet UILabel *mySubTitleLabel; @end @implementation RQSpecialQuestionCell #pragma mark - PublicMethods + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath { static NSString *ID = @"RQSpecialQuestionCell"; [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID]; RQSpecialQuestionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath]; if (!cell) cell = [self rq_viewFromXib]; return cell; } - (void)bindViewModel:(RQSpecialQuestionItemViewModel *)viewModel { _viewModel = viewModel; _myIconImageView.image = [UIImage imageNamed:viewModel.icon]; _myTitleLabel.text = viewModel.title; RAC(self.mySubTitleLabel, text) = [[[RACObserve(viewModel, subtitle) deliverOnMainThread] map:^id _Nullable(id _Nullable value) { return RQStringIsEmpty(viewModel.subtitle)? @"..." : viewModel.subtitle; }] takeUntil:self.rac_prepareForReuseSignal]; } #pragma mark - SystemMethods - (void)awakeFromNib { [super awakeFromNib]; } @end