//
//  SLMyListCollectionViewCell.m
//  SLAiELTS
//
//  Created by Gusont on 2023/3/9.
//

#import "SLMyListCollectionViewCell.h"
#import "SLBaseCellView.h"
#import "SLFeedbackVc.h"
#import "SLMomentsVc.h"
#import "SLUserCenterViewController.h"

@implementation SLMyListCollectionViewCell

- (void)confignCellWithModel:(SLPageModel *)pageModel {
    [self.bgView.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        [obj removeFromSuperview];
        obj = nil;
    }];
    [pageModel.modelDetails enumerateObjectsUsingBlock:^(SLPageModelDetail * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        SLBaseCellView *baseCell = [[SLBaseCellView alloc] initWithFrame:CGRectZero];
        baseCell.titleLabel.text = obj.title;
        baseCell.leftImageView.image = ImageName(obj.bgImage);
        baseCell.subTitleLabel.text = obj.subTitle;
        WS(weakSelf);
        [baseCell addTapWithBlock:^{
            switch (idx) {
                case 0:
                {
                    
                }
                    break;
                case 1:
                {
                    SLMomentsVc *vc = [SLMomentsVc loadViewControllewWithNib];
                    vc.userModel = [SLGlobalInfo SharedInstance].loginInfo.user;
                    vc.isFriendList = YES;
                    [self.viewController navPushViewController:vc animated:YES];
//                    self.viewController.rdv_tabBarController.selectedIndex = 2;
                }
                    break;
                case 2:
                {
                    SLUserCenterViewController *vc = [SLUserCenterViewController loadViewControllewWithNib];
                    [self.viewController navPushViewController:vc animated:YES];
                }
                    break;
                case 3:
                {
                    
                    SLFeedbackVc *vc = [SLFeedbackVc loadViewControllewWithNib];
                    [weakSelf.viewController navPushViewController:vc animated:YES];
                }
                    break;
                    
                default:
                    break;
            }
        }];
        [self.bgView addSubview:baseCell];
        CGFloat top = 56 * idx * KScaleW;
        [baseCell mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self.bgView);
            make.height.mas_equalTo(56 * KScaleW);
            make.top.equalTo(self.bgView).offset(top);
        }];
        
    }];
}

@end
