123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- //
- // NYFailSpecialExerciseDetailsViewController.m
- // jiaPei
- //
- // Created by Ning.ge on 2024/12/12.
- // Copyright © 2024 JCZ. All rights reserved.
- //
- #import "NYFailSpecialExerciseDetailsViewController.h"
- @interface NYFailSpecialExerciseDetailsViewController ()
- /// viewModel
- @property (nonatomic, readonly, strong) NYFailSpecialExerciseDetailsViewModel *viewModel;
- @property (nonatomic, strong) UIView *headerView;
- @end
- @implementation NYFailSpecialExerciseDetailsViewController
- @dynamic viewModel;
- #pragma mark - SystemMethod
- - (void)viewDidLoad {
- [super viewDidLoad];
- /// 初始化
- [self rq_setup];
- }
- - (void)viewDidLayoutSubviews {
- [super viewDidLayoutSubviews];
- self.view.frame = CGRectMake(0, 0, RQ_SCREEN_WIDTH, RQ_SCREEN_HEIGHT);
- }
- - (void)dealloc {
- [RQ_Video_Module.playerController stop];
- if (self.headerView) {
- [self.headerView removeFromSuperview];
- self.headerView = nil;
- }
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- RQ_Video_Module.playerController.viewControllerDisappear = NO;
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
- RQ_Video_Module.playerController.viewControllerDisappear = YES;
- }
- - (BOOL)shouldAutorotate {
- return NO;
- }
- - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
- if (RQ_Video_Module.playerController.player.isFullScreen) {
- return UIInterfaceOrientationMaskLandscape;
- }
- return UIInterfaceOrientationMaskPortrait;
- }
- #pragma mark - PrivateMethods
- /// 初始化
- - (void)rq_setup {
- /// set up ...
- self.collectionView.bounces = NO;
- self.collectionView.backgroundColor = UIColorHex(0xF2F8FF);
-
-
- [RQNotificationCenter removeObserver:self name:RQPlayVideoUrlNotification object:nil];
- /// 播放
- WeakSelf(weakSelf)
- [RQ_Video_Module.playerController stop];
- [[[[RQNotificationCenter rac_addObserverForName:RQPlayVideoUrlNotification object:nil] takeUntil:self.rac_willDeallocSignal] deliverOnMainThread] subscribeNext:^(NSNotification * note) {
- [weakSelf myVideoUrlNotification:note];
- }];
- }
- - (void)myVideoUrlNotification:(NSNotification *)note{
- NSLog(@"RQNotificationCenter-----播放---AD-广告");
- VideosItem *videosItem = note.object[RQPlayVideoItemKey];
- NSArray *videoItemArr = note.object[RQPlayVideoItemArrKey];
- if ([RQ_Video_Module isCanWatchWithVideosItem:videosItem]) {
- [RQ_Video_Module playVideoWithVideosItem:videosItem videosItemArr:videoItemArr playView:self.headerView scrollView:self.collectionView];
- }
- }
- #pragma mark - OverrideMethods
- /// 配置collectionView的区域
- - (UIEdgeInsets)contentInset {
- return UIEdgeInsetsMake(RQ_APPLICATION_STATUS_BAR_HEIGHT + RQ_APPLICATION_NAV_BAR_HEIGHT, 0, 0, 0);
- }
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
- RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section];
- RQCommonCollectionItemViewModel *itemViewModel = groupViewModel.itemViewModels[indexPath.row];
- UICollectionViewCell *cell = [NSClassFromString(itemViewModel.itemClassName) cellWithCollectionView:collectionView forIndexPath:indexPath];
- return cell;
- }
- - (void)configureCell:(RQCommonCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
- NSLog(@"configureCell=====%@",indexPath);
- [cell bindViewModel:object];
- }
- - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
- return UIEdgeInsetsMake(0, 0, 0, 0);
- }
- - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
- // @weakify(self)
- RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section];
- // 如果是头视图
- if (kind == UICollectionElementKindSectionHeader) {
- if ([groupViewModel isKindOfClass:[NYFailSpecialVideoGroupViewModel class]]) {
- NYFailSpecialVideoHeaderView *headerView = [NYFailSpecialVideoHeaderView reusableViewWithCollectionView:collectionView OfKind:kind forIndexPath:indexPath];
- self.headerView = headerView.palyerView;
- RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section];
- [headerView bindViewModel:groupViewModel];
- headerView.headerContentLabel.hidden = YES;
- headerView.footerContentLabel.hidden = YES;
- return headerView;
- }
- }
- RQCommonReusableView *headerView = [RQCommonReusableView reusableViewWithCollectionView:collectionView OfKind:kind forIndexPath:indexPath];
- [headerView bindViewModel:groupViewModel];
- headerView.headerContentLabel.hidden = YES;
- headerView.footerContentLabel.hidden = YES;
- return headerView;
- }
- @end
|