RQProfileViewController.m 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. //
  2. // RQProfileViewController.m
  3. // RQCommon
  4. //
  5. // Created by 张嵘 on 2018/11/21.
  6. // Copyright © 2018 张嵘. All rights reserved.
  7. //
  8. #import "RQProfileViewController.h"
  9. @interface RQProfileViewController ()
  10. /// viewModel
  11. @property (nonatomic, readonly, strong) RQProfileViewModel *viewModel;
  12. @end
  13. @implementation RQProfileViewController
  14. @dynamic viewModel;
  15. #pragma mark - SystemMethod
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. /// 初始化
  19. [self rq_setup];
  20. }
  21. - (void)viewDidLayoutSubviews {
  22. [super viewDidLayoutSubviews];
  23. }
  24. - (void)dealloc {
  25. }
  26. #pragma mark - PrivateMethods
  27. /// 初始化
  28. - (void)rq_setup {
  29. }
  30. #pragma mark - OverrideMethods
  31. /// 配置tableView的区域
  32. - (UIEdgeInsets)contentInset {
  33. return UIEdgeInsetsMake(0, 0, RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT + RQ_APPLICATION_TAB_BAR_HEIGHT, 0);
  34. }
  35. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
  36. switch (indexPath.section) {
  37. case 0: {
  38. return [RQProfileUserAndVipCell cellWithCollectionView:collectionView forIndexPath:indexPath];
  39. }
  40. case 1: {
  41. return [RQProfilePracticeCell cellWithCollectionView:collectionView forIndexPath:indexPath];
  42. }
  43. default:
  44. return [super collectionView:collectionView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
  45. }
  46. }
  47. - (void)configureCell:(UICollectionViewCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
  48. switch (indexPath.section) {
  49. case 0: {
  50. RQProfileUserAndVipCell *profileUserAndVipCell = (RQProfileUserAndVipCell *)cell;
  51. [profileUserAndVipCell bindViewModel:object];
  52. break;
  53. }
  54. case 1: {
  55. RQProfilePracticeCell *profilePracticeCell = (RQProfilePracticeCell *)cell;
  56. [profilePracticeCell bindViewModel:object];
  57. break;
  58. }
  59. default:
  60. [super configureCell:cell atIndexPath:indexPath withObject:object];
  61. break;
  62. }
  63. }
  64. - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
  65. return UIEdgeInsetsZero;
  66. }
  67. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
  68. return 0;
  69. }
  70. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
  71. return 0;
  72. }
  73. - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
  74. if (kind == UICollectionElementKindSectionHeader) {
  75. switch (indexPath.section) {
  76. case 2:
  77. case 3:
  78. case 4:{
  79. RQProfileUserAndVipHeaderView *profileUserAndVipHeaderView = [RQProfileUserAndVipHeaderView reusableViewWithCollectionView:collectionView OfKind:kind forIndexPath:indexPath];
  80. RQProfileUserAndVipHeaderGroupViewModel *profileUserAndVipHeaderGroupViewModel = self.viewModel.dataSource[indexPath.section];
  81. [profileUserAndVipHeaderView bindViewModel:profileUserAndVipHeaderGroupViewModel];
  82. profileUserAndVipHeaderView.headerContentLabel.hidden = YES;
  83. profileUserAndVipHeaderView.footerContentLabel.hidden = YES;
  84. return profileUserAndVipHeaderView;
  85. }
  86. default: {
  87. RQCommonReusableView *headerView = [RQCommonReusableView reusableViewWithCollectionView:collectionView OfKind:kind forIndexPath:indexPath];
  88. RQCommonReusableView *groupViewModel = self.viewModel.dataSource[indexPath.section];
  89. [headerView bindViewModel:groupViewModel];
  90. headerView.headerContentLabel.hidden = NO;
  91. headerView.footerContentLabel.hidden = YES;
  92. return headerView;
  93. }
  94. }
  95. } else {
  96. switch (indexPath.section) {
  97. default: {
  98. RQCommonReusableView *footerView = [RQCommonReusableView reusableViewWithCollectionView:collectionView OfKind:kind forIndexPath:indexPath];
  99. RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section];
  100. [footerView bindViewModel:groupViewModel];
  101. footerView.headerContentLabel.hidden = YES;
  102. footerView.footerContentLabel.hidden = NO;
  103. return footerView;
  104. }
  105. }
  106. }
  107. }
  108. @end