//
|
// RecommendController.m
|
// BuWanVideo2.0
|
//
|
// Created by Aeline on 2021/5/23.
|
// Copyright © 2021 com.yeshi.buwansheque.ios. All rights reserved.
|
//
|
|
#import "RecommendMainController.h"
|
|
#import "RecommendController.h"
|
#import "HDController.h"
|
#import "ListController.h"
|
|
@interface RecommendMainController () <ZJScrollPageViewDelegate>
|
|
@property(nonatomic, nullable, strong) ZJScrollPageView *scrollPageView;
|
|
@property (nonatomic, nullable, strong) NSMutableArray *arrayClassName;
|
@property (nonatomic, nullable, strong) NSMutableArray *arrayKeyName;
|
@end
|
|
@implementation RecommendMainController
|
|
- (instancetype)init {
|
self = [super init];
|
if (self) {
|
self.title = @"精选";
|
}
|
return self;
|
}
|
|
- (void)viewWillAppear:(BOOL)animated {
|
[super viewWillAppear:animated];
|
[self.navigationController setNavigationBarHidden:YES animated:animated];
|
self.navigationController.navigationBar.translucent = NO;
|
}
|
|
- (void)viewWillDisappear:(BOOL)animated {
|
[super viewWillDisappear:animated];
|
}
|
|
- (void)viewDidLoad {
|
[super viewDidLoad];
|
[self setuoDataConfig];
|
[self loadDataFromFile];
|
}
|
|
- (void)setuoDataConfig {
|
}
|
|
-(void)loadDataFromFile{
|
[[YTHNetInterface startInterface]cancelAll];
|
|
[[YTHNetInterface startInterface] getVideoClassWithUid:[YTHsharedManger startManger].Uid WithSystem:@"1" withBlock:^(BOOL isSuccessful, id result, NSString *error) {
|
if (isSuccessful) {
|
|
for (int i = 0; i < [result[@"Data"][@"data"] count]; i++) {
|
[self.arrayClassName addObject:result[@"Data"][@"data"][i][@"Name"]];
|
[self.arrayKeyName addObject:result[@"Data"][@"data"][i]];
|
}
|
[self setupViewConfig];
|
}
|
}];
|
|
}
|
|
- (void)setupViewConfig {
|
[self setupContentView];
|
}
|
|
- (void)setupContentView {
|
if (self.scrollPageView) {
|
[self.scrollPageView removeFromSuperview];
|
}
|
ZJSegmentStyle *style = [[ZJSegmentStyle alloc] init];
|
// 缩放标题
|
style.scaleTitle = YES;
|
// 颜色渐变
|
style.gradualChangeTitleColor = YES;
|
// 选中字体的颜色
|
style.selectedTitleColor = UICOLOR_FROM_RGB(0x159FFF, 1);
|
// 标题一般状态的颜色
|
style.normalTitleColor = UICOLOR_FROM_RGB(0x3B3B3B, 1);
|
// 标题之间的间隙
|
style.titleMargin = 23;
|
// 放大倍数
|
style.titleBigScale = 1.3;
|
// 字体
|
style.titleFont = [UIFont systemFontOfSize:14];
|
// 设置segment的高度
|
style.segmentHeight = 36;
|
style.autoAdjustTitlesWidth = YES;
|
|
// 初始化
|
ZJScrollPageView *scrollPageView = [[ZJScrollPageView alloc] initWithFrame:CGRectMake(0, kStatusBarH + ALNavBarH, KScreenW, KScreenH - kStatusBarH - ALNavBarH - ALTabBar_H) segmentStyle:style titles:self.arrayClassName parentViewController:self delegate:self];
|
self.scrollPageView = scrollPageView;
|
[self.view addSubview:self.scrollPageView];
|
}
|
|
#pragma mark --- ZJScrollPageViewDelegate ---
|
- (NSInteger)numberOfChildViewControllers {
|
return self.arrayClassName.count;
|
}
|
|
- (UIViewController<ZJScrollPageViewChildVcDelegate> *)childViewController:(UIViewController<ZJScrollPageViewChildVcDelegate> *)reuseViewController forIndex:(NSInteger)index {
|
|
UIViewController<ZJScrollPageViewChildVcDelegate> *childVc = reuseViewController;
|
if (!childVc) {
|
NSString *type = self.arrayKeyName[index][@"DataType"];
|
if ([type containsString:@"recommend"]) {
|
RecommendController *vc = [[RecommendController alloc] init];
|
vc.parms = _arrayKeyName[index];
|
childVc = vc;
|
|
} else if ([type containsString:@"class"]) {
|
ListController *vc = [[ListController alloc] init];
|
vc.parms = _arrayKeyName[index];
|
childVc = vc;
|
}
|
|
// if (index == 0) {
|
//
|
//
|
// } else if (index == 1) {
|
// LifeHomeController *vc = [[LifeHomeController alloc] init];
|
// childVc = vc;
|
//
|
// } else if (index == 2) {
|
// HDController *vc = [[HDController alloc] init];
|
// childVc = vc;
|
//
|
// } else {
|
//
|
// }
|
}
|
return childVc;
|
}
|
|
- (NSMutableArray *)arrayClassName {
|
if (!_arrayClassName) {
|
_arrayClassName = [[NSMutableArray alloc] init];
|
}
|
return _arrayClassName;
|
}
|
|
- (NSMutableArray *)arrayKeyName {
|
if (!_arrayKeyName) {
|
_arrayKeyName = [[NSMutableArray alloc] init];
|
}
|
return _arrayKeyName;
|
}
|
@end
|