// // RQSpecialAddCell.m // jiaPei // // Created by 张嵘 on 2022/6/22. // Copyright © 2022 JCZ. All rights reserved. // #import "RQSpecialAddCell.h" @interface RQSpecialAddCell () @property (nonatomic, readwrite, strong) RQSpecialAddItemViewModel *viewModel; @property (weak, nonatomic) IBOutlet UIImageView *myBgImageView; @property (weak, nonatomic) IBOutlet UILabel *myTitleLabel; @property (weak, nonatomic) IBOutlet UILabel *mySubTitleLabel; @end @implementation RQSpecialAddCell #pragma mark - PublicMethods + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath { static NSString *ID = @"RQSpecialAddCell"; [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID]; RQSpecialAddCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath]; if (!cell) cell = [self rq_viewFromXib]; return cell; } - (void)bindViewModel:(RQSpecialAddItemViewModel *)viewModel { _viewModel = viewModel; _myBgImageView.image = [UIImage imageNamed:viewModel.icon]; RAC(self.myTitleLabel, text) = [[RACObserve(viewModel, title) deliverOnMainThread] takeUntil:self.rac_prepareForReuseSignal]; 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