CNLiveBalanceDetailController.m 5.26 KB
//
//  CNLiveBalanceDetailController.m
//  CNLiveBalanceModule
//
//  Created by 153993236@qq.com on 11/12/2019.
//  Copyright (c) 2019 153993236@qq.com. All rights reserved.
//

#import "CNLiveBalanceDetailController.h"
#import "QMUIKit.h"

#import "CNLiveBaseKit.h"
#import "CNLiveCategory.h"
#import "JXCategoryView.h"
#import "CNLiveNavigationBar.h"

#import "CNLiveBalanceDetailBaseController.h"

@interface CNLiveBalanceDetailController ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate>
@property (nonatomic, strong) CNLiveNavigationBar *navigationBar;
@property (nonatomic, strong) JXCategoryTitleView *titleCategoryView;
@property (nonatomic, strong) JXCategoryListContainerView *listContainerView;
@property (nonatomic, strong) NSArray *titles;

@property (nonatomic, strong) UIView *tline;
@property (nonatomic, strong) UIView *bline;

@end

@implementation CNLiveBalanceDetailController
static const CGFloat height = 44;

#pragma mark - 生命周期
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    if (@available(iOS 11, *)) {
    }
    else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    [self createSubViews];
    
}

- (void)createSubViews {
    [self.view addSubview:self.navigationBar];
    [self.view addSubview:self.tline];
    [self.view addSubview:self.titleCategoryView];
    [self.view addSubview:self.bline];
    [self.view addSubview:self.listContainerView];
    _titleCategoryView.listContainer = self.listContainerView;

}

#pragma mark - JXCategoryViewDelegate
- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
    //侧滑手势处理
}

#pragma mark - JXCategoryListContainerViewDelegate
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
    CNLiveBalanceDetailBaseController *list = [[CNLiveBalanceDetailBaseController alloc] init];
    list.type = index;
    list.ID = self.ID;
    return list;
}

- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
    return self.titles.count;
}

#pragma mark - 响应方法
- (void)goBack {
    if (self.presentingViewController != nil) {
        [self dismissViewControllerAnimated:YES completion:nil];
    }
    else {
        [self.navigationController popViewControllerAnimated:YES];
    }
}

#pragma mark - 懒加载
- (CNLiveNavigationBar *)navigationBar {
    if (!_navigationBar) {
        _navigationBar = [CNLiveNavigationBar navigationBar];
        _navigationBar.title.text = @"明细";
        __weak typeof(self) weakSelf = self;
        _navigationBar.onClickLeftButton = ^{
            __strong typeof(weakSelf) strongSelf = weakSelf;
            if(!strongSelf) return ;
            [strongSelf goBack];
        };
    }
    return _navigationBar;
}

- (UIView *)tline {
    if (!_tline) {
        _tline = [[UIView alloc] initWithFrame:CGRectMake(0, NavigationContentTop, self.view.bounds.size.width, 0.5)];
        _tline.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0];
    }
    return _tline;
}
- (JXCategoryTitleView *)titleCategoryView{
    if (!_titleCategoryView) {
        _titleCategoryView = [[JXCategoryTitleView alloc]initWithFrame:CGRectMake(0, _tline.bottom, self.view.bounds.size.width, height)];
        _titleCategoryView.titles = self.titles;
        _titleCategoryView.delegate = self;
        _titleCategoryView.titleColor = [UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0];
        _titleCategoryView.titleSelectedColor = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
        _titleCategoryView.titleFont = [UIFont systemFontOfSize:16];
        _titleCategoryView.titleLabelZoomScale = 1.0;
        _titleCategoryView.collectionView.scrollEnabled = NO;
        _titleCategoryView.titleLabelZoomEnabled = YES;
        _titleCategoryView.titleColorGradientEnabled = YES;
        JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
        lineView.indicatorColor = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
        lineView.indicatorWidth = 40;
        _titleCategoryView.indicators = @[lineView];        
    }
    return _titleCategoryView;
}

- (UIView *)bline {
    if (!_bline) {
        _bline = [[UIView alloc] initWithFrame:CGRectMake(0, _titleCategoryView.bottom, self.view.bounds.size.width, 0.5)];
        _bline.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0];
    }
    return _bline;
}

- (JXCategoryListContainerView *)listContainerView {
    if (_listContainerView == nil) {
        _listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
        _listContainerView.frame = CGRectMake(0, _bline.bottom, self.view.bounds.size.width, self.view.bounds.size.height-_bline.bottom);
    }
    return _listContainerView;
}

- (NSArray *)titles{
    if (!_titles) {
        _titles = [NSArray arrayWithObjects:@"全部", @"收入", @"支出", nil];
    }
    return _titles;
}

@end