CNLiveCMineInteTaskViewController.m
7.66 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
//
// CNLiveCMineInteTaskViewController.m
// CNLiveCMineModule
//
// Created by open on 2021/12/30.
//
#import "CNLiveCMineInteTaskViewController.h"
#import "CNLiveCMineInteTaskListViewController.h"
static NSInteger const kCNLiveSectionTitleHeight = 44;//标题显示
static NSInteger const kCNLiveSectionHeaderHeight = 140;//头视图高度
@interface CNLiveCMineInteTaskViewController ()<JXCategoryViewDelegate,JXPagerViewDelegate>
@property (nonatomic, strong) NSMutableArray<CNLiveCMineInteTaskListViewController *> *viewControllers;
@property (nonatomic, strong) CNLiveCMineInteTaskListModel * taskModel;//数据源
@property (nonatomic, strong) CNLiveNavigationBar * navigationBar;//导航栏
@property (nonatomic, strong) JXCategoryTitleView *categoryView;
@property (nonatomic, strong) JXPagerView *pagingView;
@property (nonatomic, strong) UIImageView * backView;
@property (nonatomic, assign) CGFloat header_height;//高度
@end
@implementation CNLiveCMineInteTaskViewController
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.navigationController.navigationBarHidden = YES;
}
-(void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
self.navigationController.navigationBarHidden = NO;
}
- (instancetype)initWithTaskModel:(CNLiveCMineInteTaskListModel *)taskModel
{
self = [super init];
if (self) {
_taskModel = taskModel;
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.header_height = kCNLiveSectionHeaderHeight + (kCNLiveSectionTitleHeight/2);
self.view.backgroundColor = UIColorHex(0xf9f9f9);
[self.view addSubview:self.backView];
[self.view addSubview:self.pagingView];
[self.view addSubview:self.navigationBar];
}
#pragma mark - JXPagingViewDelegate
- (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
UIView * headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kCNLiveSectionHeaderHeight)];
headerView.backgroundColor = [UIColor clearColor];
return headerView;
}
- (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
return kCNLiveSectionHeaderHeight;
}
- (NSUInteger)heightForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
return kCNLiveSectionTitleHeight;
}
- (UIView *)viewForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
return self.categoryView;
}
- (NSInteger)numberOfListsInPagerView:(JXPagerView *)pagerView {
return 2;
}
- (id<JXPagerViewListViewDelegate>)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index {
return self.viewControllers[index];
}
- (void)pagerView:(JXPagerView *)pagerView mainTableViewDidScroll:(UIScrollView *)scrollView {
CGFloat offsetY = scrollView.contentOffset.y;
self.backView.height = offsetY < 0 ? self.header_height + fabs(offsetY) : self.header_height;
self.backView.width = offsetY < 0 ? SCREEN_WIDTH + fabs(offsetY) : SCREEN_WIDTH;
self.backView.left = self.backView.width > SCREEN_WIDTH ? -(self.backView.width - SCREEN_WIDTH)/2 : 0;
}
-(UIStatusBarStyle)preferredStatusBarStyle
{
if (@available(iOS 13.0, *)) {
return UIStatusBarStyleDarkContent;
} else {
return UIStatusBarStyleDefault;
}
}
#pragma mark =
-(NSMutableArray<CNLiveCMineInteTaskListViewController *> *)viewControllers
{
if (!_viewControllers) {
_viewControllers = [[NSMutableArray alloc] initWithArray:@[
[[CNLiveCMineInteTaskListViewController alloc] initWithTaskArray:self.taskModel.dailyTask TaskVC:self],
[[CNLiveCMineInteTaskListViewController alloc] initWithTaskArray:self.taskModel.firstTask TaskVC:self]
]];
}
return _viewControllers;
}
#pragma mark = getter
-(JXPagerView *)pagingView
{
if (_pagingView == nil) {
_pagingView = [[JXPagerView alloc] initWithDelegate:self listContainerType:JXPagerListContainerType_CollectionView];
_pagingView.frame = CGRectMake(0, kNavigationBarHeight, KScreenWidth, KScreenHeight);
_pagingView.backgroundColor = kClearColor;
_pagingView.mainTableView.backgroundColor = kClearColor;
_pagingView.pinSectionHeaderVerticalOffset = kCNLiveSectionHeaderHeight;
_pagingView.automaticallyDisplayListVerticalScrollIndicator = NO;
_pagingView.listContainerView.categoryNestPagingEnabled = YES;
self.categoryView.listContainer = (id<JXCategoryViewListContainer>)self.pagingView.listContainerView;
}
return _pagingView;
}
- (JXCategoryTitleView *)categoryView {
if (_categoryView == nil) {
_categoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, kCNLiveSectionTitleHeight)];
_categoryView.titles = @[@"每日任务",@"首次任务"];
_categoryView.titleFont = [UIFont systemFontOfSize:15.0f];
_categoryView.titleSelectedFont = [UIFont systemFontOfSize:16.0f];
_categoryView.titleSelectedFont = [UIFont boldSystemFontOfSize:16.0f];
_categoryView.titleColor = UIColorHex(#999999);
_categoryView.titleSelectedColor = UIColorHex(#333333);
_categoryView.collectionView.backgroundColor = [UIColor clearColor];
_categoryView.backgroundColor = [UIColor clearColor];
_categoryView.separatorLineShowEnabled = YES;
_categoryView.delegate = self;
JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
lineView.indicatorColor = UIColorHex(#0AC94A);
lineView.verticalMargin = 5;
lineView.indicatorWidth = 10;
_categoryView.indicators = @[lineView];
UIView * radiusView = [[UIView alloc] initWithFrame:CGRectMake(15, 0, kScreenWidth - 30, kCNLiveSectionTitleHeight)];
radiusView.backgroundColor = [UIColor whiteColor];
radiusView.layer.shadowColor = [UIColor blackColor].CGColor;
radiusView.layer.shadowOffset = CGSizeMake(0, 0);
radiusView.layer.shadowOpacity = 0.3;
radiusView.layer.shadowRadius = 8;
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_WIDTH - 30, kCNLiveSectionTitleHeight) byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(12, 12)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.path = maskPath.CGPath;
radiusView.layer.mask = maskLayer;
[_categoryView insertSubview:radiusView belowSubview:_categoryView.collectionView];
}
return _categoryView;
}
- (CNLiveNavigationBar *)navigationBar {
if (!_navigationBar) {
_navigationBar = [CNLiveNavigationBar navigationBar];
_navigationBar.leftImage = [CNLiveCMineService imageWithMineName:@"c_mine_skip_push_back"];
__weak typeof(self) weakSelf = self;
_navigationBar.lineHidden = YES;
_navigationBar.backgroundColor = [UIColor whiteColor];
_navigationBar.onClickLeftButton = ^{
[weakSelf.navigationController popViewControllerAnimated:YES];
};
_navigationBar.title.text = @"做任务 赚积分";
_navigationBar.title.textColor = UIColorHex(#3A3A3A);
_navigationBar.right.hidden = YES;
}
return _navigationBar;
}
-(UIImageView *)backView
{
if (!_backView) {
_backView = [[UIImageView alloc] initWithFrame:CGRectMake(0, kNavigationBarHeight, kScreenWidth, kCNLiveSectionHeaderHeight + (kCNLiveSectionTitleHeight/2))];
_backView.contentMode = UIViewContentModeScaleToFill;
_backView.clipsToBounds = YES;
_backView.backgroundColor = UIColorHex(0xf9f9f9);
_backView.image = [CNLiveCMineService imageWithMineName:@"c_mine_content_task_groud"];
}
return _backView;
}
@end