You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
144 lines
4.6 KiB
144 lines
4.6 KiB
4 years ago
|
//
|
||
|
// TFDiscoverViewController.m
|
||
|
// WXReader
|
||
|
//
|
||
|
// Created by 谢腾飞 on 2020/12/2.
|
||
|
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "TFDiscoverViewController.h"
|
||
|
#if TF_Enable_Comic
|
||
|
#import "TFDiscoverComicViewController.h"
|
||
|
#endif
|
||
|
|
||
|
#if TF_Enable_Book
|
||
|
#import "TFDiscoverNovelViewController.h"
|
||
|
#endif
|
||
|
|
||
|
#if TF_Enable_Audio
|
||
|
#import "TFDiscoverAudioViewController.h"
|
||
|
#endif
|
||
|
|
||
|
#import "TFLimitFreeViewController.h"
|
||
|
|
||
|
#import "SGPagingView.h"
|
||
|
|
||
|
@interface TFDiscoverViewController ()<SGPageTitleViewDelegate, SGPageContentCollectionViewDelegate>
|
||
|
|
||
|
@property (nonatomic ,strong) SGPageTitleView *pageTitleView;
|
||
|
@property (nonatomic ,strong) SGPageContentCollectionView *pageContentCollectionView;
|
||
|
@end
|
||
|
|
||
|
@implementation TFDiscoverViewController
|
||
|
|
||
|
- (void)viewDidLoad
|
||
|
{
|
||
|
[super viewDidLoad];
|
||
|
|
||
|
[self initialize];
|
||
|
[self createSubviews];
|
||
|
}
|
||
|
|
||
|
- (void)viewWillAppear:(BOOL)animated
|
||
|
{
|
||
|
[super viewWillAppear:animated];
|
||
|
|
||
|
[self setStatusBarDefaultStyle];
|
||
|
}
|
||
|
|
||
|
- (void)initialize
|
||
|
{
|
||
|
[self hiddenNavigationBarLeftButton];
|
||
|
[self hiddenSeparator];
|
||
|
}
|
||
|
|
||
|
- (void)createSubviews
|
||
|
{
|
||
|
#if TF_Enable_Comic
|
||
|
TFDiscoverComicViewController *comicVC = [[TFDiscoverComicViewController alloc] init];
|
||
|
comicVC.productionType = TFProductionTypeComic;
|
||
|
[self addChildViewController:comicVC];
|
||
|
#endif
|
||
|
|
||
|
#if TF_Enable_Book
|
||
|
TFDiscoverNovelViewController *bookVC = [[TFDiscoverNovelViewController alloc] init];
|
||
|
bookVC.productionType = TFProductionTypeNovel;
|
||
|
[self addChildViewController:bookVC];
|
||
|
#endif
|
||
|
|
||
|
#if TF_Enable_Audio
|
||
|
TFDiscoverAudioViewController *audioVC = [[TFDiscoverAudioViewController alloc] init];
|
||
|
audioVC.productionType = TFProductionTypeAudio;
|
||
|
[self addChildViewController:audioVC];
|
||
|
#endif
|
||
|
|
||
|
NSMutableArray *titleArr = [NSMutableArray array];
|
||
|
NSMutableArray *childArr = [NSMutableArray array];
|
||
|
|
||
|
for (NSNumber *siteNumber in [TFUtilsHelper getSiteState]) {
|
||
|
#if TF_Enable_Book
|
||
|
if ([siteNumber integerValue] == 1) {
|
||
|
[titleArr addObject:TFLocalizedString(@"小说")];
|
||
|
[childArr addObject:bookVC];
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
#if TF_Enable_Comic
|
||
|
if ([siteNumber integerValue] == 2) {
|
||
|
[titleArr addObject:TFLocalizedString(@"漫画")];
|
||
|
[childArr addObject:comicVC];
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
#if TF_Enable_Audio
|
||
|
if ([siteNumber integerValue] == 3) {
|
||
|
[titleArr addObject:TFLocalizedString(@"听书")];
|
||
|
[childArr addObject:audioVC];
|
||
|
}
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
if ([TFUtilsHelper getSiteState].count == 1) {
|
||
|
[titleArr removeAllObjects];
|
||
|
[titleArr addObject:TFLocalizedString(@"发现")];
|
||
|
}
|
||
|
|
||
|
self.pageContentCollectionView = [[SGPageContentCollectionView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) parentVC:self childVCs:childArr];
|
||
|
_pageContentCollectionView.delegatePageContentCollectionView = self;
|
||
|
[self.view addSubview:self.pageContentCollectionView];
|
||
|
|
||
|
self.pageConfigure.indicatorStyle = SGIndicatorStyleDynamic;
|
||
|
self.pageConfigure.indicatorHeight = 3;
|
||
|
self.pageConfigure.indicatorFixedWidth = 10;
|
||
|
self.pageConfigure.indicatorToBottomDistance = 3;
|
||
|
self.pageConfigure.titleSelectedColor = kBlackColor;
|
||
|
self.pageConfigure.titleFont = kBoldFont16;
|
||
|
self.pageConfigure.titleTextZoom = YES;
|
||
|
self.pageConfigure.titleGradientEffect = YES;
|
||
|
self.pageConfigure.titleTextZoomRatio = 0.2;
|
||
|
self.pageConfigure.indicatorDynamicWidth = 14;
|
||
|
self.pageConfigure.showIndicator = YES;
|
||
|
|
||
|
CGFloat width = 0;
|
||
|
for (NSString *obj in titleArr) {
|
||
|
CGFloat t_width = [TFViewHelper getDynamicWidthWithLabelFont:kBoldFont16 labelHeight:TFPageView_H labelText:obj maxWidth:140.0];
|
||
|
width += t_width;
|
||
|
width += kLabelHeight;
|
||
|
}
|
||
|
self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(kHalfMargin, (is_iPhoneX?kQuarterMargin:kHalfMargin) + kHalfMargin + PUB_NAVBAR_OFFSET, width, TFPageView_H) delegate:self titleNames:titleArr configure:self.pageConfigure];
|
||
|
self.pageTitleView.backgroundColor = [UIColor clearColor];
|
||
|
[self.navigationBar addSubview:_pageTitleView];
|
||
|
}
|
||
|
|
||
|
- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex
|
||
|
{
|
||
|
[self.pageContentCollectionView setPageContentCollectionViewCurrentIndex:selectedIndex];
|
||
|
}
|
||
|
|
||
|
- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex
|
||
|
{
|
||
|
[self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
|
||
|
}
|
||
|
|
||
|
@end
|