RQHomeSubPageVideoHeaderCollectionReusableView.m 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // RQHomeSubPageVideoHeaderCollectionReusableView.m
  3. // JSJP
  4. //
  5. // Created by 张嵘 on 2021/11/10.
  6. //
  7. #import "RQHomeSubPageVideoHeaderCollectionReusableView.h"
  8. @interface RQHomeSubPageVideoHeaderCollectionReusableView ()
  9. @property (nonatomic, readwrite, strong) RQHomeSubPageVideoHeaderGroupViewModel *viewModel;
  10. @property (weak, nonatomic) IBOutlet UIView *myContentView;
  11. @property (weak, nonatomic) IBOutlet UILabel *titleLabel;
  12. @property (weak, nonatomic) IBOutlet UILabel *moreLabel;
  13. @property (weak, nonatomic) IBOutlet UIImageView *rightArrow;
  14. @end
  15. @implementation RQHomeSubPageVideoHeaderCollectionReusableView
  16. + (instancetype)reusableViewWithCollectionView:(UICollectionView *)collectionView OfKind:(NSString *)elementKind forIndexPath:(NSIndexPath *)indexPath {
  17. NSString *ID = [NSString stringWithFormat:@"%@%@", @"RQHomeSubPageVideoHeaderCollectionReusableView",elementKind];
  18. [collectionView registerNib:[UINib nibWithNibName:@"RQHomeSubPageVideoHeaderCollectionReusableView" bundle:nil] forSupplementaryViewOfKind:elementKind withReuseIdentifier:ID];
  19. RQHomeSubPageVideoHeaderCollectionReusableView *reusableView = [collectionView dequeueReusableSupplementaryViewOfKind:elementKind withReuseIdentifier:ID forIndexPath:indexPath];
  20. if (!reusableView) reusableView = [self rq_viewFromXib];
  21. return reusableView;
  22. }
  23. - (void)bindViewModel:(RQHomeSubPageVideoHeaderGroupViewModel *)viewModel {
  24. self.viewModel = viewModel;
  25. self.titleLabel.text = viewModel.header;
  26. _moreLabel.hidden = RQStringIsEmpty(viewModel.header) || [viewModel.header isEqualToString:@"短视频"];
  27. _rightArrow.hidden = RQStringIsEmpty(viewModel.header) || [viewModel.header isEqualToString:@"短视频"];
  28. [_myContentView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  29. // 获取当前系统版本
  30. NSOperatingSystemVersion systemVersion = [[NSProcessInfo processInfo] operatingSystemVersion];
  31. if (systemVersion.majorVersion < 18.0) {
  32. NSLog(@"当前系统版本小于 iOS 18.0");
  33. RQVideoCatalogueViewModel *videoCatalogueViewModel = [[RQVideoCatalogueViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  34. RQViewModelUtilKey : self.viewModel.treeListModel,
  35. RQHomePageSubjectTypeKey : @(self.viewModel.homePageSubjectType),
  36. RQVideoItemIndexPathKey : @(self.viewModel.mySection),
  37. }];
  38. [RQ_APPDELEGATE.services pushViewModel:videoCatalogueViewModel animated:YES];
  39. } else {
  40. NSLog(@"当前系统版本大于 iOS 18.0");
  41. NYVideoCatalogueViewModel *videoCatalogueViewModel = [[NYVideoCatalogueViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  42. RQViewModelUtilKey : self.viewModel.treeListModel,
  43. RQHomePageSubjectTypeKey : @(self.viewModel.homePageSubjectType),
  44. RQVideoItemIndexPathKey : @(self.viewModel.mySection),
  45. }];
  46. [RQ_APPDELEGATE.services pushViewModel:videoCatalogueViewModel animated:YES];
  47. }
  48. }];
  49. }
  50. - (void)awakeFromNib {
  51. [super awakeFromNib];
  52. // Initialization code
  53. }
  54. @end