CoachArrangeClassViewController.m 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. //
  2. // CoachArrangeClassViewController.m
  3. // LN_School
  4. //
  5. // Created by 张嵘 on 2019/7/31.
  6. // Copyright © 2019 Danson. All rights reserved.
  7. //
  8. #import "CoachArrangeClassViewController.h"
  9. #import "CoachArrangeClassViewModel.h"
  10. #import "CoachArrangeClassFooterView.h"
  11. @interface CoachArrangeClassViewController ()
  12. @property (nonatomic, readwrite, strong) HDCollectionView *collectionView;
  13. @property (nonatomic, readwrite, strong) CoachArrangeClassViewModel *coachArrangeClassViewModel;
  14. @property (nonatomic, readwrite, strong) CoachArrangeClassFooterView *coachArrangeClassFooterView;
  15. @end
  16. @implementation CoachArrangeClassViewController
  17. #pragma mark - Life Cycle
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. [self initUI];
  21. }
  22. #pragma mark - Private Functions
  23. - (void)initUI {
  24. self.title = @"教练排班";
  25. self.view.backgroundColor = KBackGroundColor;
  26. [self goBackByNavigation];
  27. [self.view addSubview:self.collectionView];
  28. [self.view addSubview:self.coachArrangeClassFooterView];
  29. [_collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.left.mas_equalTo(self.view.hd_mas_left);
  31. make.right.mas_equalTo(self.view.hd_mas_right);
  32. make.bottom.mas_equalTo(self.view.hd_mas_bottom).mas_offset(-80);
  33. make.top.mas_equalTo(self.view.hd_mas_top);
  34. }];
  35. [_coachArrangeClassFooterView mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.left.mas_equalTo(self.view.hd_mas_left);
  37. make.right.mas_equalTo(self.view.hd_mas_right);
  38. make.bottom.mas_equalTo(self.view.hd_mas_bottom);
  39. make.height.mas_equalTo(80);
  40. }];
  41. /// 初始化数据
  42. __weak typeof(self) weakS = self;
  43. _collectionView.collectionV.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  44. [self.coachArrangeClassViewModel loadData:^(BOOL success, id _Nonnull res) {
  45. [_collectionView.collectionV.mj_header endRefreshing];
  46. if (success) {
  47. [_collectionView hd_setAllDataArr:res];
  48. }else{
  49. //error
  50. }
  51. }];
  52. }];
  53. _collectionView.collectionV.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
  54. [_collectionView.collectionV.mj_footer endRefreshing];
  55. [self.coachArrangeClassViewModel loadData:^(BOOL success, id _Nonnull res) {
  56. if (success) {
  57. [_collectionView hd_setAllDataArr:res];
  58. }else{
  59. //error
  60. }
  61. }];
  62. }];
  63. [_collectionView.collectionV.mj_header beginRefreshing];
  64. [_collectionView hd_setAllEventCallBack:^(id backModel, HDCallBackType type) {
  65. if (type == HDCellCallBack) {
  66. [weakS clickCell:backModel];
  67. }else if (type == HDSectionHeaderCallBack){
  68. [weakS clickHeader:backModel];
  69. }
  70. }];
  71. }
  72. - (void)clickCell:(HDCellModel*)cellM {
  73. NSLog(@"点击了%zd--%zd cell",cellM.indexP.section,cellM.indexP.item);
  74. }
  75. - (void)clickHeader:(HDSectionModel*)secM {
  76. NSLog(@"点击了段头");
  77. }
  78. #pragma mark - Lazy Load
  79. - (HDCollectionView *)collectionView {
  80. if (!_collectionView) {
  81. _collectionView = [HDCollectionView hd_makeHDCollectionView:^(HDCollectionViewMaker *maker) {
  82. maker
  83. .hd_isNeedTopStop(YES)
  84. .hd_scrollDirection(UICollectionViewScrollDirectionVertical);
  85. }];
  86. _collectionView.backgroundColor = RQBackGroundColor;
  87. }
  88. return _collectionView;
  89. }
  90. - (CoachArrangeClassViewModel *)coachArrangeClassViewModel {
  91. if (!_coachArrangeClassViewModel) {
  92. _coachArrangeClassViewModel = [[CoachArrangeClassViewModel alloc] init];
  93. }
  94. return _coachArrangeClassViewModel;
  95. }
  96. - (CoachArrangeClassFooterView *)coachArrangeClassFooterView {
  97. if (!_coachArrangeClassFooterView) {
  98. _coachArrangeClassFooterView = [[CoachArrangeClassFooterView alloc] init];
  99. }
  100. return _coachArrangeClassFooterView;
  101. }
  102. @end