//
//  YMMyView.m
//  PCDBank
//
//  Created by Gusont on 2021/2/20.
//  Copyright © 2021 YMBank. All rights reserved.
//

#import "SLMyView.h"

@implementation SLMyView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self confignMyView];
    }
    return self;
}

- (void)confignMyView
{
    self.backgroundColor = SLBgColor;
    [self.mainCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
}

#pragma mark - UICollectionViewDataSource
- (nonnull __kindof UICollectionViewCell *)collectionView:(nonnull UICollectionView *)collectionView cellForItemAtIndexPath:(nonnull NSIndexPath *)indexPath {
    SLPageViewModel *viewModel = [self.viewModels objectAtIndex:indexPath.section];
    Class cellClass = viewModel.cellClass;
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass(cellClass) forIndexPath:indexPath];
    
    cell.contentView.backgroundColor = self.contentBgColor;

    //通用配置方法，cell各自实现相应的方法
//    [cell confignCellWithViewModel:[viewModel.models.details objectAtIndex:indexPath.row]];
    [cell confignCellWithModel:viewModel.pageModel];

    cell.contentView.clipsToBounds = YES;
    return cell;
}

@end
