123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- //
- // RQSpecialPractiseViewController.m
- // jiaPei
- //
- // Created by 张嵘 on 2022/6/21.
- // Copyright © 2022 JCZ. All rights reserved.
- //
- #import "RQSpecialPractiseViewController.h"
- @interface RQSpecialPractiseViewController ()
- /// viewModel
- @property (nonatomic, readonly, strong) RQHoursBeforeExamHomeViewModel *viewModel;
- @end
- @implementation RQSpecialPractiseViewController
- @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);
- }
- #pragma mark - PrivateMethods
- /// 初始化
- - (void)rq_setup {
- /// set up ...
- self.collectionView.bounces = NO;
- self.collectionView.backgroundColor = UIColor.clearColor;
- if(RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectOne && !RQ_VIP_Module.isSubject1Vip){
- [RQ_AD_MANAGER loadAdWithAdType:RQADType_InterstitialSplash customView:nil];//广告
- }
- if(RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectFour && !RQ_VIP_Module.isSubject4Vip){
- [RQ_AD_MANAGER loadAdWithAdType:RQADType_InterstitialSplash customView:nil];//广告
- }
- }
- #pragma mark - OverrideMethods
- /// 配置tableView的区域
- - (UIEdgeInsets)contentInset {
- return UIEdgeInsetsMake((RQ_APPLICATION_NAV_BAR_HEIGHT + RQ_APPLICATION_STATUS_BAR_HEIGHT), 0, RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT, 0);
- }
- /// RQHomePageSectionZeroGroupViewModel
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
- RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section];
- RQCommonCollectionItemViewModel *itemViewModel = groupViewModel.itemViewModels[indexPath.row];
- if ([itemViewModel isKindOfClass:[RQSpecialPracticeItemViewModel class]]) {
- RQSpecialPracticeCell *cell = [RQSpecialPracticeCell cellWithCollectionView:collectionView forIndexPath:indexPath];
- return cell;
- } else if ([itemViewModel isKindOfClass:[RQSpecialAddItemViewModel class]]) {
- RQSpecialAddCell *cell = [RQSpecialAddCell cellWithCollectionView:collectionView forIndexPath:indexPath];
- return cell;
- } else if ([itemViewModel isKindOfClass:[RQSpecialQuestionItemViewModel class]]) {
- RQSpecialQuestionCell *cell = [RQSpecialQuestionCell cellWithCollectionView:collectionView forIndexPath:indexPath];
- return cell;
- } else if ([itemViewModel isKindOfClass:[RQSpecialPointItemViewModel class]]) {
- RQSpecialPointCell *cell = [RQSpecialPointCell cellWithCollectionView:collectionView forIndexPath:indexPath];
- return cell;
- } else {
- return [super collectionView:collectionView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
- }
-
- }
- - (void)configureCell:(UICollectionViewCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
- RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section];
- RQCommonCollectionItemViewModel *itemViewModel = groupViewModel.itemViewModels[indexPath.row];
- if ([itemViewModel isKindOfClass:[RQSpecialPracticeItemViewModel class]]) {
- RQSpecialPracticeCell *specialPracticeCell = (RQSpecialPracticeCell *)cell;
- [specialPracticeCell bindViewModel:object];
- } else if ([itemViewModel isKindOfClass:[RQSpecialAddItemViewModel class]]) {
- RQSpecialAddCell *specialAddCell = (RQSpecialAddCell *)cell;
- [specialAddCell bindViewModel:object];
- } else if ([itemViewModel isKindOfClass:[RQSpecialQuestionItemViewModel class]]) {
- RQSpecialQuestionCell *specialQuestionCell = (RQSpecialQuestionCell *)cell;
- [specialQuestionCell bindViewModel:object];
- } else if ([itemViewModel isKindOfClass:[RQSpecialPointItemViewModel class]]) {
- RQSpecialPointCell *specialPointCell = (RQSpecialPointCell *)cell;
- [specialPointCell bindViewModel:object];
- } else {
- [super configureCell:cell atIndexPath:indexPath withObject:object];
- }
- }
- - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
- RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[section];
- RQCommonCollectionItemViewModel *itemViewModel = (groupViewModel.itemViewModels.count > 0)? groupViewModel.itemViewModels.firstObject : nil;
- if (itemViewModel) {
- if ([groupViewModel isKindOfClass:[RQHomeSubPageVideoHeaderGroupViewModel class]] || [self.viewModel.dataSource[section] isKindOfClass:[RQHomePageSectionOneGroupViewModel class]]) {
- return UIEdgeInsetsMake(0, 16, 0, 16);
- } else {
- if ([itemViewModel isKindOfClass:[RQSpecialPracticeItemViewModel class]]) {
- return UIEdgeInsetsMake(16, 16, 8, 16);
- } else if ([itemViewModel isKindOfClass:[RQSpecialAddItemViewModel class]]) {
- return UIEdgeInsetsMake(0, 16, 16, 16);
- } else if ([itemViewModel isKindOfClass:[RQSpecialQuestionItemViewModel class]]) {
- return UIEdgeInsetsMake(0, 16, 16, 16);
- } else {
- return UIEdgeInsetsZero;
- }
- }
- } else {
- return UIEdgeInsetsZero;
- }
- }
- - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
- RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[section];
- if ([groupViewModel.groupModel.header isEqualToString:@"考点练习"]) {
- return 0.f;
- } else {
- return 8.f;
- }
- }
- - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
- RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[section];
- if ([groupViewModel.groupModel.header isEqualToString:@"考点练习"]) {
- return 0.f;
- } else {
- return 8.f;
- }
- }
- - (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:[RQHomeSubPageVideoHeaderGroupViewModel class]]) {
- RQHomeSubPageVideoHeaderCollectionReusableView *headerView = [RQHomeSubPageVideoHeaderCollectionReusableView reusableViewWithCollectionView:collectionView OfKind:kind forIndexPath:indexPath];
- RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section];
- [headerView bindViewModel:groupViewModel];
- headerView.headerContentLabel.hidden = NO;
- headerView.footerContentLabel.hidden = YES;
- return headerView;
- } else if ([groupViewModel isKindOfClass:[RQHomePageSectionOneGroupViewModel class]]) {
- RQCommonReusableView *homePageSectionOneHeaderView = [RQCommonReusableView reusableViewWithCollectionView:collectionView OfKind:kind forIndexPath:indexPath];
- RQHomePageSectionOneGroupViewModel *homePageSectionOneGroupViewModel = self.viewModel.dataSource[indexPath.section];
- [homePageSectionOneHeaderView bindViewModel:homePageSectionOneGroupViewModel];
- homePageSectionOneHeaderView.headerContentLabel.hidden = YES;
- homePageSectionOneHeaderView.footerContentLabel.hidden = YES;
- homePageSectionOneHeaderView.backgroundColor = UIColor.whiteColor;
- return homePageSectionOneHeaderView;
- } else {
- RQCommonReusableView *headerView = [RQCommonReusableView reusableViewWithCollectionView:collectionView OfKind:kind forIndexPath:indexPath];
- RQCommonReusableView *groupViewModel = self.viewModel.dataSource[indexPath.section];
- [headerView bindViewModel:groupViewModel];
- return headerView;
- }
- } else {
- if ([groupViewModel isKindOfClass:[RQHomeSubPageVideoHeaderGroupViewModel class]]) {
- RQCommonReusableView *footerView = [RQCommonReusableView reusableViewWithCollectionView:collectionView OfKind:kind forIndexPath:indexPath];
- RQHomeSubPageVideoHeaderGroupViewModel *homeSubPageVideoHeaderGroupViewModel = self.viewModel.dataSource[indexPath.section];
- [footerView bindViewModel:homeSubPageVideoHeaderGroupViewModel];
- footerView.headerContentLabel.hidden = YES;
- if ([homeSubPageVideoHeaderGroupViewModel.footer isEqualToString:@"查看更多 >"]) {
- footerView.footerContentLabel.textAlignment = NSTextAlignmentCenter;
- [footerView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
- @strongify(self)
- RQDspVideoDetailViewModel *viewModel = [[RQDspVideoDetailViewModel alloc] initWithServices:self.viewModel.services params:@{
- RQViewCommonValueKey: [NSIndexPath indexPathForRow:6 inSection:0],
- }];
- [self.viewModel.services pushViewModel:viewModel animated:YES];
- }];
- footerView.backgroundColor = UIColor.whiteColor;
- footerView.footerContentLabel.hidden = NO;
- } else {
- footerView.footerContentLabel.hidden = YES;
- }
- return footerView;
- } else if ([groupViewModel isKindOfClass:[RQHomePageSectionOneGroupViewModel class]]) {
- RQCommonReusableView *homePageSectionOneFooterView = [RQCommonReusableView reusableViewWithCollectionView:collectionView OfKind:kind forIndexPath:indexPath];
- RQHomePageSectionOneGroupViewModel *homePageSectionOneGroupViewModel = self.viewModel.dataSource[indexPath.section];
- [homePageSectionOneFooterView bindViewModel:homePageSectionOneGroupViewModel];
- homePageSectionOneFooterView.headerContentLabel.hidden = YES;
- homePageSectionOneFooterView.footerContentLabel.hidden = YES;
- homePageSectionOneFooterView.backgroundColor = UIColor.whiteColor;
- return homePageSectionOneFooterView;
- } else {
- RQCommonReusableView *commonFooterView = [RQCommonReusableView reusableViewWithCollectionView:collectionView OfKind:kind forIndexPath:indexPath];
- RQCommonGroupViewModel *commonFooterGroupViewModel = self.viewModel.dataSource[indexPath.section];
- [commonFooterView bindViewModel:commonFooterGroupViewModel];
- return commonFooterView;
- }
- }
- }
- @end
|