123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- //
- // 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
|