12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- //
- // NYFailSpecialExerciseViewController.m
- // jiaPei
- //
- // Created by Ning.ge on 2024/12/11.
- // Copyright © 2024 JCZ. All rights reserved.
- //
- #import "NYFailSpecialExerciseViewController.h"
- @interface NYFailSpecialExerciseViewController ()
- /// viewModel
- @property (nonatomic, readonly, strong) NYFailSpecialExerciseViewModel *viewModel;
- @end
- @implementation NYFailSpecialExerciseViewController
- @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;
- }
- #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 {
- [cell bindViewModel:object];
- }
- - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
- return UIEdgeInsetsMake(0, 16, 0, 16);
- }
- - (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:[NYFailSpecialExerciseGroupViewModel class]]) {
- NYFailSpecialExerciseHeaderView *headerView = [NYFailSpecialExerciseHeaderView reusableViewWithCollectionView:collectionView OfKind:kind forIndexPath:indexPath];
- 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
|