CNLiveSubSegmentController.m
7.32 KB
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
//
// CNLiveSubSegmentController.m
// CNLiveVideoClassifyKit
//
// Created by CNLive on 2021/8/30.
//
#import "CNLiveSubSegmentController.h"
#import "CNCategoryGetChannelModel.h"
#import "CNLiveListManager.h"
@interface CNLiveSubSegmentController ()
@property (nonatomic, strong)JXCategoryTitleView *myCategoryView;
@property (nonatomic, strong) QMUIButton *searchBtn;
@property (nonatomic, strong)NSArray<CNCategoryGetChannelModel*> *pageListArr;
@property (nonatomic, strong)UIColor *textColor;
@property (nonatomic, strong)NSString *backgroundColor;
@property (nonatomic, strong)NSString *backImage;
@property (nonatomic, strong)NSString *backImageH5;
@end
@implementation CNLiveSubSegmentController
-(void)dealloc
{
}
-(instancetype)initWithModel:(CNCategoryGetChannelModel *)model
{
self = [super init];
if(self){
self.pageListArr = model.pageStyleList;
if (!CNLiveStringIsEmpty(model.textColor)) {
self.textColor = CNLiveColorWithHexString(model.textColor);
}else
{
self.textColor = CNLiveColorWithHexString(@"#848494");
}
if (!CNLiveStringIsEmpty(model.backgroundColor)) {
self.backgroundColor = model.backgroundColor;
}else
{
self.backgroundColor = @"#FFFFFF";
}
self.backImageH5 = model.backgroundImgH5;
self.backImage = model.backgroundImg;
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
// 添加二级频道右侧的搜索按钮
[self.view addSubview:self.searchBtn];
self.view.backgroundColor = [UIColor clearColor];
[self handleDateWithChannelsArray];
self.myCategoryView.titles = self.titles;
if (CNLiveStringIsEmpty(self.backImage)) {
self.view.backgroundColor = CNLiveColorWithHexString(self.backgroundColor);
}
self.myCategoryView.titleColor = self.textColor;
self.myCategoryView.titleSelectedColor = self.textColor;
self.myCategoryView.cellSpacing = 32;
self.myCategoryView.contentEdgeInsetLeft = 25;
self.myCategoryView.averageCellSpacingEnabled = NO;
self.myCategoryView.titleFont = [UIFont fontWithName:@"PingFangSC-Medium" size:14];
JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
lineView.indicatorWidth = 18;
lineView.indicatorColor = self.textColor;
self.myCategoryView.indicators = @[lineView];
[self.categoryView reloadData];
self.listContainerView.scrollView.scrollEnabled = NO;
// Do any additional setup after loading the view.
}
-(void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
self.searchBtn.right = KScreenWidth-12;
self.searchBtn.centerY = self.myCategoryView.height/2;
self.myCategoryView.top = 0;
self.myCategoryView.width = self.searchBtn.left;
self.listContainerView.frame = CGRectMake(0, [self preferredCategoryViewHeight]+10, self.view.bounds.size.width, self.view.bounds.size.height - [self preferredCategoryViewHeight]);
}
#pragma mark - Method
-(void)handleDateWithChannelsArray{
[self.titles removeAllObjects];
for (CNCategoryGetChannelModel *model in self.pageListArr) {
[self.titles addObject:model.name];
}
}
// 一级频道显示隐藏时二级频道右侧的搜索按钮变宽变窄控制
- (void)layoutRightSubViewWithShow:(BOOL)show {
self.listContainerView.scrollView.scrollEnabled = !show;
if (show) {
// 正常
self.searchBtn.width = 66;
self.searchBtn.right = KScreenWidth-12;
[self.searchBtn setTitle:@"搜索" forState:UIControlStateNormal];
// if ([self.channelModel.id isEqualToString:@"219"]) {
// self.moreBtn.right = KScreenWidth-12-66-15;
// self.progressView.right = KScreenWidth-93-18-15;
// } else if ([self.channelModel.id isEqualToString:@"11"]) {
// self.historyBtn.right = KScreenWidth-93;
// }
self.myCategoryView.width = self.searchBtn.left;
} else {
// 变窄
self.searchBtn.width = 30;
self.searchBtn.right = KScreenWidth-12;
[self.searchBtn setTitle:nil forState:UIControlStateNormal];
// if ([self.channelModel.id isEqualToString:@"219"]) {
// self.moreBtn.right = KScreenWidth-12-66-15+30;
// self.progressView.right = KScreenWidth-93-18-15+30;
// } else if ([self.channelModel.id isEqualToString:@"11"]) {
// self.historyBtn.right = KScreenWidth-93+30;
// }
self.myCategoryView.width = self.searchBtn.left;
}
}
#pragma mark - Public
-(JXCategoryTitleView *)preferredCategoryView{
return [[JXCategoryTitleView alloc] init];
}
-(CGFloat)preferredCategoryViewHeight
{
return 40;
}
#pragma mark - JXCategoryListContainerViewDelegate
-(id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index
{
CNCategoryGetChannelModel *model = self.pageListArr[index];
CNLiveListManager *list = [CNLiveListManager shareListManager];
[list model:model black:_isBlack bgImage:self.backImage bgColor:self.backgroundColor bgImageH5:self.backImageH5];
list.contentVC = self;
weakself
list.scrollViewDidScrollBlock = ^(BOOL isUp) {
!weakSelf.scrollViewDidScrollBlock ?: weakSelf.scrollViewDidScrollBlock(isUp);
};
return list;
}
#pragma mark - JXCategoryListContentViewDelegate
/**
实现 <JXCategoryListContentViewDelegate> 协议方法,返回该视图控制器所拥有的「视图」
*/
- (UIView *)listView {
return self.view;
}
#pragma mark - Getting&&Setting
-(JXCategoryTitleView *)myCategoryView
{
return (JXCategoryTitleView *)self.categoryView;
}
- (QMUIButton *)searchBtn {
if (!_searchBtn) {
_searchBtn = [QMUIButton buttonWithType:UIButtonTypeCustom];
_searchBtn.frame = CGRectMake(0, 0, 66, 30);
[_searchBtn setTitle:@"搜索" forState:UIControlStateNormal];
_searchBtn.titleLabel.font = [UIFont systemFontOfSize:14.0];
if (self.isBlack) {
_searchBtn.backgroundColor = RGBA(245, 245, 245, 0.3);
[_searchBtn setTitleColor:KGray153Color forState:UIControlStateNormal];
[_searchBtn setImage:[UIImage loadBundleImage:@"ClassifySearchBlack"] forState:UIControlStateNormal];
}else
{
_searchBtn.backgroundColor = RGBA(249, 249, 249, 0.14);
[_searchBtn setTitleColor:kWhiteColor forState:UIControlStateNormal];
[_searchBtn setImage:[UIImage loadBundleImage:@"ClassifySearch"] forState:UIControlStateNormal];
}
_searchBtn.imagePosition = QMUIButtonImagePositionLeft;
_searchBtn.spacingBetweenImageAndTitle = 5;
_searchBtn.layer.cornerRadius = 15;
_searchBtn.layer.masksToBounds = YES;
[_searchBtn addTarget:self action:@selector(searchAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _searchBtn;
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end