RQDspVideoDetailViewModel.m 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // RQDspVideoDetailViewModel.m
  3. // SDJK
  4. //
  5. // Created by RONGQING on 2022/1/19.
  6. //
  7. #import "RQDspVideoDetailViewModel.h"
  8. @interface RQDspVideoDetailViewModel ()
  9. @property (nonatomic, readwrite, strong) NSArray *videoArr;
  10. @property (nonatomic, readwrite, strong) NSIndexPath *indexPath;
  11. @end
  12. @implementation RQDspVideoDetailViewModel
  13. #pragma mark - Public Method
  14. - (instancetype)initWithServices:(id<RQViewModelServices>)services params:(NSDictionary *)params {
  15. if (self = [super initWithServices:services params:params]) {
  16. self.videoArr = RQ_COMMON_MANAGER.dspListArr;
  17. self.indexPath = params[RQViewCommonValueKey];
  18. }
  19. return self;
  20. }
  21. - (void)initialize {
  22. [super initialize];
  23. self.prefersNavigationBarHidden = YES;
  24. [self rq_configureData];
  25. }
  26. #pragma mark - PrivateMethod
  27. - (void)rq_configureData {
  28. // @weakify(self);
  29. /// 第零组
  30. RQCommonGroupViewModel *group0 = [RQCommonGroupViewModel groupViewModel];
  31. group0.headerHeight = CGFLOAT_MIN;
  32. group0.footerHeight = CGFLOAT_MIN;
  33. NSMutableArray *itemMutableArr = @[].mutableCopy;
  34. [self.videoArr.rac_sequence.signal subscribeNext:^(VideosItem *videosItem) {
  35. videosItem.index = [self.videoArr indexOfObject:videosItem] + 1;
  36. videosItem.totalNum = self.videoArr.count;
  37. RQDspVideoDetailItemViewModel *dspVideoDetailItemViewModel = [[RQDspVideoDetailItemViewModel alloc] initWithVideosItem:videosItem];
  38. dspVideoDetailItemViewModel.rowHeight = RQ_SCREEN_HEIGHT;
  39. dspVideoDetailItemViewModel.operation = ^{
  40. // @strongify(self);
  41. // [RQNotificationCenter postNotificationName:RQPlayVideoUrlNotification object:@{
  42. // RQPlayVideoItemKey : videosItem,
  43. // RQPlayVideoItemArrKey : self.videoArr,
  44. // }];
  45. };
  46. [itemMutableArr addObject:dspVideoDetailItemViewModel];
  47. } completed:^{
  48. group0.itemViewModels = itemMutableArr.copy;
  49. self.dataSource = @[group0];
  50. }];
  51. }
  52. @end