RQHomeSubPageSortViewController.m 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //
  2. // RQHomeSubPageSortViewController.m
  3. // SDJK
  4. //
  5. // Created by 张嵘 on 2021/8/5.
  6. //
  7. #import "RQHomeSubPageSortViewController.h"
  8. @interface RQHomeSubPageSortViewController ()
  9. // viewModel
  10. @property (nonatomic, readwrite, strong) RQHomeSubPageSortViewModel *viewModel;
  11. @end
  12. @implementation RQHomeSubPageSortViewController
  13. @dynamic viewModel;
  14. #pragma mark - SystemMethod
  15. - (void)viewDidLoad {
  16. [super viewDidLoad];
  17. // Do any additional setup after loading the view.
  18. }
  19. #pragma mark - OverrideMethods
  20. - (UIEdgeInsets)contentInset {
  21. return UIEdgeInsetsMake(RQ_APPLICATION_TOP_BAR_HEIGHT, 0, RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT, 0);
  22. }
  23. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
  24. switch (indexPath.section) {
  25. case 0: {
  26. return [RQHomeSubPageSortCell cellWithCollectionView:collectionView forIndexPath:indexPath];
  27. }
  28. default: {
  29. return [super collectionView:collectionView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
  30. }
  31. }
  32. }
  33. - (void)configureCell:(UICollectionViewCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
  34. switch (indexPath.section) {
  35. case 0: {
  36. RQHomeSubPageSortCell *homeSubPageSortCell = (RQHomeSubPageSortCell *)cell;
  37. [homeSubPageSortCell bindViewModel:object];
  38. break;
  39. }
  40. default: {
  41. [super configureCell:cell atIndexPath:indexPath withObject:object];
  42. break;
  43. }
  44. }
  45. }
  46. - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
  47. // 如果是头视图
  48. if (kind == UICollectionElementKindSectionHeader) {
  49. RQCommonReusableView *headerView = [RQCommonReusableView reusableViewWithCollectionView:collectionView OfKind:kind forIndexPath:indexPath];
  50. RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section];
  51. [headerView bindViewModel:groupViewModel];
  52. headerView.headerContentLabel.hidden = NO;
  53. headerView.footerContentLabel.hidden = YES;
  54. headerView.headerContentLabel.textColor = RQ_MAIN_TEXT_COLOR_RED;
  55. return headerView;
  56. } else {
  57. RQCommonReusableView *footerView = [RQCommonReusableView reusableViewWithCollectionView:collectionView OfKind:kind forIndexPath:indexPath];
  58. RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section];
  59. [footerView bindViewModel:groupViewModel];
  60. footerView.headerContentLabel.hidden = YES;
  61. footerView.footerContentLabel.hidden = NO;
  62. return footerView;
  63. }
  64. }
  65. - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
  66. switch (section) {
  67. case 1: {
  68. return UIEdgeInsetsZero;
  69. }
  70. default: {
  71. return UIEdgeInsetsMake(16, 16, 16, 16);
  72. }
  73. }
  74. }
  75. @end