HomePageViewModel.m 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. //
  2. // HomePageViewModel.m
  3. // LN_School
  4. //
  5. // Created by 张嵘 on 2019/7/9.
  6. // Copyright © 2019 Danson. All rights reserved.
  7. //
  8. #import "HomePageViewModel.h"
  9. #import "HomePageSecOneModel.h"
  10. #import "HomePageSecHeaderModel.h"
  11. #import "HomePageSignUpSituationModel.h"
  12. #import "TrainingSituationModel.h"
  13. #import "HomePageSubViewController.h"
  14. #import "HomePageNumHeaderModel.h"
  15. @implementation HomePageViewModel
  16. - (CGSize)titleSize {
  17. return CGSizeMake(hd_deviceWidth, 88);
  18. }
  19. - (BOOL)headerStop {
  20. return YES;
  21. }
  22. - (CGFloat)listHeight {
  23. return 80 * 5 + 50 + 10;
  24. }
  25. - (NSMutableArray *)topSecArr {
  26. if (!_topSecArr) {
  27. _topSecArr = @[[self makeSecZeroModel], [self makeSecOneModel]].mutableCopy;
  28. }
  29. return _topSecArr;
  30. }
  31. - (NSMutableArray *)titles {
  32. return @[@"昨日报名",@"今日报名",@"本月报名",@"本季报名"].mutableCopy;
  33. }
  34. - (NSMutableArray*)subViewControllerSecArr {
  35. if (!_subViewControllerSecArr) {
  36. _subViewControllerSecArr = @[[self makeSecTwoModel]].mutableCopy;
  37. }
  38. return _subViewControllerSecArr;
  39. }
  40. - (NSMutableArray *)controllers {
  41. if (!_controllers) {
  42. NSMutableArray *result = @[].mutableCopy;
  43. //仅测试,所以放入同一类型VC
  44. for (int i=0; i<4; i++) {
  45. HomePageSubViewController *vc1 = [HomePageSubViewController new];
  46. HomePageNumHeaderModel *homePageNumHeaderModel = [[HomePageNumHeaderModel alloc] init];
  47. switch (i) {
  48. case 0: {
  49. homePageNumHeaderModel.leftLabelText = @"昨日报名人数:100人";
  50. break;
  51. }
  52. case 1: {
  53. homePageNumHeaderModel.leftLabelText = @"今日报名人数:100人";
  54. break;
  55. }
  56. case 2: {
  57. homePageNumHeaderModel.leftLabelText = @"本月报名人数:200人";
  58. break;
  59. }
  60. case 3: {
  61. homePageNumHeaderModel.leftLabelText = @"本季报名人数:200人";
  62. break;
  63. }
  64. default:
  65. break;
  66. }
  67. vc1.homePageNumHeaderModel = homePageNumHeaderModel;
  68. [result addObject:vc1];
  69. }
  70. _controllers = result;
  71. }
  72. return _controllers;
  73. }
  74. - (NSMutableArray *)bottomSecArr {
  75. if (!_bottomSecArr) {
  76. _bottomSecArr = @[].mutableCopy;
  77. [_bottomSecArr addObject:[self makeSecThreeModel]];
  78. }
  79. return _bottomSecArr;
  80. }
  81. - (HDSectionModel*)makeSecZeroModel {
  82. //该段layout
  83. HDYogaFlowLayout *layout = [HDYogaFlowLayout new];
  84. layout.headerSize = CGSizeMake(kScreenWidth, kScreenWidth * (270.f / 719.f));
  85. //该段的所有数据封装
  86. HDSectionModel *secModel = [HDSectionModel new];
  87. secModel.sectionHeaderClassStr = @"HomePageADHeaderView";
  88. secModel.sectionFooterClassStr = @"CommonSecFooterView";
  89. secModel.layout = layout;
  90. return secModel;
  91. }
  92. - (HDSectionModel*)makeSecOneModel {
  93. NSArray *titlesArr = @[@"报名情况",@"预考成绩",@"预约管理",@"考试安排",@"考试统计",@"预约学车",@"教练排班",@"培训记录"];
  94. NSArray *imageName = @[@"Training",@"PreTest Results",@"ExaminationAppointment",@"ExaminationArrangements",@"ExaminationStatistics",@"MakeAnAppointmentToStudentDriver",@"CoachScheduling",@"TrainingRecords"];
  95. //该段cell数据源
  96. NSMutableArray *cellModelArr = @[].mutableCopy;
  97. NSInteger cellCount = titlesArr.count;
  98. for (int i =0; i < cellCount; i++) {
  99. HDCellModel *model = [HDCellModel new];
  100. HomePageSecOneModel *homePageSecOneModel = [HomePageSecOneModel new];
  101. homePageSecOneModel.title = titlesArr[i];
  102. homePageSecOneModel.imageName = imageName[i];
  103. model.orgData = homePageSecOneModel;
  104. model.cellSize = CGSizeMake(kScreenWidth/4.f, kScreenWidth/4.f);
  105. model.cellClassStr = @"HomePageSecOneCell";
  106. [cellModelArr addObject:model];
  107. }
  108. //该段layout
  109. HDYogaFlowLayout *layout = [HDYogaFlowLayout new];
  110. layout.secInset = UIEdgeInsetsMake(0, 0, 0, 0);
  111. layout.justify = YGJustifyCenter;
  112. layout.verticalGap = 0;
  113. layout.horizontalGap = 0;
  114. layout.headerSize = CGSizeZero;
  115. layout.footerSize = CGSizeMake(kScreenWidth, 54);
  116. //该段的所有数据封装
  117. HDSectionModel *secModel = [HDSectionModel new];
  118. secModel.sectionFooterClassStr = @"HomePageNoticFooterView";
  119. secModel.sectionDataArr = cellModelArr;
  120. secModel.layout = layout;
  121. return secModel;
  122. }
  123. - (HDSectionModel*)makeSecNoticModel {
  124. //该段layout
  125. HDYogaFlowLayout *layout = [HDYogaFlowLayout new];//isUseSystemFlowLayout为YES时只支持HDBaseLayout
  126. layout.secInset = UIEdgeInsetsMake(0, 10, 0, 10);
  127. layout.justify = YGJustifyCenter;
  128. layout.headerSize = CGSizeMake(kScreenWidth, 44);
  129. layout.footerSize = CGSizeMake(kScreenWidth, 10);
  130. //该段的所有数据封装
  131. HDSectionModel *secModel = [HDSectionModel new];
  132. secModel.sectionHeaderClassStr = @"HomePageNoticHeaderView";
  133. secModel.sectionFooterClassStr = @"CommonSecFooterView";
  134. secModel.isNeedAutoCountCellHW = NO;
  135. secModel.layout = layout;
  136. HomePageSecHeaderModel *headerModel = [[HomePageSecHeaderModel alloc] init];
  137. headerModel.title = @"培训情况";
  138. secModel.headerObj = headerModel;
  139. return secModel;
  140. }
  141. - (HDSectionModel*)makeSecTwoModel {
  142. NSMutableArray *cellModelArr = @[].mutableCopy;
  143. NSInteger cellCount = 5;
  144. for (int i =0; i < cellCount; i++) {
  145. HDCellModel *model = [HDCellModel new];
  146. HomePageSignUpSituationModel *homePageSignUpSituationModel = [HomePageSignUpSituationModel new];
  147. homePageSignUpSituationModel.imageName = @"HeaderPlacehold";
  148. homePageSignUpSituationModel.name = @"张三丰";
  149. homePageSignUpSituationModel.sex = @"女";
  150. homePageSignUpSituationModel.school = @"金安驾校";
  151. model.orgData = homePageSignUpSituationModel;
  152. model.cellSize = CGSizeMake(kScreenWidth, 80);
  153. model.cellClassStr = @"HomePageSignUpSituationCell";
  154. [cellModelArr addObject:model];
  155. }
  156. //该段layout
  157. HDYogaFlowLayout *layout = [HDYogaFlowLayout new];//isUseSystemFlowLayout为YES时只支持HDBaseLayout
  158. layout.justify = YGJustifySpaceBetween;
  159. layout.headerSize = CGSizeMake(kScreenWidth, 50);
  160. layout.footerSize = CGSizeMake(kScreenWidth, 10);
  161. //该段的所有数据封装
  162. HDSectionModel *secModel = [HDSectionModel new];
  163. secModel.sectionHeaderClassStr = @"HomePageNumHeaderView";
  164. secModel.sectionFooterClassStr = @"CommonSecFooterView";
  165. secModel.headerTopStopType = HDHeaderStopOnTopTypeNormal;
  166. secModel.isNeedAutoCountCellHW = NO;
  167. secModel.sectionDataArr = cellModelArr;
  168. secModel.layout = layout;
  169. return secModel;
  170. }
  171. - (HDSectionModel*)makeSecThreeModel {
  172. //该段cell数据源
  173. NSMutableArray *cellModelArr = @[].mutableCopy;
  174. NSInteger cellCount = 10;
  175. for (int i =0; i < cellCount; i++) {
  176. HDCellModel *model = [HDCellModel new];
  177. TrainingSituationModel *trainingSituationModel = [TrainingSituationModel new];
  178. trainingSituationModel.imageName = @"HeaderPlacehold";
  179. trainingSituationModel.name = @"张三丰";
  180. trainingSituationModel.carType = @"C1";
  181. trainingSituationModel.totalHours = @"24";
  182. trainingSituationModel.finishedHours = @"2";
  183. model.orgData = trainingSituationModel;
  184. model.cellSize = CGSizeMake(kScreenWidth, 80);
  185. model.cellClassStr = @"TrainingSituationCell";
  186. [cellModelArr addObject:model];
  187. }
  188. //该段layout
  189. HDYogaFlowLayout *layout = [HDYogaFlowLayout new];//isUseSystemFlowLayout为YES时只支持HDBaseLayout
  190. layout.secInset = UIEdgeInsetsMake(0, 10, 0, 10);
  191. layout.justify = YGJustifyCenter;
  192. layout.verticalGap = 0;
  193. layout.horizontalGap = 0;
  194. layout.headerSize = CGSizeMake(kScreenWidth, 44);
  195. layout.footerSize = CGSizeMake(0, 0);
  196. //该段的所有数据封装
  197. HDSectionModel *secModel = [HDSectionModel new];
  198. secModel.sectionHeaderClassStr = @"HomePageSectionThreeHeaderView";
  199. secModel.sectionFooterClassStr = @"CommonSecFooterView";
  200. secModel.headerTopStopType = HDHeaderStopOnTopTypeNormal;
  201. secModel.isNeedAutoCountCellHW = NO;
  202. secModel.sectionDataArr = cellModelArr;
  203. secModel.layout = layout;
  204. HomePageSecHeaderModel *headerModel = [[HomePageSecHeaderModel alloc] init];
  205. headerModel.title = @"培训情况";
  206. secModel.headerObj = headerModel;
  207. return secModel;
  208. }
  209. @end