小说绘上架版本
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// TFBookRackCommViewController.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/1.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFBookRackCommViewController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,copy) void (^pushToReaderViewControllerBlock)(UIView *transitionView, TFProductionModel *productionModel);
|
||||
|
||||
// 结束编辑状态
|
||||
- (void)endEdited;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+617
@@ -0,0 +1,617 @@
|
||||
//
|
||||
// TFBookRackCommViewController.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/1.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookRackCommViewController.h"
|
||||
|
||||
#if TF_Enable_Book
|
||||
#import "TFReadNovelViewController.h"
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
#import "TFComicBrowseViewController.h"
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
#import "TFAudioPlayViewController.h"
|
||||
#endif
|
||||
|
||||
#import "TFAnnouncementController.h"
|
||||
#import "TFTaskViewController.h"
|
||||
#import "TFBookRackCommCell.h"
|
||||
#import "TFBookRackAddMoreCell.h"
|
||||
#import "TFBookRackHeaderView.h"
|
||||
#import "TFCollectionManager.h"
|
||||
#import "TFReadRecordManager.h"
|
||||
#import "NSObject+Observer.h"
|
||||
|
||||
@interface TFBookRackCommViewController ()<UICollectionViewDelegate, UICollectionViewDataSource>
|
||||
|
||||
@property (nonatomic ,strong) TFBookRackHeaderView *headerView;
|
||||
@property (nonatomic ,strong) UIView *toolBarView;
|
||||
@property (nonatomic ,strong) UIButton *deleteBtn;
|
||||
@property (nonatomic ,strong) UIButton *checkAllBtn;
|
||||
@property (nonatomic ,strong) TFBookRackModel *bookRackModel;
|
||||
@property (nonatomic ,strong) NSMutableArray *deleteSourceArray;
|
||||
// 角标记录
|
||||
@property (nonatomic ,strong) NSMutableDictionary *badges;
|
||||
@property (nonatomic ,assign) BOOL editingProduction;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFBookRackCommViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
[self localSourceRequest];
|
||||
[self netRequest];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self hiddenNavigationBar:YES];
|
||||
|
||||
self.view.backgroundColor = kWhiteColor;
|
||||
self.deleteSourceArray = [NSMutableArray array];
|
||||
|
||||
// 签到加入书架
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(localSourceRequest) name:Notification_Reload_Rack_Production object:nil];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.mainCollectionViewFlowLayout.minimumLineSpacing = kMargin;
|
||||
self.mainCollectionViewFlowLayout.minimumInteritemSpacing = 0;
|
||||
self.mainCollectionViewFlowLayout.headerReferenceSize = CGSizeMake(SCREEN_WIDTH, Rack_Header_Height);
|
||||
self.mainCollectionViewFlowLayout.footerReferenceSize = CGSizeMake(SCREEN_WIDTH, kHalfMargin);
|
||||
self.mainCollectionViewFlowLayout.itemSize = CGSizeMake(BOOK_WIDTH, BOOK_HEIGHT + BOOK_CELL_TITLE_HEIGHT / 2);
|
||||
self.mainCollectionViewFlowLayout.sectionInset = UIEdgeInsetsMake(0, kHalfMargin, 0, kHalfMargin);
|
||||
|
||||
self.mainCollectionView.delegate = self;
|
||||
self.mainCollectionView.dataSource = self;
|
||||
[self.mainCollectionView registerClass:[TFBookRackCommCell class] forCellWithReuseIdentifier:@"TFBookRackCommCell"];
|
||||
[self.mainCollectionView registerClass:[TFBookRackAddMoreCell class] forCellWithReuseIdentifier:@"TFBookRackAddMoreCell"];
|
||||
[self.mainCollectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView"];
|
||||
[self.mainCollectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"FooterView"];
|
||||
[self.view addSubview:self.mainCollectionView];
|
||||
|
||||
[self.mainCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT);
|
||||
make.width.mas_equalTo(self.view.mas_width);
|
||||
make.height.mas_equalTo(self.view.mas_height).with.offset(-PUB_NAVBAR_HEIGHT - PUB_TABBAR_HEIGHT);
|
||||
}];
|
||||
|
||||
UILongPressGestureRecognizer *editLongPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(startEdited:)];
|
||||
editLongPressGesture.minimumPressDuration = 1.0f;
|
||||
editLongPressGesture.numberOfTouchesRequired = 1;
|
||||
[self.mainCollectionView addGestureRecognizer:editLongPressGesture];
|
||||
|
||||
WS(weakSelf)
|
||||
self.mainCollectionView.mj_header = [TFRefreshHeader headerWithRefreshingBlock:^{
|
||||
[weakSelf localSourceRequest];
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
|
||||
{
|
||||
if (self.editingProduction) {
|
||||
return self.dataSourceArray.count;
|
||||
}
|
||||
return self.dataSourceArray.count + 1;
|
||||
}
|
||||
|
||||
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (self.dataSourceArray.count == indexPath.row && !self.editingProduction) {
|
||||
|
||||
static NSString *CellIdentifier = @"TFBookRackAddMoreCell";
|
||||
TFBookRackAddMoreCell __weak *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
|
||||
|
||||
return cell;
|
||||
} else {
|
||||
|
||||
static NSString *CellIdentifier = @"TFBookRackCommCell";
|
||||
TFBookRackCommCell __weak *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
|
||||
TFProductionModel *t_bookModel = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
cell.productionModel = t_bookModel;
|
||||
cell.badgeNum = [TFUtilsHelper formatStringWithInteger:[[self.badges objectForKey:[TFUtilsHelper formatStringWithInteger:t_bookModel.production_id]] total_chapters]];
|
||||
cell.bookSeleced = NO;
|
||||
cell.startEditing = self.editingProduction;
|
||||
|
||||
for (TFProductionModel *t_model in self.deleteSourceArray) {
|
||||
if (t_model.production_id == t_bookModel.production_id) {
|
||||
cell.bookSeleced = YES;
|
||||
}
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
|
||||
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
|
||||
|
||||
UICollectionReusableView *headerReusableView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView" forIndexPath:indexPath];
|
||||
headerReusableView.backgroundColor = [UIColor clearColor];
|
||||
|
||||
if (self.bookRackModel && self.bookRackModel.recommendList.count > 0 && !self.editingProduction) {
|
||||
self.headerView.rackModel = self.bookRackModel;
|
||||
[self showHeaderViewWithAnimated:NO];
|
||||
} else if (self.bookRackModel) {
|
||||
[self hiddenHeaderViewWithAnimated:NO];
|
||||
}
|
||||
[headerReusableView addSubview:self.headerView];
|
||||
|
||||
return headerReusableView;
|
||||
} else {
|
||||
|
||||
UICollectionReusableView *footerReusableView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"FooterView" forIndexPath:indexPath];
|
||||
|
||||
return footerReusableView;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (self.dataSourceArray.count == indexPath.row && !self.editingProduction) {
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Change_Tabbar_Index object:@"1"];
|
||||
switch (self.productionType) {
|
||||
#if TF_Enable_Book
|
||||
case TFProductionTypeNovel:
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:NSNotification_Rack_JumpToMallCenter object:@"novel"];
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
case TFProductionTypeComic:
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:NSNotification_Rack_JumpToMallCenter object:@"comic"];
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
case TFProductionTypeAudio:
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:NSNotification_Rack_JumpToMallCenter object:@"audio"];
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
TFBookRackCommCell *cell = (TFBookRackCommCell *)[collectionView cellForItemAtIndexPath:indexPath];
|
||||
TFProductionModel *productionModel = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
|
||||
if (!self.editingProduction) {
|
||||
[[TFCollectionManager shareManagerWithProductionType:self.productionType] moveCollectionToTopWithProductionModel:productionModel];
|
||||
|
||||
switch (self.productionType) {
|
||||
#if TF_Enable_Book
|
||||
case TFProductionTypeNovel: {
|
||||
if (self.pushToReaderViewControllerBlock) {
|
||||
self.pushToReaderViewControllerBlock(cell.coverView, productionModel);
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
case TFProductionTypeComic: {
|
||||
TFComicBrowseViewController *comicBrowse = [[TFComicBrowseViewController alloc] init];
|
||||
comicBrowse.comicProductionModel = productionModel;
|
||||
comicBrowse.chapter_id = [[TFReadRecordManager shareManagerWithProductionType:TFProductionTypeComic] getReadingRecordChapter_idWithProduction_id:productionModel.production_id];
|
||||
|
||||
[self.navigationController pushViewController:comicBrowse animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
case TFProductionTypeAudio: {
|
||||
TFAudioPlayViewController *audioPlay = [[TFAudioPlayViewController alloc] init];
|
||||
[audioPlay loadDataWithAudio_id:productionModel.production_id chapter_id:0];
|
||||
|
||||
TFNavigationController *nav = [[TFNavigationController alloc] initWithRootViewController:audioPlay];
|
||||
[[TFViewHelper getWindowRootController] presentViewController:nav animated:YES completion:nil];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// 读书任务请求
|
||||
[TFTaskViewController taskReadRequestWithProduction_id:productionModel.production_id];
|
||||
|
||||
// 如果有更新则更新本地数据源
|
||||
if ([cell.badgeNum integerValue] > 0) {
|
||||
TFProductionModel *t_model = [self.badges objectForKey:[TFUtilsHelper formatStringWithInteger:productionModel.production_id]];
|
||||
if (t_model) {
|
||||
[[TFCollectionManager shareManagerWithProductionType:self.productionType] modificationCollectionWithProductionModel:t_model];
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (cell.bookSeleced) {
|
||||
cell.bookSeleced = NO;
|
||||
[self.deleteSourceArray removeObject:productionModel];
|
||||
} else {
|
||||
cell.bookSeleced = YES;
|
||||
[self.deleteSourceArray addObject:productionModel];
|
||||
}
|
||||
|
||||
[self reloadToolBarState];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - 点击事件
|
||||
- (void)showHeaderViewWithAnimated:(BOOL)animated
|
||||
{
|
||||
if (self.bookRackModel.recommendList.count == 0) return;
|
||||
|
||||
[self.mainCollectionView showRefreshHeader];
|
||||
|
||||
[UIView animateWithDuration:animated?kAnimatedDuration:0.0f animations:^{
|
||||
if (self.bookRackModel.announcement.count > 0) {
|
||||
self.headerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, Rack_Header_Height);
|
||||
self.mainCollectionViewFlowLayout.headerReferenceSize = CGSizeMake(SCREEN_WIDTH, Rack_Header_Height);
|
||||
} else {
|
||||
self.headerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, Rack_Header_Height_NoRecommend);
|
||||
self.mainCollectionViewFlowLayout.headerReferenceSize = CGSizeMake(SCREEN_WIDTH, Rack_Header_Height_NoRecommend);
|
||||
}
|
||||
[self.mainCollectionView setCollectionViewLayout:self.mainCollectionViewFlowLayout animated:animated];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)hiddenHeaderViewWithAnimated:(BOOL)animated
|
||||
{
|
||||
[self.mainCollectionView hideRefreshHeader];
|
||||
|
||||
[UIView animateWithDuration:animated?kAnimatedDuration:0.0f animations:^{
|
||||
self.headerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 0);
|
||||
self.mainCollectionViewFlowLayout.headerReferenceSize = CGSizeMake(SCREEN_WIDTH, 10);
|
||||
[self.mainCollectionView setCollectionViewLayout:self.mainCollectionViewFlowLayout animated:animated];
|
||||
}];
|
||||
}
|
||||
|
||||
// 工具栏点击
|
||||
- (void)toolBarActionClick:(UIButton *)sender
|
||||
{
|
||||
switch (sender.tag) {
|
||||
case 11: // 取消操作
|
||||
[self endEdited];
|
||||
break;
|
||||
|
||||
case 22: { // 删除操作
|
||||
if (self.deleteSourceArray.count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSMutableArray *t_deleteArray = [NSMutableArray array];
|
||||
for (TFProductionModel *t_model in self.deleteSourceArray) {
|
||||
[[TFCollectionManager shareManagerWithProductionType:self.productionType] removeCollectionWithProductionModel:t_model];
|
||||
[t_deleteArray addObject:[TFUtilsHelper formatStringWithInteger:t_model.production_id]];
|
||||
}
|
||||
|
||||
NSString *url = @"";
|
||||
NSString *production_key = @"";
|
||||
switch (self.productionType) {
|
||||
case TFProductionTypeNovel:
|
||||
url = Book_Delete_Collect;
|
||||
production_key = @"book_id";
|
||||
break;
|
||||
|
||||
case TFProductionTypeComic:
|
||||
url = Comic_Collect_Delete;
|
||||
production_key = @"comic_id";
|
||||
break;
|
||||
|
||||
case TFProductionTypeAudio:
|
||||
url = Audio_Collection_Delete;
|
||||
production_key = @"audio_id";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
[TFNetworkTools POST:url parameters:@{production_key:[t_deleteArray componentsJoinedByString:@","]} model:nil success:nil failure:nil];
|
||||
|
||||
[self endEdited];
|
||||
[self localSourceRequest];
|
||||
}
|
||||
|
||||
case 33: { // 全选/取消操作
|
||||
|
||||
[self.deleteSourceArray removeAllObjects];
|
||||
|
||||
if (!sender.selected) {
|
||||
self.deleteSourceArray = [self.dataSourceArray mutableCopy];
|
||||
[sender setTitle:TFLocalizedString(@"取消全选") forState:UIControlStateNormal];
|
||||
} else {
|
||||
[sender setTitle:TFLocalizedString(@"全选") forState:UIControlStateNormal];
|
||||
[self.deleteSourceArray removeAllObjects];
|
||||
}
|
||||
|
||||
sender.selected = !sender.selected;
|
||||
|
||||
[self.mainCollectionView.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
if ([obj isKindOfClass:[TFBookRackCommCell class]]) {
|
||||
TFBookRackCommCell *cell = (TFBookRackCommCell *)obj;
|
||||
cell.bookSeleced = sender.selected;
|
||||
}
|
||||
}];
|
||||
|
||||
[self reloadToolBarState];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 开启编辑状态
|
||||
- (void)startEdited:(UILongPressGestureRecognizer *)gestureRecognizer
|
||||
{
|
||||
if (gestureRecognizer.state != UIGestureRecognizerStateBegan) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.editingProduction) {
|
||||
return;
|
||||
}
|
||||
self.editingProduction = YES;
|
||||
|
||||
[self.deleteSourceArray removeAllObjects];
|
||||
|
||||
CGPoint pointTouch = [gestureRecognizer locationInView:self.mainCollectionView];
|
||||
|
||||
if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
|
||||
NSIndexPath *indexPath = [self.mainCollectionView indexPathForItemAtPoint:pointTouch];
|
||||
if ([[self.mainCollectionView cellForItemAtIndexPath:indexPath] isKindOfClass:[TFBookRackCommCell class]]) {
|
||||
|
||||
// 获取当前被点击的书籍,默认选中
|
||||
TFBookRackCommCell *t_cell = (TFBookRackCommCell *)[self.mainCollectionView cellForItemAtIndexPath:indexPath];
|
||||
[self.deleteSourceArray addObject:t_cell.productionModel];
|
||||
|
||||
// 隐藏推荐栏
|
||||
[self hiddenHeaderViewWithAnimated:YES];
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)((kAnimatedDuration + 0.1) * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[self.mainCollectionView reloadData];
|
||||
});
|
||||
|
||||
[UIView animateWithDuration:kAnimatedDuration animations:^{
|
||||
self.toolBarView.frame = CGRectMake(0, SCREEN_HEIGHT - PUB_TABBAR_HEIGHT, SCREEN_WIDTH, PUB_TABBAR_HEIGHT);
|
||||
}];
|
||||
|
||||
[self reloadToolBarState];
|
||||
} else {
|
||||
self.editingProduction = NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)endEdited
|
||||
{
|
||||
self.editingProduction = NO;
|
||||
|
||||
[self showHeaderViewWithAnimated:YES];
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(kAnimatedDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[self.mainCollectionView reloadData];
|
||||
});
|
||||
|
||||
[UIView animateWithDuration:kAnimatedDuration animations:^{
|
||||
self.toolBarView.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, PUB_TABBAR_HEIGHT);
|
||||
}];
|
||||
|
||||
[self reloadToolBarState];
|
||||
}
|
||||
|
||||
- (void)reloadToolBarState
|
||||
{
|
||||
if (self.deleteSourceArray.count == 0) {
|
||||
|
||||
self.deleteBtn.backgroundColor = kGrayLineColor;
|
||||
self.deleteBtn.enabled = NO;
|
||||
[self.deleteBtn setTitle:TFLocalizedString(@"删除(0)") forState:UIControlStateNormal];
|
||||
[self.deleteBtn setTitleColor:kGrayTextColor forState:UIControlStateNormal];
|
||||
|
||||
self.checkAllBtn.selected = NO;
|
||||
[self.checkAllBtn setTitle:TFLocalizedString(@"全选") forState:UIControlStateNormal];
|
||||
|
||||
} else {
|
||||
self.deleteBtn.backgroundColor = kRedColor;
|
||||
self.deleteBtn.enabled = YES;
|
||||
[self.deleteBtn setTitle:[NSString stringWithFormat:@"%@(%@)", TFLocalizedString(@"删除"), [TFUtilsHelper formatStringWithInteger:self.deleteSourceArray.count]] forState:UIControlStateNormal];
|
||||
[self.deleteBtn setTitleColor:kWhiteColor forState:UIControlStateNormal];
|
||||
|
||||
|
||||
if (self.deleteSourceArray.count == self.dataSourceArray.count) {
|
||||
self.checkAllBtn.selected = YES;
|
||||
[self.checkAllBtn setTitle:TFLocalizedString(@"取消全选") forState:UIControlStateNormal];
|
||||
} else {
|
||||
self.checkAllBtn.selected = NO;
|
||||
[self.checkAllBtn setTitle:TFLocalizedString(@"全选") forState:UIControlStateNormal];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (TFBookRackHeaderView *)headerView
|
||||
{
|
||||
if (!_headerView) {
|
||||
WS(weakSelf)
|
||||
_headerView = [[TFBookRackHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, Rack_Header_Height)];
|
||||
_headerView.backgroundColor = [UIColor whiteColor];
|
||||
_headerView.productionType = self.productionType;
|
||||
|
||||
_headerView.adBannerClickBlock = ^(NSString * _Nonnull title, NSString * _Nonnull content) {
|
||||
TFAnnouncementController *vc = [[TFAnnouncementController alloc] init];
|
||||
vc.titleText = title?:@"";
|
||||
vc.contentText = content?:@"";
|
||||
[weakSelf.navigationController pushViewController:vc animated:YES];
|
||||
};
|
||||
|
||||
_headerView.recommendBannerClickBlock = ^(NSInteger production_id) {
|
||||
switch (weakSelf.productionType) {
|
||||
#if TF_Enable_Book
|
||||
case TFProductionTypeNovel: {
|
||||
TFNovelDetailViewController *novelDetail = [[TFNovelDetailViewController alloc] init];
|
||||
novelDetail.book_id = production_id;
|
||||
[weakSelf.navigationController pushViewController:novelDetail animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
case TFProductionTypeComic: {
|
||||
TFComicDetailViewController *comicDetail = [[TFComicDetailViewController alloc] init];
|
||||
comicDetail.comic_id = production_id;
|
||||
[weakSelf.navigationController pushViewController:comicDetail animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
case TFProductionTypeAudio: {
|
||||
TFAudioDetailViewController *audioDetail = [[TFAudioDetailViewController alloc] init];
|
||||
audioDetail.audio_id = production_id;
|
||||
[weakSelf.navigationController pushViewController:audioDetail animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
_headerView.collectionClickBlock = ^{
|
||||
[weakSelf.navigationController pushViewController:[[TFTaskViewController alloc] init] animated:YES];
|
||||
};
|
||||
}
|
||||
return _headerView;
|
||||
}
|
||||
|
||||
- (UIView *)toolBarView
|
||||
{
|
||||
if (!_toolBarView) {
|
||||
_toolBarView = [[UIView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, PUB_TABBAR_HEIGHT)];
|
||||
_toolBarView.backgroundColor = kWhiteColor;
|
||||
WS(weakSelf)
|
||||
[_toolBarView addObserver:KEY_PATH(_toolBarView, frame) complete:^(UIView * _Nonnull toolBarView, id _Nullable oldVal, id _Nullable newVal) {
|
||||
CGRect frame = [newVal CGRectValue];
|
||||
if (CGRectGetMinY(frame) >= SCREEN_HEIGHT) {
|
||||
toolBarView.hidden = YES;
|
||||
weakSelf.tabBarController.tabBar.hidden = NO;
|
||||
} else {
|
||||
toolBarView.hidden = NO;
|
||||
weakSelf.tabBarController.tabBar.hidden = YES;
|
||||
}
|
||||
}];
|
||||
[self.view addSubview:_toolBarView];
|
||||
|
||||
UIButton *checkAllBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
checkAllBtn.tag = 33;
|
||||
checkAllBtn.selected = NO;
|
||||
checkAllBtn.frame = CGRectMake(0, 0, SCREEN_WIDTH / 3, PUB_TABBAR_HEIGHT - PUB_TABBAR_OFFSET);
|
||||
checkAllBtn.adjustsImageWhenHighlighted = NO;
|
||||
[checkAllBtn setTitle:TFLocalizedString(@"全选") forState:UIControlStateNormal];
|
||||
[checkAllBtn setTitleColor:kBlackColor forState:UIControlStateNormal];
|
||||
[checkAllBtn.titleLabel setFont:kMainFont];
|
||||
[checkAllBtn addTarget:self action:@selector(toolBarActionClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[_toolBarView addSubview:checkAllBtn];
|
||||
|
||||
self.checkAllBtn = checkAllBtn;
|
||||
|
||||
UIButton *deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
deleteBtn.frame = CGRectMake(SCREEN_WIDTH / 3, 0, SCREEN_WIDTH / 3, PUB_TABBAR_HEIGHT - PUB_TABBAR_OFFSET);
|
||||
deleteBtn.backgroundColor = kGrayLineColor;
|
||||
deleteBtn.tag = 22;
|
||||
[deleteBtn setTitleColor:kGrayTextColor forState:UIControlStateNormal];
|
||||
[deleteBtn setTitle:TFLocalizedString(@"删除") forState:UIControlStateNormal];
|
||||
[deleteBtn.titleLabel setFont:kMainFont];
|
||||
[deleteBtn addTarget:self action:@selector(toolBarActionClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[_toolBarView addSubview:deleteBtn];
|
||||
|
||||
self.deleteBtn = deleteBtn;
|
||||
|
||||
UIButton *cancleButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
cancleButton.frame = CGRectMake(SCREEN_WIDTH / 3 * 2, 0, SCREEN_WIDTH / 3, PUB_TABBAR_HEIGHT - PUB_TABBAR_OFFSET);
|
||||
cancleButton.tag = 11;
|
||||
[cancleButton setTitle:TFLocalizedString(@"取消") forState:UIControlStateNormal];
|
||||
[cancleButton setTitleColor:kBlackColor forState:UIControlStateNormal];
|
||||
[cancleButton.titleLabel setFont:kMainFont];
|
||||
[cancleButton addTarget:self action:@selector(toolBarActionClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[_toolBarView addSubview:cancleButton];
|
||||
}
|
||||
return _toolBarView;
|
||||
}
|
||||
|
||||
// 加载本地书籍缓存
|
||||
- (void)localSourceRequest
|
||||
{
|
||||
NSArray *cacheArray = [[TFCollectionManager shareManagerWithProductionType:self.productionType] getAllCollection];
|
||||
if (![cacheArray isEqualToArray:self.dataSourceArray]) {
|
||||
self.dataSourceArray = [cacheArray mutableCopy];
|
||||
[self.mainCollectionView reloadData];
|
||||
}
|
||||
|
||||
[self.mainCollectionView scrollToTop];
|
||||
[self.mainCollectionView endRefreshing];
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
// 书籍更新角标
|
||||
self.badges = [NSMutableDictionary dictionary];
|
||||
|
||||
NSString *url = @"";
|
||||
switch (self.productionType) {
|
||||
case TFProductionTypeNovel:
|
||||
url = Book_Rack;
|
||||
break;
|
||||
case TFProductionTypeComic:
|
||||
url = Comic_Rack;
|
||||
break;
|
||||
case TFProductionTypeAudio:
|
||||
url = Audio_Rack;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:url parameters:nil model:TFBookRackModel.class success:^(BOOL isSuccess, TFBookRackModel * _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
if (isSuccess) {
|
||||
weakSelf.bookRackModel = t_model;
|
||||
for (TFProductionModel *t_model in weakSelf.bookRackModel.productionList) {
|
||||
[weakSelf.badges setObject:t_model forKey:[TFUtilsHelper formatStringWithInteger:t_model.production_id]];
|
||||
}
|
||||
}
|
||||
[weakSelf.mainCollectionView endRefreshing];
|
||||
[weakSelf.mainCollectionView reloadData];
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[weakSelf.mainCollectionView endRefreshing];
|
||||
[weakSelf.mainCollectionView reloadData];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// TFBookRackViewController.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/1.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFBookRackViewController : TFBasicViewController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,169 @@
|
||||
//
|
||||
// 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
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// TFBookRackModel.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/11.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class TFBaseInfoModel, TFAnnouncementModel, TFProductionModel, WXYZ_TaskModel;
|
||||
|
||||
@interface TFBookRackModel : NSObject
|
||||
|
||||
@property (nonatomic ,strong) TFBaseInfoModel *base_info;
|
||||
@property (nonatomic ,strong) NSArray <TFAnnouncementModel *>* announcement; // 公告
|
||||
@property (nonatomic ,strong) NSArray <TFProductionModel *>* recommendList; // 推荐
|
||||
@property (nonatomic ,strong) NSArray <TFProductionModel *>* productionList; // 作品列表
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface TFBaseInfoModel : NSObject
|
||||
|
||||
@property (nonatomic ,assign) NSInteger sign_status;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface TFAnnouncementModel : NSObject
|
||||
|
||||
@property (nonatomic ,copy) NSString *title;
|
||||
@property (nonatomic ,copy) NSString *content;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// TFBookRackModel.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/11.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookRackModel.h"
|
||||
|
||||
@implementation TFBookRackModel
|
||||
|
||||
+ (NSDictionary *)modelCustomPropertyMapper
|
||||
{
|
||||
return @{
|
||||
@"rackDescription" : @"description",
|
||||
@"announcement" : @[@"announce", @"announcement"],
|
||||
@"recommendList" : @[@"recommend_list", @"recommend"],
|
||||
@"productionList" : @[@"list"]
|
||||
};
|
||||
}
|
||||
|
||||
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass
|
||||
{
|
||||
return @{
|
||||
@"announcement" : [TFAnnouncementModel class],
|
||||
@"recommendList" : [TFProductionModel class],
|
||||
@"productionList" : [TFProductionModel class]
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation TFBaseInfoModel
|
||||
@end
|
||||
|
||||
|
||||
@implementation TFAnnouncementModel
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// TFBookRackAddMoreCell.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/2.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFBookRackAddMoreCell : UICollectionViewCell
|
||||
|
||||
- (void)startEditState;
|
||||
|
||||
- (void)endEditState;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// TFBookRackAddMoreCell.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/2.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookRackAddMoreCell.h"
|
||||
|
||||
@implementation TFBookRackAddMoreCell
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
[self createSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
UIView *borderView = [[UIView alloc] init];
|
||||
borderView.backgroundColor = kGrayViewColor;
|
||||
borderView.layer.cornerRadius = 2;
|
||||
[self addSubview:borderView];
|
||||
|
||||
[borderView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self.mas_centerX);
|
||||
make.top.mas_equalTo(self.mas_top);
|
||||
make.width.mas_equalTo(BOOK_WIDTH);
|
||||
make.height.mas_equalTo(BOOK_HEIGHT);
|
||||
}];
|
||||
|
||||
UIImageView *addImageView = [[UIImageView alloc] init];
|
||||
addImageView.image = [UIImage imageNamed:@"public_rack_add"];
|
||||
[borderView addSubview:addImageView];
|
||||
|
||||
[addImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(borderView.mas_centerX);
|
||||
make.centerY.mas_equalTo(borderView.mas_centerY);
|
||||
make.height.width.mas_equalTo(30);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)startEditState
|
||||
{
|
||||
self.hidden = YES;
|
||||
}
|
||||
|
||||
- (void)endEditState
|
||||
{
|
||||
self.hidden = NO;
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// TFBookRackCommCell.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/1.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class TFProductionModel;
|
||||
@interface TFBookRackCommCell : UICollectionViewCell
|
||||
|
||||
@property (nonatomic ,strong) TFProductionModel *productionModel;
|
||||
|
||||
@property (nonatomic ,assign) BOOL bookSeleced;
|
||||
|
||||
@property (nonatomic ,strong) TFProductionCoverView *coverView;
|
||||
|
||||
@property (nonatomic ,strong) NSString *badgeNum;
|
||||
|
||||
@property (nonatomic ,assign) BOOL startEditing;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,180 @@
|
||||
//
|
||||
// TFBookRackCommCell.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/1.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookRackCommCell.h"
|
||||
|
||||
@interface TFBookRackCommCell ()
|
||||
|
||||
@property (nonatomic ,strong) UILabel *titleLabel;
|
||||
@property (nonatomic ,strong) UILabel *finishedLabel;
|
||||
@property (nonatomic ,strong) UIImageView *selectView;
|
||||
@property (nonatomic ,strong) UIImageView *recommendView;
|
||||
@property (nonatomic ,strong) UILabel *badgeLabel;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFBookRackCommCell
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.backgroundColor = kWhiteColor;
|
||||
[self createSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.coverView = [[TFProductionCoverView alloc] initWithProductionType:TFProductionTypeNovel coverDirection:TFProductionCoverDirectionVertical];
|
||||
self.coverView.userInteractionEnabled = YES;
|
||||
[self addSubview:self.coverView];
|
||||
|
||||
[self.coverView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self.mas_centerX);
|
||||
make.top.mas_equalTo(self.mas_top);
|
||||
make.width.mas_equalTo(BOOK_WIDTH);
|
||||
make.height.mas_equalTo(BOOK_HEIGHT);
|
||||
}];
|
||||
|
||||
self.recommendView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:TFLocalizedString(@"book_rack_recommend_conner")]];
|
||||
self.recommendView.hidden = YES;
|
||||
[self.coverView addSubview:self.recommendView];
|
||||
|
||||
[self.recommendView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(0);
|
||||
make.width.mas_equalTo(BOOK_WIDTH / 3);
|
||||
make.height.mas_equalTo(kGeometricHeight((BOOK_WIDTH / 3), 102, 54));
|
||||
}];
|
||||
|
||||
self.badgeLabel = [[UILabel alloc] init];
|
||||
self.badgeLabel.hidden = YES;
|
||||
self.badgeLabel.textAlignment = NSTextAlignmentCenter;
|
||||
self.badgeLabel.textColor = kWhiteColor;
|
||||
self.badgeLabel.backgroundColor = kColorRGBA(229, 91, 94, 1);
|
||||
self.badgeLabel.font = kFont9;
|
||||
self.badgeLabel.numberOfLines = 1;
|
||||
self.badgeLabel.layer.cornerRadius = 8;
|
||||
self.badgeLabel.layer.borderColor = [UIColor whiteColor].CGColor;
|
||||
self.badgeLabel.layer.borderWidth = 2;
|
||||
self.badgeLabel.clipsToBounds = YES;
|
||||
[self.coverView addSubview:self.badgeLabel];
|
||||
|
||||
[self.badgeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self.coverView.mas_right).with.offset(- 3);
|
||||
make.centerY.mas_equalTo(self.coverView.mas_top).with.offset(3);
|
||||
make.width.height.mas_equalTo(16);
|
||||
}];
|
||||
|
||||
self.selectView = [[UIImageView alloc] init];
|
||||
self.selectView.hidden = YES;
|
||||
self.selectView.userInteractionEnabled = YES;
|
||||
self.selectView.image = [UIImage imageNamed:@"audio_download_unselect"];
|
||||
[self addSubview:self.selectView];
|
||||
|
||||
[self.selectView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.coverView.mas_right).with.offset(- 5);
|
||||
make.bottom.mas_equalTo(self.coverView.mas_bottom).with.offset(- 5);
|
||||
make.height.width.mas_equalTo(18);
|
||||
}];
|
||||
|
||||
self.titleLabel = [[UILabel alloc] init];
|
||||
self.titleLabel.numberOfLines = 1;
|
||||
self.titleLabel.backgroundColor = kGrayViewColor;
|
||||
self.titleLabel.font = kFont12;
|
||||
self.titleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.titleLabel.textColor = kBlackColor;
|
||||
[self addSubview:self.titleLabel];
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.coverView.mas_left);
|
||||
make.top.mas_equalTo(self.coverView.mas_bottom).with.offset(kHalfMargin);
|
||||
make.width.mas_equalTo(self.coverView.mas_width);
|
||||
make.height.mas_equalTo(BOOK_CELL_TITLE_HEIGHT / 2);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setProductionModel:(TFProductionModel *)productionModel
|
||||
{
|
||||
_productionModel = productionModel;
|
||||
|
||||
self.coverView.productionType = productionModel.productionType;
|
||||
|
||||
if (productionModel.cover.length > 0) {
|
||||
self.coverView.coverImageUrl = productionModel.cover;
|
||||
} else if (productionModel.vertical_cover.length > 0) {
|
||||
self.coverView.coverImageUrl = productionModel.vertical_cover;
|
||||
} else if (productionModel.horizontal_cover.length > 0) {
|
||||
self.coverView.coverImageUrl = productionModel.horizontal_cover;
|
||||
}
|
||||
|
||||
self.recommendView.hidden = !productionModel.is_recommend;
|
||||
self.titleLabel.backgroundColor = kWhiteColor;
|
||||
self.titleLabel.text = productionModel.name ? : @"";
|
||||
self.badgeLabel.hidden = YES;
|
||||
}
|
||||
|
||||
- (void)setBookSeleced:(BOOL)bookSeleced
|
||||
{
|
||||
_bookSeleced = bookSeleced;
|
||||
|
||||
if (bookSeleced) {
|
||||
self.selectView.image = [UIImage imageNamed:@"audio_download_select"];
|
||||
self.coverView.alpha = 1.0f;
|
||||
} else {
|
||||
self.selectView.image = [UIImage imageNamed:@"audio_download_unselect"];
|
||||
self.coverView.alpha = 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setBadgeNum:(NSString *)badgeNum
|
||||
{
|
||||
if ([badgeNum isEqualToString:@"0"]) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_productionModel.total_chapters == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
badgeNum = [NSString stringWithFormat:@"%@", [TFUtilsHelper formatStringWithInteger:abs((int)_productionModel.total_chapters - [badgeNum intValue])]];
|
||||
|
||||
if (badgeNum && ![badgeNum isEqualToString:@"0"]) {
|
||||
|
||||
self.badgeLabel.hidden = NO;
|
||||
self.badgeLabel.text = badgeNum;
|
||||
if (badgeNum.length == 2) {
|
||||
[self.badgeLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(21);
|
||||
}];
|
||||
} else if (badgeNum.length >= 3) {
|
||||
[self.badgeLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(26);
|
||||
}];
|
||||
}
|
||||
} else {
|
||||
self.badgeLabel.hidden = YES;
|
||||
}
|
||||
|
||||
_badgeNum = badgeNum;
|
||||
}
|
||||
|
||||
- (void)setStartEditing:(BOOL)startEditing
|
||||
{
|
||||
_startEditing = startEditing;
|
||||
|
||||
if (startEditing) {
|
||||
self.coverView.alpha = 0.5f;
|
||||
self.selectView.hidden = NO;
|
||||
} else {
|
||||
self.coverView.alpha = 1.0f;
|
||||
self.selectView.hidden = YES;
|
||||
}
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TFBookRackHeaderCell.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/1.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFBookRackHeaderCell : UICollectionViewCell
|
||||
|
||||
@property (nonatomic, strong) TFProductionModel *productionModel;
|
||||
|
||||
@property (nonatomic, assign) TFProductionType productionType;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,114 @@
|
||||
//
|
||||
// TFBookRackHeaderCell.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/1.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookRackHeaderCell.h"
|
||||
|
||||
@interface TFBookRackHeaderCell ()
|
||||
{
|
||||
UIView *bottomView;
|
||||
|
||||
TFProductionCoverView *bookImageView;
|
||||
|
||||
UILabel *titleLabel;
|
||||
YYLabel *bookDetailLabel;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation TFBookRackHeaderCell
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.backgroundColor = kWhiteColor;
|
||||
[self createSubViews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createSubViews
|
||||
{
|
||||
bottomView = [[UIView alloc] init];
|
||||
bottomView.backgroundColor = kGrayViewColor;
|
||||
bottomView.layer.cornerRadius = 8;
|
||||
[self addSubview:bottomView];
|
||||
|
||||
[bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kHalfMargin + kQuarterMargin);
|
||||
make.right.mas_equalTo(self.mas_right).with.offset(- kHalfMargin - kQuarterMargin);
|
||||
make.top.mas_equalTo(self.mas_top).with.offset(kHalfMargin);
|
||||
make.height.mas_equalTo(self.mas_height).with.offset(- kMargin);
|
||||
}];
|
||||
|
||||
bookImageView = [[TFProductionCoverView alloc] initWithProductionType:TFProductionTypeNovel coverDirection:TFProductionCoverDirectionVertical];
|
||||
[bottomView addSubview:bookImageView];
|
||||
|
||||
[bookImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(bottomView.mas_left).with.offset(kHalfMargin);
|
||||
make.centerY.mas_equalTo(bottomView.mas_centerY);
|
||||
make.height.mas_equalTo(bottomView.mas_height).with.offset(- kMargin);
|
||||
make.width.mas_equalTo(kGeometricWidth((self.height - 2 * kMargin), 3, 4));
|
||||
}];
|
||||
|
||||
titleLabel = [[UILabel alloc] init];
|
||||
titleLabel.textColor = kBlackColor;
|
||||
titleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
titleLabel.numberOfLines = 1;
|
||||
titleLabel.font = kMainFont;
|
||||
[self addSubview:titleLabel];
|
||||
|
||||
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(bookImageView.mas_right).with.offset(kHalfMargin);
|
||||
make.top.mas_equalTo(bookImageView.mas_top).with.offset(kQuarterMargin);
|
||||
make.right.mas_equalTo(bottomView.mas_right).with.offset(- kHalfMargin);
|
||||
make.height.mas_equalTo(30);
|
||||
}];
|
||||
|
||||
bookDetailLabel = [[YYLabel alloc] init];
|
||||
bookDetailLabel.textColor = kGrayTextColor;
|
||||
bookDetailLabel.textAlignment = NSTextAlignmentLeft;
|
||||
bookDetailLabel.textVerticalAlignment = YYTextVerticalAlignmentCenter;
|
||||
bookDetailLabel.numberOfLines = 2;
|
||||
bookDetailLabel.font = kFont13;
|
||||
[self addSubview:bookDetailLabel];
|
||||
|
||||
[bookDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(titleLabel.mas_left);
|
||||
make.top.mas_equalTo(titleLabel.mas_bottom);
|
||||
make.bottom.mas_equalTo(bookImageView.mas_bottom).with.offset(- kHalfMargin);
|
||||
make.right.mas_equalTo(titleLabel.mas_right);
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
- (void)setProductionModel:(TFProductionModel *)productionModel
|
||||
{
|
||||
_productionModel = productionModel;
|
||||
|
||||
if (productionModel.vertical_cover.length > 0) {
|
||||
bookImageView.coverImageUrl = productionModel.vertical_cover;
|
||||
} else if (productionModel.horizontal_cover.length > 0) {
|
||||
bookImageView.coverImageUrl = productionModel.horizontal_cover;
|
||||
} else {
|
||||
bookImageView.coverImageUrl = productionModel.cover;
|
||||
}
|
||||
|
||||
titleLabel.text = productionModel.name?:@"";
|
||||
|
||||
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString: productionModel.production_descirption?:@""];
|
||||
attributedString.lineSpacing = 3;
|
||||
attributedString.font = kFont13;
|
||||
attributedString.color = kGrayTextColor;
|
||||
bookDetailLabel.attributedText = attributedString;
|
||||
}
|
||||
|
||||
- (void)setProductionType:(TFProductionType)productionType
|
||||
{
|
||||
_productionType = productionType;
|
||||
bookImageView.productionType = productionType;
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// TFBookRackHeaderView.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/1.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
#define Rack_Header_Height (kGeometricHeight(SCREEN_WIDTH, 3, 1) + kLabelHeight + kMargin + kQuarterMargin)
|
||||
#define Rack_Header_Height_NoRecommend (kGeometricHeight(SCREEN_WIDTH, 3, 1) + kQuarterMargin)
|
||||
|
||||
typedef void(^RecommendBannerClickBlock)(NSInteger production_id);
|
||||
|
||||
typedef void(^AdBannerClickBlock)(NSString *title, NSString *content);
|
||||
|
||||
@interface TFBookRackHeaderView : UIView
|
||||
|
||||
@property (nonatomic, assign) TFProductionType productionType;
|
||||
|
||||
@property (nonatomic, strong) TFBookRackModel *rackModel;
|
||||
|
||||
@property (nonatomic, copy) RecommendBannerClickBlock recommendBannerClickBlock;
|
||||
|
||||
@property (nonatomic, copy) AdBannerClickBlock adBannerClickBlock;
|
||||
|
||||
@property (nonatomic, copy) void (^collectionClickBlock)(void);
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,221 @@
|
||||
//
|
||||
// TFBookRackHeaderView.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/1.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookRackHeaderView.h"
|
||||
#import "TFBookRackHeaderCell.h"
|
||||
|
||||
#import "TFSignModel.h"
|
||||
|
||||
#import "WXYZ_AnnouncementView.h"
|
||||
#import "YJBannerView.h"
|
||||
#import "TFSignAlertView.h"
|
||||
|
||||
@interface TFBookRackHeaderView () <YJBannerViewDelegate, YJBannerViewDataSource>
|
||||
|
||||
@property (nonatomic ,strong) YJBannerView *recommendBannerView;
|
||||
@property (nonatomic ,strong) WXYZ_AnnouncementView *announceBannerView;
|
||||
@property (nonatomic ,strong) NSMutableArray *bannerArray;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFBookRackHeaderView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.clipsToBounds = YES;
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
[self createSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.backgroundColor = kWhiteColor;
|
||||
|
||||
[self addSubview:self.recommendBannerView];
|
||||
[self.recommendBannerView reloadData];
|
||||
|
||||
[self addSubview:self.announceBannerView];
|
||||
|
||||
[self.announceBannerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kHalfMargin + kQuarterMargin);
|
||||
make.top.mas_equalTo(self.recommendBannerView.mas_bottom).with.offset(kHalfMargin);
|
||||
make.right.mas_equalTo(self.recommendBannerView.mas_right).with.offset(- kHalfMargin - kQuarterMargin);
|
||||
make.height.mas_equalTo(kLabelHeight);
|
||||
}];
|
||||
|
||||
#if TF_Sign_Mode
|
||||
TFButton *collectionButton = [[TFButton alloc] initWithFrame:CGRectZero buttonTitle:TFLocalizedString(@"签到") buttonImageName:@"public_sign_in" buttonIndicator:TFButtonIndicatorTitleRight];
|
||||
collectionButton.graphicDistance = 5;
|
||||
collectionButton.buttonImageScale = 0.45;
|
||||
collectionButton.buttonTintColor = kMainColor;
|
||||
[collectionButton addTarget:self action:@selector(rackCollectionClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self addSubview:collectionButton];
|
||||
|
||||
[collectionButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.announceBannerView.mas_right).with.offset(- kQuarterMargin);
|
||||
make.centerY.mas_equalTo(self.announceBannerView.mas_centerY);
|
||||
make.height.mas_equalTo(self.announceBannerView.mas_height);
|
||||
make.width.mas_equalTo(80);
|
||||
}];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (WXYZ_AnnouncementView *)announceBannerView
|
||||
{
|
||||
if (!_announceBannerView) {
|
||||
WS(weakSelf)
|
||||
_announceBannerView = [[WXYZ_AnnouncementView alloc] init];
|
||||
_announceBannerView.layer.cornerRadius = kLabelHeight / 2;
|
||||
_announceBannerView.backgroundColor = kGrayViewColor;
|
||||
_announceBannerView.clickAdBlock = ^(NSString *path, NSUInteger index) {
|
||||
if (weakSelf.adBannerClickBlock) {
|
||||
TFAnnouncementModel *t_ann = [weakSelf.rackModel.announcement objectAtIndex:index];
|
||||
weakSelf.adBannerClickBlock(t_ann.title, t_ann.content);
|
||||
}
|
||||
};
|
||||
}
|
||||
return _announceBannerView;
|
||||
}
|
||||
|
||||
- (YJBannerView *)recommendBannerView
|
||||
{
|
||||
if (!_recommendBannerView) {
|
||||
_recommendBannerView = [YJBannerView bannerViewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, kGeometricHeight(SCREEN_WIDTH, 3, 1)) dataSource:self delegate:self emptyImage:nil placeholderImage:nil selectorString:NSStringFromSelector(@selector(setImageWithURL:placeholder:))];
|
||||
_recommendBannerView.backgroundColor = kWhiteColor;
|
||||
_recommendBannerView.repeatCount = 9999;
|
||||
_recommendBannerView.autoDuration = 5.0f;
|
||||
_recommendBannerView.pageControlAliment = PageControlAlimentRight;
|
||||
_recommendBannerView.pageControlStyle = PageControlCustom;
|
||||
_recommendBannerView.pageControlDotSize = CGSizeMake(5, 5);
|
||||
_recommendBannerView.pageControlBottomMargin = 20;
|
||||
_recommendBannerView.pageControlHorizontalEdgeMargin = 25;
|
||||
_recommendBannerView.pageControlPadding = 3;
|
||||
_recommendBannerView.customPageControlHighlightImage = [UIImage imageNamed:@"pageControl_H"];
|
||||
_recommendBannerView.customPageControlNormalImage = [UIImage imageNamed:@"pageControl_N"];
|
||||
}
|
||||
return _recommendBannerView;
|
||||
}
|
||||
|
||||
- (NSMutableArray *)bannerArray
|
||||
{
|
||||
if (!_bannerArray) {
|
||||
_bannerArray = [NSMutableArray array];
|
||||
[_bannerArray addObject:@""];
|
||||
}
|
||||
return _bannerArray;
|
||||
}
|
||||
|
||||
// 将网络图片或者本地图片 或者混合数组
|
||||
- (NSArray *)bannerViewImages:(YJBannerView *)bannerView
|
||||
{
|
||||
return self.bannerArray;
|
||||
}
|
||||
|
||||
- (NSArray *)bannerViewRegistCustomCellClass:(YJBannerView *)bannerView
|
||||
{
|
||||
return @[[TFBookRackHeaderCell class]];
|
||||
}
|
||||
|
||||
/** 根据 Index 选择使用哪个 reuseIdentifier */
|
||||
- (Class)bannerView:(YJBannerView *)bannerView reuseIdentifierForIndex:(NSInteger)index
|
||||
{
|
||||
return [TFBookRackHeaderCell class];
|
||||
}
|
||||
|
||||
/** 自定义 View 刷新数据或者其他配置 */
|
||||
- (UICollectionViewCell *)bannerView:(YJBannerView *)bannerView customCell:(UICollectionViewCell *)customCell index:(NSInteger)index
|
||||
{
|
||||
TFBookRackHeaderCell *cell = (TFBookRackHeaderCell *)customCell;
|
||||
cell.productionModel = [_rackModel.recommendList objectOrNilAtIndex:index];
|
||||
cell.productionType = self.productionType;
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
// 代理方法 点击了哪个bannerView 的 第几个元素
|
||||
- (void)bannerView:(YJBannerView *)bannerView didSelectItemAtIndex:(NSInteger)index
|
||||
{
|
||||
if ([[self.bannerArray objectAtIndex:index] length] > 0) {
|
||||
WS(weakSelf)
|
||||
if (self.recommendBannerClickBlock) {
|
||||
self.recommendBannerClickBlock([weakSelf.rackModel.recommendList objectAtIndex:index].production_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)rackCollectionClick
|
||||
{
|
||||
if (!TFUserInfoManager.isLogin) {
|
||||
|
||||
[TFLoginOptionsViewController presentLoginView:nil];
|
||||
|
||||
return;
|
||||
}
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:Sign_Click parameters:nil model:TFSignModel.class success:^(BOOL isSuccess, TFSignModel *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
if (isSuccess) {
|
||||
if ((t_model.book.count > 0 || t_model.comic.count > 0) && t_model.award.length > 0 && t_model.tomorrow_award.length > 0) {
|
||||
|
||||
NSMutableArray *t_arr = [NSMutableArray array];
|
||||
|
||||
for (TFProductionModel *t in t_model.book) {
|
||||
t.productionType = TFProductionTypeNovel;
|
||||
[t_arr addObject:t];
|
||||
}
|
||||
|
||||
for (TFProductionModel *t in t_model.comic) {
|
||||
t.productionType = TFProductionTypeComic;
|
||||
[t_arr addObject:t];
|
||||
}
|
||||
|
||||
for (TFProductionModel *t in t_model.audio) {
|
||||
t.productionType = TFProductionTypeAudio;
|
||||
[t_arr addObject:t];
|
||||
}
|
||||
|
||||
TFSignAlertView *alert = [[TFSignAlertView alloc] init];
|
||||
alert.alertTitle = t_model.award;
|
||||
alert.alertDetailContent = t_model.tomorrow_award;
|
||||
alert.bookList = [t_arr copy];
|
||||
[alert showAlertView];
|
||||
}
|
||||
} else {
|
||||
!weakSelf.collectionClickBlock ?: weakSelf.collectionClickBlock();
|
||||
}
|
||||
} failure:nil];
|
||||
}
|
||||
|
||||
- (void)setRackModel:(TFBookRackModel *)rackModel
|
||||
{
|
||||
if (_rackModel != rackModel) {
|
||||
_rackModel = rackModel;
|
||||
// 公告
|
||||
if (rackModel.announcement.count > 0) {
|
||||
self.announceBannerView.modelArr = rackModel.announcement;
|
||||
self.announceBannerView.hidden = NO;
|
||||
} else {
|
||||
self.announceBannerView.hidden = YES;
|
||||
}
|
||||
|
||||
// 设置推荐
|
||||
[self.bannerArray removeAllObjects];
|
||||
|
||||
for (TFProductionModel *model in rackModel.recommendList) {
|
||||
NSString *imageURL = (model.vertical_cover.length > 0?model.vertical_cover:model.horizontal_cover)?:model.cover?:@"";
|
||||
|
||||
[self.bannerArray addObject:imageURL];
|
||||
}
|
||||
|
||||
[self.recommendBannerView reloadData];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user