1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- //
- // ShowPhotoesViewModel.m
- // LN_School
- //
- // Created by 张嵘 on 2019/7/28.
- // Copyright © 2019 Danson. All rights reserved.
- //
- #import "ShowPhotoesViewModel.h"
- #import "ShowPhotoesModel.h"
- @implementation ShowPhotoesViewModel
- - (void)loadData:(void (^)(BOOL, id _Nonnull))calback {
- //发起网络请求、处理后返回(这里省略)
- NSMutableArray *sectionArr = @[[self makeSecModel]].mutableCopy;
- //如果没有对callback强引用,外部可以不用weakSelf
- if (calback) {
- calback(YES,sectionArr);
- }
- }
- - (HDSectionModel*)makeSecModel {
-
- //该段cell数据源
- NSMutableArray *cellModelArr = @[].mutableCopy;
- NSInteger cellCount = 10;
- for (int i =0; i < cellCount; i++) {
- HDCellModel *model = [HDCellModel new];
- ShowPhotoesModel *showPhotoesModel = [ShowPhotoesModel new];
- showPhotoesModel.url = @"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=17825117,2252669969&fm=26&gp=0.jpg";
- showPhotoesModel.name = @"抓拍照片";
- model.orgData = showPhotoesModel;
- model.cellSize = CGSizeMake((kScreenWidth - 30) / 2.f, (3 * (kScreenWidth - 30)) / 5.f);
- model.cellClassStr = @"ShowPhotoesCell";
- [cellModelArr addObject:model];
- }
-
- //该段layout
- HDYogaFlowLayout *layout = [HDYogaFlowLayout new];//isUseSystemFlowLayout为YES时只支持HDBaseLayout
- layout.secInset = UIEdgeInsetsMake(10, 10, 10, 10);
- layout.justify = YGJustifyCenter;
- layout.verticalGap = 10;
- layout.horizontalGap = 10;
-
- //该段的所有数据封装
- HDSectionModel *secModel = [HDSectionModel new];
- secModel.headerTopStopType = HDHeaderStopOnTopTypeNormal;
- secModel.isNeedAutoCountCellHW = NO;
- secModel.sectionDataArr = cellModelArr;
- secModel.layout = layout;
- return secModel;
- }
- @end
|