// // RQProfileViewController.m // RQCommon // // Created by 张嵘 on 2018/11/21. // Copyright © 2018 张嵘. All rights reserved. // #import "RQProfileViewController.h" @interface RQProfileViewController () /// viewModel @property (nonatomic, readonly, strong) RQProfileViewModel *viewModel; @end @implementation RQProfileViewController @dynamic viewModel; #pragma mark - SystemMethod - (void)viewDidLoad { [super viewDidLoad]; /// 初始化 [self rq_setup]; } - (void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; } - (void)dealloc { } #pragma mark - PrivateMethods /// 初始化 - (void)rq_setup { } #pragma mark - OverrideMethods /// 配置tableView的区域 - (UIEdgeInsets)contentInset { return UIEdgeInsetsMake(0, 0, RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT + RQ_APPLICATION_TAB_BAR_HEIGHT, 0); } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath { switch (indexPath.section) { case 0: { return [RQProfileUserAndVipCell cellWithCollectionView:collectionView forIndexPath:indexPath]; } case 1: { return [RQProfilePracticeCell 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: { RQProfileUserAndVipCell *profileUserAndVipCell = (RQProfileUserAndVipCell *)cell; [profileUserAndVipCell bindViewModel:object]; break; } case 1: { RQProfilePracticeCell *profilePracticeCell = (RQProfilePracticeCell *)cell; [profilePracticeCell bindViewModel:object]; break; } default: [super configureCell:cell atIndexPath:indexPath withObject:object]; break; } } - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section { return UIEdgeInsetsZero; } - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section { return 0; } - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section { return 0; } - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath { if (kind == UICollectionElementKindSectionHeader) { switch (indexPath.section) { case 2: case 3: case 4:{ RQProfileUserAndVipHeaderView *profileUserAndVipHeaderView = [RQProfileUserAndVipHeaderView reusableViewWithCollectionView:collectionView OfKind:kind forIndexPath:indexPath]; RQProfileUserAndVipHeaderGroupViewModel *profileUserAndVipHeaderGroupViewModel = self.viewModel.dataSource[indexPath.section]; [profileUserAndVipHeaderView bindViewModel:profileUserAndVipHeaderGroupViewModel]; profileUserAndVipHeaderView.headerContentLabel.hidden = YES; profileUserAndVipHeaderView.footerContentLabel.hidden = YES; return profileUserAndVipHeaderView; } default: { RQCommonReusableView *headerView = [RQCommonReusableView reusableViewWithCollectionView:collectionView OfKind:kind forIndexPath:indexPath]; RQCommonReusableView *groupViewModel = self.viewModel.dataSource[indexPath.section]; [headerView bindViewModel:groupViewModel]; headerView.headerContentLabel.hidden = NO; headerView.footerContentLabel.hidden = YES; return headerView; } } } else { switch (indexPath.section) { default: { 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; } } } } @end