RQTimeViewController.m 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. if(RQ_USER_MANAGER.currentUser.stuNum == nil ||
  20. [RQ_USER_MANAGER.currentUser.stuNum isEqualToString:@""]){
  21. [[RQ_HTTP_Service getUserinfoWithUserId:RQ_USER_MANAGER.currentUser._id] subscribeNext:^(RQUserModel *userModel) {
  22. if(userModel){
  23. RQ_USER_MANAGER.currentUser.stuNum = userModel.stuNum;
  24. }
  25. } error:^(NSError * _Nullable error) {
  26. } completed:^{
  27. }];
  28. }
  29. }
  30. #pragma mark - OverrideMethods
  31. /// 配置collectionView的区域
  32. - (UIEdgeInsets)contentInset {
  33. return UIEdgeInsetsMake(RQ_APPLICATION_STATUS_BAR_HEIGHT + RQ_APPLICATION_NAV_BAR_HEIGHT, 0, RQ_APPLICATION_TAB_BAR_HEIGHT + RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT, 0);
  34. }
  35. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
  36. RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section];
  37. RQCommonCollectionItemViewModel *itemViewModel = groupViewModel.itemViewModels[indexPath.row];
  38. return [NSClassFromString(itemViewModel.itemClassName) cellWithCollectionView:collectionView forIndexPath:indexPath];
  39. }
  40. - (void)configureCell:(RQCommonCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
  41. [cell bindViewModel:object];
  42. }
  43. - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
  44. switch (section) {
  45. case 1: {
  46. return UIEdgeInsetsMake(0, 16, 0, 16);
  47. }
  48. default: {
  49. return UIEdgeInsetsZero;
  50. }
  51. }
  52. }
  53. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
  54. switch (section) {
  55. case 1:
  56. //理论计时,实车认证,我的学时,课堂培训
  57. return (RQ_SCREEN_WIDTH - 32 - (RQ_FIT_HORIZONTAL(90.f) * 4)) / 2.f;
  58. default:
  59. return 8;
  60. }
  61. }
  62. @end