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.
170 lines
6.0 KiB
170 lines
6.0 KiB
4 years ago
|
//
|
||
|
// TFBookRackViewController.m
|
||
|
// WXReader
|
||
|
//
|
||
|
// Created by 谢腾飞 on 2020/12/1.
|
||
|
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "TFBookRackViewController.h"
|
||
|
#import "TFTaskViewController.h"
|
||
|
#import "TFBookRackCommViewController.h"
|
||
|
|
||
|
#if TF_Enable_Book
|
||
|
#import "TFReadNovelViewController.h"
|
||
|
#endif
|
||
|
|
||
|
#import "NSObject+DZM.h"
|
||
|
#import "UINavigationController+TFExtension.h"
|
||
|
|
||
|
@interface TFBookRackViewController ()<SGPageTitleViewDelegate, SGPageContentCollectionViewDelegate>
|
||
|
|
||
|
@property (nonatomic ,strong) SGPageTitleView *pageTitleView;
|
||
|
@property (nonatomic ,strong) SGPageContentCollectionView *pageContentView;
|
||
|
@property (nonatomic ,strong) NSMutableArray *childControllers;
|
||
|
|
||
|
@end
|
||
|
|
||
|
@implementation TFBookRackViewController
|
||
|
|
||
|
- (void)viewWillAppear:(BOOL)animated
|
||
|
{
|
||
|
[super viewWillAppear:animated];
|
||
|
|
||
|
[self setStatusBarDefaultStyle];
|
||
|
|
||
|
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Show_Tabbar object:nil];
|
||
|
}
|
||
|
|
||
|
- (void)viewDidLoad
|
||
|
{
|
||
|
[super viewDidLoad];
|
||
|
|
||
|
[self initialize];
|
||
|
[self createSubviews];
|
||
|
}
|
||
|
|
||
|
- (void)initialize
|
||
|
{
|
||
|
[self hiddenNavigationBarLeftButton];
|
||
|
[self hiddenSeparator];
|
||
|
|
||
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(synchronizationRack) name:Notification_Login_Success object:nil];
|
||
|
|
||
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(synchronizationRack) name:Notification_Reload_Rack_Production object:nil];
|
||
|
|
||
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(synchronizationRack) name:UIApplicationWillEnterForegroundNotification object:nil];
|
||
|
}
|
||
|
|
||
|
- (void)synchronizationRack
|
||
|
{
|
||
|
[TFUtilsHelper synchronizationRack];
|
||
|
}
|
||
|
|
||
|
- (void)createSubviews
|
||
|
{
|
||
|
#if TF_Enable_Book
|
||
|
WS(weakSelf)
|
||
|
TFBookRackCommViewController *novel = [[TFBookRackCommViewController alloc] init];
|
||
|
novel.productionType = TFProductionTypeNovel;
|
||
|
novel.pushToReaderViewControllerBlock = ^(UIView * _Nonnull transitionView, TFProductionModel * _Nonnull productionModel) {
|
||
|
weakSelf.ATTarget = transitionView;
|
||
|
TFReadNovelViewController *vc = [[TFReadNovelViewController alloc] init];
|
||
|
vc.book_id = productionModel.production_id;
|
||
|
[weakSelf.navigationController jumpNextViewController:vc animated:YES];
|
||
|
};
|
||
|
novel.view.backgroundColor = kWhiteColor;
|
||
|
[self addChildViewController:novel];
|
||
|
#endif
|
||
|
|
||
|
#if TF_Enable_Comic
|
||
|
TFBookRackCommViewController *comic = [[TFBookRackCommViewController alloc] init];
|
||
|
comic.productionType = TFProductionTypeComic;
|
||
|
comic.view.backgroundColor = kWhiteColor;
|
||
|
[self addChildViewController:comic];
|
||
|
#endif
|
||
|
|
||
|
#if TF_Enable_Audio
|
||
|
TFBookRackCommViewController *audio = [[TFBookRackCommViewController alloc] init];
|
||
|
audio.productionType = TFProductionTypeAudio;
|
||
|
audio.view.backgroundColor = kWhiteColor;
|
||
|
[self addChildViewController:audio];
|
||
|
#endif
|
||
|
|
||
|
NSMutableArray *titleArray = [NSMutableArray array];
|
||
|
self.childControllers = [NSMutableArray array];
|
||
|
|
||
|
for (NSNumber *siteNumber in [TFUtilsHelper getSiteState]) {
|
||
|
#if TF_Enable_Book
|
||
|
if ([siteNumber integerValue] == 1) {
|
||
|
[titleArray addObject:TFLocalizedString(@"小说")];
|
||
|
[self.childControllers addObject:novel];
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
#if TF_Enable_Comic
|
||
|
if ([siteNumber integerValue] == 2) {
|
||
|
[titleArray addObject:TFLocalizedString(@"漫画")];
|
||
|
[self.childControllers addObject:comic];
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
#if TF_Enable_Audio
|
||
|
if ([siteNumber integerValue] == 3) {
|
||
|
[titleArray addObject:TFLocalizedString(@"听书")];
|
||
|
[self.childControllers addObject:audio];
|
||
|
}
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
if ([TFUtilsHelper getSiteState].count == 1) {
|
||
|
[titleArray removeAllObjects];
|
||
|
[titleArray addObject:TFLocalizedString(@"书架")];
|
||
|
}
|
||
|
|
||
|
self.pageContentView = [[SGPageContentCollectionView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) parentVC:self childVCs:self.childControllers];
|
||
|
self.pageContentView.delegatePageContentCollectionView = self;
|
||
|
[self.view addSubview:self.pageContentView];
|
||
|
|
||
|
self.pageConfigure.indicatorStyle = SGIndicatorStyleDynamic;
|
||
|
self.pageConfigure.indicatorDynamicWidth = 14;
|
||
|
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.showIndicator = YES;
|
||
|
|
||
|
CGFloat width = 0;
|
||
|
for (NSString *obj in titleArray) {
|
||
|
CGFloat t_width = [TFViewHelper getDynamicWidthWithLabelFont:kBoldFont16 labelHeight:43.0 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:titleArray configure:self.pageConfigure];
|
||
|
self.pageTitleView.backgroundColor = [UIColor clearColor];
|
||
|
[self.navigationBar addSubview:self.pageTitleView];
|
||
|
}
|
||
|
|
||
|
- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex
|
||
|
{
|
||
|
[self.pageContentView setPageContentCollectionViewCurrentIndex:selectedIndex];
|
||
|
}
|
||
|
|
||
|
- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex
|
||
|
{
|
||
|
[self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
|
||
|
}
|
||
|
|
||
|
- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView index:(NSInteger)index
|
||
|
{
|
||
|
for (UIViewController *viewController in self.childControllers) {
|
||
|
[viewController performSelector:@selector(endEdited)];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@end
|