// // TrainSituationViewController.m // LN_School // // Created by 张嵘 on 2019/7/31. // Copyright © 2019 Danson. All rights reserved. // #import "TrainSituationViewController.h" #import "TrainSituationViewModel.h" #import "StudentDetailViewController.h" @interface TrainSituationViewController () @property (nonatomic, readwrite, strong) HDCollectionView *collectionView; @property (nonatomic, readwrite, strong) TrainSituationViewModel *trainSituationViewModel; @end @implementation TrainSituationViewController #pragma mark - Life Cycle - (void)viewDidLoad { [super viewDidLoad]; [self initUI]; } #pragma mark - Private Functions - (void)initUI { self.title = @"培训情况"; self.view.backgroundColor = KBackGroundColor; [self goBackByNavigation]; [self.view addSubview:self.collectionView]; [_collectionView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.view.hd_mas_left); make.right.mas_equalTo(self.view.hd_mas_right); make.bottom.mas_equalTo(self.view.hd_mas_bottom); make.top.mas_equalTo(self.view.hd_mas_top); }]; /// 初始化数据 __weak typeof(self) weakS = self; [self.trainSituationViewModel loadData:^(BOOL success, id _Nonnull res) { if (success) { [_collectionView hd_setAllDataArr:res]; }else{ //error } }]; [_collectionView hd_setAllEventCallBack:^(id backModel, HDCallBackType type) { if (type == HDCellCallBack) { [weakS clickCell:backModel]; }else if (type == HDSectionHeaderCallBack){ [weakS clickHeader:backModel]; } }]; } - (void)clickCell:(HDCellModel*)cellM { NSLog(@"点击了%zd--%zd cell",cellM.indexP.section,cellM.indexP.item); StudentDetailViewController *vc = [[StudentDetailViewController alloc] init]; [self navPushHideTabbarToVC:vc]; } - (void)clickHeader:(HDSectionModel*)secM { NSLog(@"点击了段头"); } #pragma mark - Lazy Load - (HDCollectionView *)collectionView { if (!_collectionView) { _collectionView = [HDCollectionView hd_makeHDCollectionView:^(HDCollectionViewMaker *maker) { maker .hd_isNeedTopStop(YES) .hd_scrollDirection(UICollectionViewScrollDirectionVertical); }]; _collectionView.backgroundColor = RQBackGroundColor; } return _collectionView; } - (TrainSituationViewModel *)trainSituationViewModel { if (!_trainSituationViewModel) { _trainSituationViewModel = [[TrainSituationViewModel alloc] init]; } return _trainSituationViewModel; } @end