// // HomePageViewModel.m // LN_School // // Created by 张嵘 on 2019/7/9. // Copyright © 2019 Danson. All rights reserved. // #import "HomePageViewModel.h" #import "HomePageSecOneModel.h" #import "HomePageSecHeaderModel.h" #import "HomePageSignUpSituationModel.h" #import "TrainingSituationModel.h" #import "HomePageSubViewController.h" #import "HomePageNumHeaderModel.h" @implementation HomePageViewModel - (CGSize)titleSize { return CGSizeMake(hd_deviceWidth, 88); } - (BOOL)headerStop { return YES; } - (CGFloat)listHeight { return 80 * 5 + 50 + 10; } - (NSMutableArray *)topSecArr { if (!_topSecArr) { _topSecArr = @[[self makeSecZeroModel], [self makeSecOneModel]].mutableCopy; } return _topSecArr; } - (NSMutableArray *)titles { return @[@"昨日报名",@"今日报名",@"本月报名",@"本季报名"].mutableCopy; } - (NSMutableArray*)subViewControllerSecArr { if (!_subViewControllerSecArr) { _subViewControllerSecArr = @[[self makeSecTwoModel]].mutableCopy; } return _subViewControllerSecArr; } - (NSMutableArray *)controllers { if (!_controllers) { NSMutableArray *result = @[].mutableCopy; //仅测试,所以放入同一类型VC for (int i=0; i<4; i++) { HomePageSubViewController *vc1 = [HomePageSubViewController new]; HomePageNumHeaderModel *homePageNumHeaderModel = [[HomePageNumHeaderModel alloc] init]; switch (i) { case 0: { homePageNumHeaderModel.leftLabelText = @"昨日报名人数:100人"; break; } case 1: { homePageNumHeaderModel.leftLabelText = @"今日报名人数:100人"; break; } case 2: { homePageNumHeaderModel.leftLabelText = @"本月报名人数:200人"; break; } case 3: { homePageNumHeaderModel.leftLabelText = @"本季报名人数:200人"; break; } default: break; } vc1.homePageNumHeaderModel = homePageNumHeaderModel; [result addObject:vc1]; } _controllers = result; } return _controllers; } - (NSMutableArray *)bottomSecArr { if (!_bottomSecArr) { _bottomSecArr = @[].mutableCopy; [_bottomSecArr addObject:[self makeSecThreeModel]]; } return _bottomSecArr; } - (HDSectionModel*)makeSecZeroModel { //该段layout HDYogaFlowLayout *layout = [HDYogaFlowLayout new]; layout.headerSize = CGSizeMake(kScreenWidth, kScreenWidth * (270.f / 719.f)); //该段的所有数据封装 HDSectionModel *secModel = [HDSectionModel new]; secModel.sectionHeaderClassStr = @"HomePageADHeaderView"; secModel.sectionFooterClassStr = @"CommonSecFooterView"; secModel.layout = layout; return secModel; } - (HDSectionModel*)makeSecOneModel { NSArray *titlesArr = @[@"报名情况",@"预考成绩",@"预约管理",@"考试安排",@"考试统计",@"预约学车",@"教练排班",@"培训记录"]; NSArray *imageName = @[@"Training",@"PreTest Results",@"ExaminationAppointment",@"ExaminationArrangements",@"ExaminationStatistics",@"MakeAnAppointmentToStudentDriver",@"CoachScheduling",@"TrainingRecords"]; //该段cell数据源 NSMutableArray *cellModelArr = @[].mutableCopy; NSInteger cellCount = titlesArr.count; for (int i =0; i < cellCount; i++) { HDCellModel *model = [HDCellModel new]; HomePageSecOneModel *homePageSecOneModel = [HomePageSecOneModel new]; homePageSecOneModel.title = titlesArr[i]; homePageSecOneModel.imageName = imageName[i]; model.orgData = homePageSecOneModel; model.cellSize = CGSizeMake(kScreenWidth/4.f, kScreenWidth/4.f); model.cellClassStr = @"HomePageSecOneCell"; [cellModelArr addObject:model]; } //该段layout HDYogaFlowLayout *layout = [HDYogaFlowLayout new]; layout.secInset = UIEdgeInsetsMake(0, 0, 0, 0); layout.justify = YGJustifyCenter; layout.verticalGap = 0; layout.horizontalGap = 0; layout.headerSize = CGSizeZero; layout.footerSize = CGSizeMake(kScreenWidth, 54); //该段的所有数据封装 HDSectionModel *secModel = [HDSectionModel new]; secModel.sectionFooterClassStr = @"HomePageNoticFooterView"; secModel.sectionDataArr = cellModelArr; secModel.layout = layout; return secModel; } - (HDSectionModel*)makeSecNoticModel { //该段layout HDYogaFlowLayout *layout = [HDYogaFlowLayout new];//isUseSystemFlowLayout为YES时只支持HDBaseLayout layout.secInset = UIEdgeInsetsMake(0, 10, 0, 10); layout.justify = YGJustifyCenter; layout.headerSize = CGSizeMake(kScreenWidth, 44); layout.footerSize = CGSizeMake(kScreenWidth, 10); //该段的所有数据封装 HDSectionModel *secModel = [HDSectionModel new]; secModel.sectionHeaderClassStr = @"HomePageNoticHeaderView"; secModel.sectionFooterClassStr = @"CommonSecFooterView"; secModel.isNeedAutoCountCellHW = NO; secModel.layout = layout; HomePageSecHeaderModel *headerModel = [[HomePageSecHeaderModel alloc] init]; headerModel.title = @"培训情况"; secModel.headerObj = headerModel; return secModel; } - (HDSectionModel*)makeSecTwoModel { NSMutableArray *cellModelArr = @[].mutableCopy; NSInteger cellCount = 5; for (int i =0; i < cellCount; i++) { HDCellModel *model = [HDCellModel new]; HomePageSignUpSituationModel *homePageSignUpSituationModel = [HomePageSignUpSituationModel new]; homePageSignUpSituationModel.imageName = @"HeaderPlacehold"; homePageSignUpSituationModel.name = @"张三丰"; homePageSignUpSituationModel.sex = @"女"; homePageSignUpSituationModel.school = @"金安驾校"; model.orgData = homePageSignUpSituationModel; model.cellSize = CGSizeMake(kScreenWidth, 80); model.cellClassStr = @"HomePageSignUpSituationCell"; [cellModelArr addObject:model]; } //该段layout HDYogaFlowLayout *layout = [HDYogaFlowLayout new];//isUseSystemFlowLayout为YES时只支持HDBaseLayout layout.justify = YGJustifySpaceBetween; layout.headerSize = CGSizeMake(kScreenWidth, 50); layout.footerSize = CGSizeMake(kScreenWidth, 10); //该段的所有数据封装 HDSectionModel *secModel = [HDSectionModel new]; secModel.sectionHeaderClassStr = @"HomePageNumHeaderView"; secModel.sectionFooterClassStr = @"CommonSecFooterView"; secModel.headerTopStopType = HDHeaderStopOnTopTypeNormal; secModel.isNeedAutoCountCellHW = NO; secModel.sectionDataArr = cellModelArr; secModel.layout = layout; return secModel; } - (HDSectionModel*)makeSecThreeModel { //该段cell数据源 NSMutableArray *cellModelArr = @[].mutableCopy; NSInteger cellCount = 10; for (int i =0; i < cellCount; i++) { HDCellModel *model = [HDCellModel new]; TrainingSituationModel *trainingSituationModel = [TrainingSituationModel new]; trainingSituationModel.imageName = @"HeaderPlacehold"; trainingSituationModel.name = @"张三丰"; trainingSituationModel.carType = @"C1"; trainingSituationModel.totalHours = @"24"; trainingSituationModel.finishedHours = @"2"; model.orgData = trainingSituationModel; model.cellSize = CGSizeMake(kScreenWidth, 80); model.cellClassStr = @"TrainingSituationCell"; [cellModelArr addObject:model]; } //该段layout HDYogaFlowLayout *layout = [HDYogaFlowLayout new];//isUseSystemFlowLayout为YES时只支持HDBaseLayout layout.secInset = UIEdgeInsetsMake(0, 10, 0, 10); layout.justify = YGJustifyCenter; layout.verticalGap = 0; layout.horizontalGap = 0; layout.headerSize = CGSizeMake(kScreenWidth, 44); layout.footerSize = CGSizeMake(0, 0); //该段的所有数据封装 HDSectionModel *secModel = [HDSectionModel new]; secModel.sectionHeaderClassStr = @"HomePageSectionThreeHeaderView"; secModel.sectionFooterClassStr = @"CommonSecFooterView"; secModel.headerTopStopType = HDHeaderStopOnTopTypeNormal; secModel.isNeedAutoCountCellHW = NO; secModel.sectionDataArr = cellModelArr; secModel.layout = layout; HomePageSecHeaderModel *headerModel = [[HomePageSecHeaderModel alloc] init]; headerModel.title = @"培训情况"; secModel.headerObj = headerModel; return secModel; } @end