CNLIVEViewController.m 3.54 KB
//
//  CNLIVEViewController.m
//  CNLiveVideoClassifyKit
//
//  Created by 杨苓玉 on 08/05/2021.
//  Copyright (c) 2021 杨苓玉. All rights reserved.
//

#import "CNLIVEViewController.h"
#import <CNLiveBaseKit/CNLiveBaseKit.h>
#import "CNliveCollectionViewCell.h"
#import <CNLiveVideoClassifyKit/CNLivevideoClassifyPCH.h>
#import <CNLiveVideoClassifyKit/CNLiveListManager.h>
#import <CNLiveNetworking.h>
#import <NSString+CNLiveExtension.h>
#import <CNLiveEnvironment/CNLiveEnvironment.h>
#import <CNUserInfoManager.h>
#import <CNLiveNetworking.h>
#import <CNLiveCommonCategory/CNLiveCommonCategory.h>
#import <MJExtension.h>
#import <CNLiveBeeHive/CNLiveBeeHive.h>
#import "CNTools.h"


#ifndef CNTouristsId
#define CNTouristsId @"100056"  //游客Id
#endif

#ifndef CNLiveNetAddGetCategoryChannels
#define CNLiveNetAddGetCategoryChannels @"CNLiveNetAddGetCategoryChannels"
#endif

@interface CNLIVEViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>
{
    NSArray *segArr;
}
@property (nonatomic, strong)UICollectionView *collectionView;
@end

@implementation CNLIVEViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    [BHConfig set:ChannelsSelectFirst value:@"0"];
    [CNTools GetClassifyChannelsUrlsAndSave];
    self.title = @"首页";
    segArr = @[@"分类",@"搜索",@"搜索文字"];
    [self.view addSubview:self.collectionView];
}
-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    self.navigationController.navigationBarHidden = NO;
}
#pragma mrk - UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return segArr.count;
}

- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    CNliveCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuseCell" forIndexPath:indexPath];
    cell.titleName = segArr[indexPath.row];
    return cell;
}
#pragma mark - UICollectionViewDelegate
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.row) {
        case 0:
        {
            CNLiveClassifySegmentController *VC = [[CNLiveClassifySegmentController alloc] init];
            [self.navigationController pushViewController:VC animated:YES];
        }
            break;
        case 1:
        {
            [CNLiveListManager pushWitnessSearchVC];
        }
            break;
        case 2:
        {
            [CNLiveListManager pushWitnessSearchVCWithSearchStr:@{@"tagId":@"1",@"tagName":@"爆料"}];
        }
            break;
        default:
            break;
    }
}
#pragma mark - Getting
-(UICollectionView *)collectionView
{
    if (!_collectionView) {
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
        layout.itemSize = CGSizeMake(100, 40);
        layout.minimumLineSpacing = 10;
        layout.minimumInteritemSpacing = 10;
        _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight) collectionViewLayout:layout];
        [_collectionView registerClass:[CNliveCollectionViewCell class] forCellWithReuseIdentifier:@"reuseCell"];
        _collectionView.delegate = self;
        _collectionView.backgroundColor = [UIColor whiteColor];
        _collectionView.dataSource = self;
    }
    return _collectionView;
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end