PreExamInfoViewModel.m 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // PreExamInfoViewModel.m
  3. // LN_School
  4. //
  5. // Created by 张嵘 on 2019/7/26.
  6. // Copyright © 2019 Danson. All rights reserved.
  7. //
  8. #import "PreExamInfoViewModel.h"
  9. #import "PreExamInfoModel.h"
  10. @implementation PreExamInfoViewModel
  11. - (void)loadData:(void (^)(BOOL, id _Nonnull))calback {
  12. //发起网络请求、处理后返回(这里省略)
  13. NSMutableArray *sectionArr = @[[self makeSecModel]].mutableCopy;
  14. //如果没有对callback强引用,外部可以不用weakSelf
  15. if (calback) {
  16. calback(YES,sectionArr);
  17. }
  18. }
  19. - (HDSectionModel*)makeSecModel {
  20. //该段cell数据源
  21. NSMutableArray *cellModelArr = @[].mutableCopy;
  22. NSInteger cellCount = 10;
  23. for (int i =0; i < cellCount; i++) {
  24. HDCellModel *model = [HDCellModel new];
  25. PreExamInfoModel *preExamInfoModel = [PreExamInfoModel new];
  26. preExamInfoModel.time = @"2012-12-12";
  27. preExamInfoModel.score = (i%2 == 0)? @"78" : @"90";
  28. preExamInfoModel.object = @"科目三";
  29. model.orgData = preExamInfoModel;
  30. model.cellSize = CGSizeMake(kScreenWidth, 80);
  31. model.cellClassStr = @"PreExamInfoCell";
  32. [cellModelArr addObject:model];
  33. }
  34. //该段layout
  35. HDYogaFlowLayout *layout = [HDYogaFlowLayout new];//isUseSystemFlowLayout为YES时只支持HDBaseLayout
  36. layout.secInset = UIEdgeInsetsMake(10, 0, 10, 0);
  37. layout.justify = YGJustifyCenter;
  38. layout.verticalGap = 10;
  39. layout.horizontalGap = 0;
  40. //该段的所有数据封装
  41. HDSectionModel *secModel = [HDSectionModel new];
  42. secModel.headerTopStopType = HDHeaderStopOnTopTypeNormal;
  43. secModel.isNeedAutoCountCellHW = NO;
  44. secModel.sectionDataArr = cellModelArr;
  45. secModel.layout = layout;
  46. return secModel;
  47. }
  48. @end