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.

116 lines
3.8 KiB

//
// TFAppraiseViewController.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/21.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFAppraiseViewController.h"
#import "TFAppraiseCommViewController.h"
@interface TFAppraiseViewController ()<SGPageTitleViewDelegate, SGPageContentCollectionViewDelegate>
@property (nonatomic ,strong) SGPageTitleView *pageTitleView;
@property (nonatomic ,strong) SGPageContentCollectionView *pageContentCollectionView;
@end
@implementation TFAppraiseViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self initialize];
[self createSubViews];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self setStatusBarDefaultStyle];
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Hidden_Tabbar object:@"1"];
}
- (void)initialize
{
[self setNavigationBarTitle:TFLocalizedString(@"我的评论")];
[self hiddenSeparator];
}
- (void)createSubViews
{
#if TF_Enable_Book
TFAppraiseCommViewController *bookVC = [[TFAppraiseCommViewController alloc] init];
bookVC.productionType = TFProductionTypeNovel;
[self addChildViewController:bookVC];
#endif
#if TF_Enable_Comic
TFAppraiseCommViewController *comicVC = [[TFAppraiseCommViewController alloc] init];
comicVC.productionType = TFProductionTypeComic;
[self addChildViewController:comicVC];
#endif
#if TF_Enable_Audio
TFAppraiseCommViewController *audioVC = [[TFAppraiseCommViewController 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.pageViewHeight = titleArr.count > 1?self.pageViewHeight:0;
self.pageContentCollectionView = [[SGPageContentCollectionView alloc] initWithFrame:CGRectMake(0, PUB_NAVBAR_HEIGHT + self.pageViewHeight, SCREEN_WIDTH, SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT - self.pageViewHeight) parentVC:self childVCs:childArr];
self.pageContentCollectionView.delegatePageContentCollectionView = self;
[self.view addSubview:self.pageContentCollectionView];
self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, self.pageViewHeight) delegate:self titleNames:titleArr configure:self.pageConfigure];
self.pageTitleView.backgroundColor = kWhiteColor;
[self.view addSubview:self.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