ExamInfoViewModel.m 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // ExamInfoViewModel.m
  3. // LN_School
  4. //
  5. // Created by 张嵘 on 2019/7/29.
  6. // Copyright © 2019 Danson. All rights reserved.
  7. //
  8. #import "ExamInfoViewModel.h"
  9. #import "ExamInfoModel.h"
  10. @implementation ExamInfoViewModel
  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. ExamInfoModel *examInfoModel = [ExamInfoModel new];
  26. examInfoModel.time = @"2012-12-12";
  27. examInfoModel.score = (i%2 == 0)? @"78" : @"90";
  28. examInfoModel.object = @"科目三";
  29. examInfoModel.address = @"黄山考场";
  30. model.orgData = examInfoModel;
  31. model.cellSize = CGSizeMake(kScreenWidth, 80);
  32. model.cellClassStr = @"ExamInfoCell";
  33. [cellModelArr addObject:model];
  34. }
  35. //该段layout
  36. HDYogaFlowLayout *layout = [HDYogaFlowLayout new];//isUseSystemFlowLayout为YES时只支持HDBaseLayout
  37. layout.secInset = UIEdgeInsetsMake(10, 0, 10, 0);
  38. layout.justify = YGJustifyCenter;
  39. layout.verticalGap = 10;
  40. layout.horizontalGap = 0;
  41. //该段的所有数据封装
  42. HDSectionModel *secModel = [HDSectionModel new];
  43. secModel.headerTopStopType = HDHeaderStopOnTopTypeNormal;
  44. secModel.isNeedAutoCountCellHW = NO;
  45. secModel.sectionDataArr = cellModelArr;
  46. secModel.layout = layout;
  47. return secModel;
  48. }
  49. @end