//
//  NestSubjectViewController.m
//  JXCategoryView
//
//  Created by jiaxin on 2019/9/11.
//  Copyright © 2019 jiaxin. All rights reserved.
//

#import "SLNestSubjectViewController.h"
#import "JXCategoryTitleView.h"
#import "JXCategoryTitleBackgroundView.h"

@interface SLNestSubjectViewController ()

@property (nonatomic, strong) JXCategoryTitleBackgroundView *myCategoryView;

@end

@implementation SLNestSubjectViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationBar.hidden = YES;

    self.myCategoryView.titles = self.titles;
    self.myCategoryView.layer.masksToBounds = YES;
    self.myCategoryView.cellWidth = 70;
    self.myCategoryView.cellSpacing = 12;
    self.myCategoryView.titleFont = [UIFont systemFontOfSize:15];
    self.myCategoryView.averageCellSpacingEnabled = NO;
}

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];

    self.categoryView.frame = CGRectMake(0, 0, self.view.bounds.size.width, [self preferredCategoryViewHeight]);
    self.listContainerView.frame = CGRectMake(0, [self preferredCategoryViewHeight] + 50, self.view.bounds.size.width, self.view.bounds.size.height);
}

- (JXCategoryTitleView *)myCategoryView {
    return (JXCategoryTitleBackgroundView *)self.categoryView;
}

- (JXCategoryBaseView *)preferredCategoryView {
    return [[JXCategoryTitleBackgroundView alloc] init];
}

#pragma mark - JXCategoryViewDelegate

- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
    //作为嵌套的子容器，不需要处理侧滑手势处理。示例demo因为是继承，所以直接覆盖掉该代理方法，达到父类不调用下面一行处理侧滑手势的代码。
//    self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0);
}

#pragma mark - JXCategoryListContentViewDelegate

- (UIView *)listView {
    return self.view;
}

@end
