RQTimeViewController.m 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // RQTimeViewController.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2021/11/19.
  6. // Copyright © 2021 JCZ. All rights reserved.
  7. //
  8. #import "RQTimeViewController.h"
  9. @interface RQTimeViewController ()
  10. /// viewModel
  11. @property (nonatomic, readonly, strong) RQTimeViewModel *viewModel;
  12. @end
  13. @implementation RQTimeViewController
  14. @dynamic viewModel;
  15. #pragma mark - SystemMethod
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. // Do any additional setup after loading the view.
  19. }
  20. #pragma mark - OverrideMethods
  21. /// 配置collectionView的区域
  22. - (UIEdgeInsets)contentInset {
  23. return UIEdgeInsetsMake(RQ_APPLICATION_STATUS_BAR_HEIGHT + RQ_APPLICATION_NAV_BAR_HEIGHT, 0, RQ_APPLICATION_TAB_BAR_HEIGHT + RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT, 0);
  24. }
  25. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
  26. RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section];
  27. RQCommonCollectionItemViewModel *itemViewModel = groupViewModel.itemViewModels[indexPath.row];
  28. return [NSClassFromString(itemViewModel.itemClassName) cellWithCollectionView:collectionView forIndexPath:indexPath];
  29. }
  30. - (void)configureCell:(RQCommonCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
  31. [cell bindViewModel:object];
  32. }
  33. - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
  34. switch (section) {
  35. case 1: {
  36. return UIEdgeInsetsMake(0, 16, 0, 16);
  37. }
  38. default: {
  39. return UIEdgeInsetsZero;
  40. }
  41. }
  42. }
  43. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
  44. switch (section) {
  45. case 1:
  46. return (RQ_SCREEN_WIDTH - 32 - (RQ_FIT_HORIZONTAL(90.f) * 3)) / 2.f;
  47. default:
  48. return 8;
  49. }
  50. }
  51. @end