TrainSituationViewModel.m 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // TrainSituationViewModel.m
  3. // LN_School
  4. //
  5. // Created by 张嵘 on 2019/7/31.
  6. // Copyright © 2019 Danson. All rights reserved.
  7. //
  8. #import "TrainSituationViewModel.h"
  9. #import "TrainSituationModel.h"
  10. #import "TrainSituationNumHeaderModel.h"
  11. @implementation TrainSituationViewModel
  12. - (void)loadData:(void (^)(BOOL, id _Nonnull))calback {
  13. //发起网络请求、处理后返回(这里省略)
  14. NSMutableArray *sectionArr = @[[self makeSecModel]].mutableCopy;
  15. //如果没有对callback强引用,外部可以不用weakSelf
  16. if (calback) {
  17. calback(YES,sectionArr);
  18. }
  19. }
  20. - (HDSectionModel*)makeSecModel {
  21. //该段cell数据源
  22. NSMutableArray *cellModelArr = @[].mutableCopy;
  23. NSInteger cellCount = 10;
  24. for (int i =0; i < cellCount; i++) {
  25. HDCellModel *model = [HDCellModel new];
  26. TrainSituationModel *trainSituationModel = [TrainSituationModel new];
  27. trainSituationModel.imageName = @"HeaderPlacehold";
  28. trainSituationModel.name = @"张三丰";
  29. trainSituationModel.carType = @"C1";
  30. trainSituationModel.totalHours = @"24";
  31. trainSituationModel.finishedHours = @"2";
  32. model.orgData = trainSituationModel;
  33. model.cellSize = CGSizeMake(kScreenWidth, 80);
  34. model.cellClassStr = @"TrainSituationCell";
  35. [cellModelArr addObject:model];
  36. }
  37. //该段layout
  38. HDYogaFlowLayout *layout = [HDYogaFlowLayout new];//isUseSystemFlowLayout为YES时只支持HDBaseLayout
  39. layout.secInset = UIEdgeInsetsMake(10, 10, 0, 10);
  40. layout.justify = YGJustifyCenter;
  41. layout.verticalGap = 0;
  42. layout.horizontalGap = 0;
  43. layout.headerSize = CGSizeMake(kScreenWidth, 60);
  44. layout.footerSize = CGSizeMake(0, 0);
  45. //该段的所有数据封装
  46. HDSectionModel *secModel = [HDSectionModel new];
  47. secModel.sectionHeaderClassStr = @"HomePageNumHeaderView";
  48. secModel.headerTopStopType = HDHeaderStopOnTopTypeNormal;
  49. secModel.isNeedAutoCountCellHW = NO;
  50. secModel.sectionDataArr = cellModelArr;
  51. secModel.layout = layout;
  52. TrainSituationNumHeaderModel *trainSituationNumHeaderModel = [[TrainSituationNumHeaderModel alloc] init];
  53. trainSituationNumHeaderModel.leftLabelText = @"培训人数:2000人";
  54. trainSituationNumHeaderModel.rightLabelText = @"毕业人数:3000人";
  55. secModel.headerObj = trainSituationNumHeaderModel;
  56. return secModel;
  57. }
  58. @end