al
liurenjie
2021-07-03 1b73d5d0b495f2d643c2523e1b8399f925b4f702
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
//
//  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