// // RQHomeSubPageSortViewController.m // SDJK // // Created by 张嵘 on 2021/8/5. // #import "RQHomeSubPageSortViewController.h" @interface RQHomeSubPageSortViewController () // viewModel @property (nonatomic, readwrite, strong) RQHomeSubPageSortViewModel *viewModel; @end @implementation RQHomeSubPageSortViewController @dynamic viewModel; #pragma mark - SystemMethod - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. } #pragma mark - OverrideMethods - (UIEdgeInsets)contentInset { return UIEdgeInsetsMake(RQ_APPLICATION_TOP_BAR_HEIGHT, 0, RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT, 0); } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath { switch (indexPath.section) { case 0: { return [RQHomeSubPageSortCell cellWithCollectionView:collectionView forIndexPath:indexPath]; } default: { return [super collectionView:collectionView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath]; } } } - (void)configureCell:(UICollectionViewCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object { switch (indexPath.section) { case 0: { RQHomeSubPageSortCell *homeSubPageSortCell = (RQHomeSubPageSortCell *)cell; [homeSubPageSortCell bindViewModel:object]; break; } default: { [super configureCell:cell atIndexPath:indexPath withObject:object]; break; } } } - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath { // 如果是头视图 if (kind == UICollectionElementKindSectionHeader) { RQCommonReusableView *headerView = [RQCommonReusableView reusableViewWithCollectionView:collectionView OfKind:kind forIndexPath:indexPath]; RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section]; [headerView bindViewModel:groupViewModel]; headerView.headerContentLabel.hidden = NO; headerView.footerContentLabel.hidden = YES; headerView.headerContentLabel.textColor = RQ_MAIN_TEXT_COLOR_RED; return headerView; } else { RQCommonReusableView *footerView = [RQCommonReusableView reusableViewWithCollectionView:collectionView OfKind:kind forIndexPath:indexPath]; RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section]; [footerView bindViewModel:groupViewModel]; footerView.headerContentLabel.hidden = YES; footerView.footerContentLabel.hidden = NO; return footerView; } } - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section { switch (section) { case 1: { return UIEdgeInsetsZero; } default: { return UIEdgeInsetsMake(16, 16, 16, 16); } } } @end