小说绘上架版本
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// TFBookStoreMoreViewController.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 TFBookStoreMoreViewController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,copy) NSString *recommend_id;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+189
@@ -0,0 +1,189 @@
|
||||
//
|
||||
// TFBookStoreMoreViewController.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/2.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookStoreMoreViewController.h"
|
||||
#import "TFBookStoreRecommend.h"
|
||||
#import "TFProductionListViewCell.h"
|
||||
|
||||
@interface TFBookStoreMoreViewController ()<UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFBookStoreMoreViewController
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.mainTableView.delegate = self;
|
||||
self.mainTableView.dataSource = self;
|
||||
self.mainTableView.contentInset = UIEdgeInsetsMake(0, 0, PUB_TABBAR_OFFSET, 0);
|
||||
[self.view addSubview:self.mainTableView];
|
||||
|
||||
[self.mainTableView 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(SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT);
|
||||
}];
|
||||
|
||||
WS(weakSelf)
|
||||
self.mainTableView.mj_header = [TFRefreshHeader headerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber = 1;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
[self.mainTableView.mj_header beginRefreshing];
|
||||
|
||||
self.mainTableView.mj_footer = [TFRefreshFooter footerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber ++;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.dataSourceArray.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
static NSString *cellName = @"TFProductionListViewCell";
|
||||
TFProductionListViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
|
||||
if (!cell) {
|
||||
cell = [[TFProductionListViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
}
|
||||
cell.productionType = self.productionType;
|
||||
cell.productionModel = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
cell.hiddenEndLine = (indexPath.row == self.dataSourceArray.count - 1);
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 10)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, PUB_TABBAR_OFFSET == 0 ? 10 : PUB_TABBAR_OFFSET)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFProductionModel *productionModel = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
|
||||
switch (self.productionType) {
|
||||
case TFProductionTypeNovel: {
|
||||
TFNovelDetailViewController *novelDetail = [[TFNovelDetailViewController alloc] init];
|
||||
novelDetail.book_id = productionModel.production_id;
|
||||
[self.navigationController pushViewController:novelDetail animated:YES];
|
||||
}
|
||||
break;
|
||||
|
||||
#if TF_Enable_Comic
|
||||
case TFProductionTypeComic: {
|
||||
TFComicDetailViewController *comicDetail = [[TFComicDetailViewController alloc] init];
|
||||
comicDetail.comic_id = productionModel.production_id;
|
||||
[self.navigationController pushViewController:comicDetail animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
case TFProductionTypeAudio: {
|
||||
TFAudioDetailViewController *audioDetail = [[TFAudioDetailViewController alloc] init];
|
||||
audioDetail.audio_id = productionModel.production_id;
|
||||
[self.navigationController pushViewController:audioDetail animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
NSString *url = @"";
|
||||
switch (self.productionType) {
|
||||
case TFProductionTypeNovel:
|
||||
url = Book_Recommend_More;
|
||||
break;
|
||||
case TFProductionTypeComic:
|
||||
url = Comic_Recommend_More;
|
||||
break;
|
||||
case TFProductionTypeAudio:
|
||||
url = Audio_Recommend_More;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
WS(weakSelf)
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
params[@"recommend_id"] = self.recommend_id;
|
||||
params[@"page_num"] = [TFUtilsHelper formatStringWithInteger:self.currentPageNumber];
|
||||
|
||||
[TFNetworkTools POST:url parameters:params model:TFBookStoreRecommend.class success:^(BOOL isSuccess, TFBookStoreRecommend *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
|
||||
if (isSuccess) {
|
||||
[weakSelf setNavigationBarTitle:t_model.recommendTitle ? : TFLocalizedString(@"查看更多")];
|
||||
if (weakSelf.currentPageNumber == 1) {
|
||||
[weakSelf.dataSourceArray removeAllObjects];
|
||||
weakSelf.dataSourceArray = [NSMutableArray arrayWithArray:t_model.recommendList.list];
|
||||
} else {
|
||||
[weakSelf.dataSourceArray addObjectsFromArray:t_model.recommendList.list];
|
||||
}
|
||||
if (t_model.recommendList.total_page <= t_model.recommendList.current_page) {
|
||||
[weakSelf.mainTableView hideRefreshFooter];
|
||||
}
|
||||
}
|
||||
[weakSelf.mainTableView reloadData];
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// TFBookStoreViewController.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/2.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFSearchView.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFBookStoreViewController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,strong) UIButton *sexChooseButton;
|
||||
@property (nonatomic ,assign) BOOL isNavDark;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+456
@@ -0,0 +1,456 @@
|
||||
//
|
||||
// TFBookStoreViewController.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/2.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookStoreViewController.h"
|
||||
#import "AppDelegate.h"
|
||||
|
||||
#if TF_Enable_Comic
|
||||
#import "TFBookStoreComicController.h"
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Book
|
||||
#import "TFBookStoreNovelController.h"
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
#import "TFBookStoreAudioController.h"
|
||||
#import "TFAudioPlayViewController.h"
|
||||
#endif
|
||||
|
||||
#import "TFSearchViewController.h"
|
||||
#import "TFLimitFreeViewController.h"
|
||||
#import "TFWebViewController.h"
|
||||
#import "TFCollectionManager.h"
|
||||
#import "TFRecommendBookModel.h"
|
||||
#import "NSObject+Observer.h"
|
||||
#import "AppDelegate+TFStartTimes.h"
|
||||
|
||||
@interface TFBookStoreViewController ()<SGPageTitleViewDelegate, SGPageContentCollectionViewDelegate>
|
||||
|
||||
@property (nonatomic ,strong) NSMutableArray *childControllers;
|
||||
@property (nonatomic ,weak) UIImageView *searchImageView;
|
||||
|
||||
@property (nonatomic ,strong) SGPageTitleView *pageTitleView;
|
||||
@property (nonatomic ,strong) SGPageContentCollectionView *pageContentView;
|
||||
@property (nonatomic ,assign) CGFloat contentOffsetY;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFBookStoreViewController
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self changeNavBarColorWithContentOffsetY:self.contentOffsetY];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubViews];
|
||||
|
||||
// 首次安装增加推荐书籍
|
||||
WS(weakSelf)
|
||||
[TFNetworkManager networkingStatus:^(BOOL status) {
|
||||
if (status) {
|
||||
AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
|
||||
if ([delegate startTimes] == 1) {
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
[weakSelf netRequest];
|
||||
});
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
{
|
||||
[super viewDidAppear:animated];
|
||||
|
||||
[self changeNavBarColorWithContentOffsetY:self.contentOffsetY];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Show_Tabbar object:nil];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pushFromMallCenter:) name:NSNotification_Rack_JumpToMallCenter object:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadSearchBar) name:Notification_Reload_Mall_Hot_Word object:nil];
|
||||
|
||||
[self hiddenNavigationBarLeftButton];
|
||||
|
||||
[self hiddenSeparator];
|
||||
}
|
||||
|
||||
- (void)createSubViews
|
||||
{
|
||||
self.navigationBar.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0];
|
||||
|
||||
WS(weakSelf)
|
||||
#if TF_Enable_Book
|
||||
TFBookStoreNovelController *bookStoreNovel = [[TFBookStoreNovelController alloc] init];
|
||||
bookStoreNovel.productionType = TFProductionTypeNovel;
|
||||
bookStoreNovel.channel = 0;
|
||||
[bookStoreNovel addObserver:KEY_PATH(bookStoreNovel, scrollViewContentOffsetY) complete:^(TFBookStoreNovelController * _Nonnull obj, id _Nullable oldVal, id _Nullable newVal) {
|
||||
[weakSelf changeNavBarColorWithContentOffsetY:[newVal floatValue]];
|
||||
}];
|
||||
[self addChildViewController:bookStoreNovel];
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
TFBookStoreComicController *bookStoreComic = [[TFBookStoreComicController alloc] init];
|
||||
bookStoreComic.productionType = TFProductionTypeComic;
|
||||
bookStoreComic.channel = 0;
|
||||
[bookStoreComic addObserver:KEY_PATH(bookStoreComic, scrollViewContentOffsetY) complete:^(TFBookStoreComicController * _Nonnull obj, id _Nullable oldVal, id _Nullable newVal) {
|
||||
[weakSelf changeNavBarColorWithContentOffsetY:[newVal floatValue]];
|
||||
}];
|
||||
[self addChildViewController:bookStoreComic];
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
TFBookStoreAudioController *bookStoreAudio = [[TFBookStoreAudioController alloc] init];
|
||||
bookStoreAudio.productionType = TFProductionTypeAudio;
|
||||
bookStoreAudio.channel = 0;
|
||||
[bookStoreAudio addObserver:KEY_PATH(bookStoreAudio, scrollViewContentOffsetY) complete:^(TFBookStoreAudioController * _Nonnull obj, id _Nullable oldVal, id _Nullable newVal) {
|
||||
[weakSelf changeNavBarColorWithContentOffsetY:[newVal floatValue]];
|
||||
}];
|
||||
[self addChildViewController:bookStoreAudio];
|
||||
#endif
|
||||
|
||||
NSMutableArray *titleArr = [NSMutableArray array];
|
||||
self.childControllers = [NSMutableArray array];
|
||||
|
||||
// 临时记录单站点状态
|
||||
NSMutableArray *t_titleArr = [NSMutableArray array];
|
||||
NSMutableArray *t_chailArr = [NSMutableArray array];
|
||||
|
||||
for (NSNumber *siteNumber in [TFUtilsHelper getSiteState]) {
|
||||
#if TF_Enable_Book
|
||||
if ([siteNumber integerValue] == 1) {
|
||||
[titleArr addObject:TFLocalizedString(@"小说")];
|
||||
[self.childControllers addObject:bookStoreNovel];
|
||||
|
||||
TFBookStoreNovelController *boyVC = [[TFBookStoreNovelController alloc] init];
|
||||
boyVC.channel = 1;
|
||||
boyVC.productionType = TFProductionTypeNovel;
|
||||
[boyVC addObserver:KEY_PATH(boyVC, scrollViewContentOffsetY) complete:^(TFBookStoreNovelController * _Nonnull obj, id _Nullable oldVal, id _Nullable newVal) {
|
||||
[weakSelf changeNavBarColorWithContentOffsetY:[newVal floatValue]];
|
||||
}];
|
||||
|
||||
TFBookStoreNovelController *girlVC = [[TFBookStoreNovelController alloc] init];
|
||||
girlVC.channel = 2;
|
||||
girlVC.productionType = TFProductionTypeNovel;
|
||||
[girlVC addObserver:KEY_PATH(girlVC, scrollViewContentOffsetY) complete:^(TFBookStoreNovelController * _Nonnull obj, id _Nullable oldVal, id _Nullable newVal) {
|
||||
[weakSelf changeNavBarColorWithContentOffsetY:[newVal floatValue]];
|
||||
}];
|
||||
|
||||
[t_titleArr addObjectsFromArray:@[TFLocalizedString(@"男生"), TFLocalizedString(@"女生")]];
|
||||
[t_chailArr addObjectsFromArray:@[boyVC, girlVC]];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
if ([siteNumber integerValue] == 2) {
|
||||
[titleArr addObject:TFLocalizedString(@"漫画")];
|
||||
[self.childControllers addObject:bookStoreComic];
|
||||
|
||||
TFBookStoreComicController *boyVC = [[TFBookStoreComicController alloc] init];
|
||||
boyVC.channel = 1;
|
||||
boyVC.productionType = TFProductionTypeComic;
|
||||
[boyVC addObserver:KEY_PATH(boyVC, scrollViewContentOffsetY) complete:^(TFBookStoreComicController * _Nonnull obj, id _Nullable oldVal, id _Nullable newVal) {
|
||||
[weakSelf changeNavBarColorWithContentOffsetY:[newVal floatValue]];
|
||||
}];
|
||||
|
||||
TFBookStoreComicController *girlVC = [[TFBookStoreComicController alloc] init];
|
||||
girlVC.channel = 2;
|
||||
girlVC.productionType = TFProductionTypeComic;
|
||||
[girlVC addObserver:KEY_PATH(girlVC, scrollViewContentOffsetY) complete:^(TFBookStoreComicController * _Nonnull obj, id _Nullable oldVal, id _Nullable newVal) {
|
||||
[weakSelf changeNavBarColorWithContentOffsetY:[newVal floatValue]];
|
||||
}];
|
||||
|
||||
[t_titleArr addObjectsFromArray:@[TFLocalizedString(@"男生"), TFLocalizedString(@"女生")]];
|
||||
[t_chailArr addObjectsFromArray:@[boyVC, girlVC]];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
if ([siteNumber integerValue] == 3) {
|
||||
[titleArr addObject:TFLocalizedString(@"听书")];
|
||||
[self.childControllers addObject:bookStoreAudio];
|
||||
|
||||
TFBookStoreAudioController *boyVC = [[TFBookStoreAudioController alloc] init];
|
||||
boyVC.channel = 1;
|
||||
boyVC.productionType = TFProductionTypeAudio;
|
||||
[boyVC addObserver:KEY_PATH(boyVC, scrollViewContentOffsetY) complete:^(TFBookStoreAudioController * _Nonnull obj, id _Nullable oldVal, id _Nullable newVal) {
|
||||
[weakSelf changeNavBarColorWithContentOffsetY:[newVal floatValue]];
|
||||
}];
|
||||
|
||||
TFBookStoreAudioController *girlVC = [[TFBookStoreAudioController alloc] init];
|
||||
girlVC.channel = 2;
|
||||
girlVC.productionType = TFProductionTypeAudio;
|
||||
[girlVC addObserver:KEY_PATH(girlVC, scrollViewContentOffsetY) complete:^(TFBookStoreAudioController * _Nonnull obj, id _Nullable oldVal, id _Nullable newVal) {
|
||||
[weakSelf changeNavBarColorWithContentOffsetY:[newVal floatValue]];
|
||||
}];
|
||||
|
||||
[t_titleArr addObjectsFromArray:@[TFLocalizedString(@"男生"), TFLocalizedString(@"女生")]];
|
||||
[t_chailArr addObjectsFromArray:@[boyVC, girlVC]];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if ([TFUtilsHelper getSiteState].count == 1) {
|
||||
titleArr = t_titleArr;
|
||||
self.childControllers = t_chailArr;
|
||||
}
|
||||
|
||||
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.indicatorColor = [UIColor whiteColor];
|
||||
self.pageConfigure.indicatorStyle = SGIndicatorStyleDynamic;
|
||||
self.pageConfigure.indicatorHeight = 3;
|
||||
self.pageConfigure.indicatorFixedWidth = 10;
|
||||
self.pageConfigure.indicatorDynamicWidth = 14;
|
||||
self.pageConfigure.indicatorToBottomDistance = 3;
|
||||
self.pageConfigure.titleSelectedColor = [UIColor whiteColor];
|
||||
self.pageConfigure.titleFont = kBoldFont16;
|
||||
self.pageConfigure.titleTextZoom = YES;
|
||||
self.pageConfigure.titleTextZoomRatio = 0.2;
|
||||
self.pageConfigure.titleColor = kColorRGBA(255, 255, 255, 0.9);
|
||||
|
||||
CGFloat width = 0;
|
||||
for (NSString *obj in titleArr) {
|
||||
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:titleArr configure:self.pageConfigure];
|
||||
self.pageTitleView.backgroundColor = [UIColor clearColor];
|
||||
[self.navigationBar addSubview:self.pageTitleView];
|
||||
|
||||
if ([TFUtilsHelper getSiteState].count > 1) {
|
||||
self.sexChooseButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
self.sexChooseButton.adjustsImageWhenHighlighted = NO;
|
||||
[self.sexChooseButton setImageEdgeInsets:UIEdgeInsetsMake(10, 20, 10, 0)];
|
||||
[self.sexChooseButton addTarget:self action:@selector(secChooseButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.navigationBar addSubview:self.sexChooseButton];
|
||||
|
||||
if (TFSystemInfoManager.sexChannel == 1) { // 男
|
||||
[self.sexChooseButton setImage:[UIImage imageNamed:@"comic_mall_boy_dark"] forState:UIControlStateNormal];
|
||||
} else { // 女
|
||||
[self.sexChooseButton setImage:[UIImage imageNamed:@"comic_mall_girl_dark"] forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
[self.sexChooseButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.navigationBar.mas_right).with.offset(- kHalfMargin - kQuarterMargin);
|
||||
make.centerY.mas_equalTo(self.pageTitleView.mas_centerY).with.offset(2);
|
||||
make.width.height.mas_equalTo(44);
|
||||
}];
|
||||
}
|
||||
|
||||
UIImageView *searchImageView = [[UIImageView alloc] init];
|
||||
searchImageView.image = [[UIImage imageNamed:@"public_search"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
|
||||
[searchImageView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(searchClick)]];
|
||||
searchImageView.backgroundColor = [UIColor clearColor];
|
||||
searchImageView.userInteractionEnabled = YES;
|
||||
searchImageView.tintColor = kWhiteColor;
|
||||
[self.navigationBar addSubview:searchImageView];
|
||||
self.searchImageView = searchImageView;
|
||||
|
||||
[searchImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.equalTo(self.pageTitleView).offset(2);
|
||||
if ([TFUtilsHelper getSiteState].count > 1) {
|
||||
make.right.equalTo(self.sexChooseButton.mas_left);
|
||||
} else {
|
||||
make.right.equalTo(self.navigationBar).offset(- kHalfMargin - kQuarterMargin);
|
||||
}
|
||||
make.width.height.mas_equalTo(24);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)searchClick
|
||||
{
|
||||
TFSearchViewController *vc = [[TFSearchViewController alloc] init];
|
||||
vc.productionType = self.productionType;
|
||||
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
|
||||
- (void)secChooseButtonClick
|
||||
{
|
||||
if (TFSystemInfoManager.sexChannel == 1) { // 男
|
||||
if (self.isNavDark) {
|
||||
[self.sexChooseButton setImage:[UIImage imageNamed:@"comic_mall_girl"] forState:UIControlStateNormal];
|
||||
} else {
|
||||
[self.sexChooseButton setImage:[UIImage imageNamed:@"comic_mall_girl_dark"] forState:UIControlStateNormal];
|
||||
}
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"已切换至女频")];
|
||||
TFSystemInfoManager.sexChannel = 2;
|
||||
} else { // 女
|
||||
if (self.isNavDark) {
|
||||
[self.sexChooseButton setImage:[UIImage imageNamed:@"comic_mall_boy"] forState:UIControlStateNormal];
|
||||
} else {
|
||||
[self.sexChooseButton setImage:[UIImage imageNamed:@"comic_mall_boy_dark"] forState:UIControlStateNormal];
|
||||
}
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"已切换至男频")];
|
||||
TFSystemInfoManager.sexChannel = 1;
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Channel_Change object:nil];
|
||||
}
|
||||
|
||||
- (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
|
||||
{
|
||||
[self reloadSearchBar];
|
||||
}
|
||||
|
||||
- (void)reloadSearchBar
|
||||
{
|
||||
TFBasicViewController *vc = [self.childControllers objectOrNilAtIndex:self.pageTitleView.signBtnIndex];
|
||||
self.productionType = vc.productionType;
|
||||
CGFloat contentOffsetY = [[vc valueForKey:@"scrollViewContentOffsetY"] integerValue];
|
||||
[self changeNavBarColorWithContentOffsetY:contentOffsetY];
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
// 书架增加推荐书籍
|
||||
[TFNetworkTools POST:Shelf_Recommend parameters:nil model:TFRecommendBookModel.class success:^(BOOL isSuccess, TFRecommendBookModel *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
if (isSuccess) {
|
||||
if ([[TFCollectionManager shareManagerWithProductionType:TFProductionTypeNovel] getAllCollection].count == 0) {
|
||||
for (TFProductionModel *model in t_model.book) {
|
||||
model.productionType = TFProductionTypeNovel;
|
||||
model.is_recommend = YES;
|
||||
[[TFCollectionManager shareManagerWithProductionType:TFProductionTypeNovel] addCollectionWithProductionModel:model atIndex:0];
|
||||
}
|
||||
}
|
||||
|
||||
if ([[TFCollectionManager shareManagerWithProductionType:TFProductionTypeComic] getAllCollection].count == 0) {
|
||||
for (TFProductionModel *model in t_model.comic) {
|
||||
model.productionType = TFProductionTypeComic;
|
||||
model.is_recommend = YES;
|
||||
[[TFCollectionManager shareManagerWithProductionType:TFProductionTypeComic] addCollectionWithProductionModel:model atIndex:0];
|
||||
}
|
||||
}
|
||||
|
||||
if ([[TFCollectionManager shareManagerWithProductionType:TFProductionTypeAudio] getAllCollection].count == 0) {
|
||||
for (TFProductionModel *model in t_model.audio) {
|
||||
model.productionType = TFProductionTypeAudio;
|
||||
model.is_recommend = YES;
|
||||
[[TFCollectionManager shareManagerWithProductionType:TFProductionTypeAudio] addCollectionWithProductionModel:model atIndex:0];
|
||||
}
|
||||
}
|
||||
}
|
||||
} failure:nil];
|
||||
}
|
||||
|
||||
- (void)changeNavBarColorWithContentOffsetY:(CGFloat)contentOffsetY
|
||||
{
|
||||
_contentOffsetY = contentOffsetY;
|
||||
|
||||
CGFloat alpha = [TFColorHelper getAlphaWithContentOffsetY:fabs(contentOffsetY)];
|
||||
CGFloat rbgColor = [TFColorHelper getColorWithContentOffsetY:fabs(contentOffsetY)];
|
||||
|
||||
self.navigationBar.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:alpha];
|
||||
|
||||
[self.pageTitleView resetTitleColor:kColorRGBA(rbgColor, rbgColor, rbgColor, 1) titleSelectedColor:kColorRGBA(rbgColor, rbgColor, rbgColor, 1) indicatorColor:kColorRGBA(rbgColor, rbgColor, rbgColor, 1)];
|
||||
self.searchImageView.tintColor = kColorRGBA(rbgColor, rbgColor, rbgColor, 1);
|
||||
|
||||
if (fabs(contentOffsetY) > 60) {
|
||||
self.isNavDark = YES;
|
||||
} else {
|
||||
self.isNavDark = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setIsNavDark:(BOOL)isNavDark
|
||||
{
|
||||
if (isNavDark) {
|
||||
if ([[TFViewHelper getCurrentViewController] isEqual:self]) {
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
if ([TFUtilsHelper getSiteState].count > 1) {
|
||||
if (TFSystemInfoManager.sexChannel == 1) { // 男
|
||||
[self.sexChooseButton setImage:[UIImage imageNamed:@"comic_mall_boy"] forState:UIControlStateNormal];
|
||||
} else { // 女
|
||||
[self.sexChooseButton setImage:[UIImage imageNamed:@"comic_mall_girl"] forState:UIControlStateNormal];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ([[TFViewHelper getCurrentViewController] isEqual:self]) {
|
||||
[self setStatusBarLightContentStyle];
|
||||
}
|
||||
|
||||
if ([TFUtilsHelper getSiteState].count > 1) {
|
||||
if (TFSystemInfoManager.sexChannel == 1) { // 男
|
||||
[self.sexChooseButton setImage:[UIImage imageNamed:@"comic_mall_boy_dark"] forState:UIControlStateNormal];
|
||||
} else { // 女
|
||||
[self.sexChooseButton setImage:[UIImage imageNamed:@"comic_mall_girl_dark"] forState:UIControlStateNormal];
|
||||
}
|
||||
}
|
||||
}
|
||||
_isNavDark = isNavDark;
|
||||
}
|
||||
|
||||
- (void)pushFromMallCenter:(NSNotification *)notification
|
||||
{
|
||||
#if TF_Enable_Comic
|
||||
// 跳转到漫画相关内容
|
||||
if ([notification.object isEqualToString:@"comic"]) {
|
||||
for (NSInteger i = 0; i < self.pageContentView.childViewControllers.count ; i ++) {
|
||||
if ([[self.pageContentView.childViewControllers objectOrNilAtIndex:i] isKindOfClass:[TFBookStoreComicController class]]) {
|
||||
self.pageTitleView.resetSelectedIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Book
|
||||
// 跳转到小说相关内容
|
||||
if ([notification.object isEqualToString:@"novel"]) {
|
||||
for (NSInteger i = 0; i < self.pageContentView.childViewControllers.count ; i ++) {
|
||||
if ([[self.pageContentView.childViewControllers objectOrNilAtIndex:i] isKindOfClass:[TFBookStoreNovelController class]]) {
|
||||
self.pageTitleView.resetSelectedIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
// 跳转到听书相关内容
|
||||
if ([notification.object isEqualToString:@"audio"]) {
|
||||
for (NSInteger i = 0; i < self.pageContentView.childViewControllers.count ; i ++) {
|
||||
if ([[self.pageContentView.childViewControllers objectOrNilAtIndex:i] isKindOfClass:[TFBookStoreAudioController class]]) {
|
||||
self.pageTitleView.resetSelectedIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// TFBookStoreLabelModel.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/2.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFAdvertModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class TFProductionModel;
|
||||
@interface TFBookStoreLabelModel : TFAdvertModel
|
||||
|
||||
@property (nonatomic ,assign) NSInteger recommend_id; // 推荐位id
|
||||
@property (nonatomic ,assign) NSInteger style; // 展示风格
|
||||
@property (nonatomic ,copy) NSString *label; // 名称
|
||||
@property (nonatomic ,copy) NSString *total; // 漫画数
|
||||
@property (nonatomic ,assign) BOOL can_more; // 是否有更多 true有,false没有
|
||||
@property (nonatomic ,assign) BOOL can_refresh; // 是否有更多 true有,false没有
|
||||
@property (nonatomic ,assign) NSInteger expire_time;
|
||||
@property (nonatomic ,strong) NSArray <TFProductionModel *>*list; // 作品列表
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TFBookStoreLabelModel.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/2.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookStoreLabelModel.h"
|
||||
|
||||
@implementation TFBookStoreLabelModel
|
||||
|
||||
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass
|
||||
{
|
||||
return @{@"list" : [TFProductionModel class]};
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// TFBookStoreModel.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/22.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class TFBannerModel, TFBookStoreLabelModel, TFBookStoreMenusModel;
|
||||
|
||||
@interface TFBookStoreModel : NSObject
|
||||
|
||||
@property (nonatomic ,strong) NSArray <TFBannerModel *>*banner;
|
||||
@property (nonatomic ,strong) NSArray <TFBookStoreLabelModel *>*label;
|
||||
@property (nonatomic ,strong) NSArray <TFBookStoreMenusModel *> *menus_tabs;
|
||||
@property (nonatomic ,strong) NSArray <NSString *>*hot_word;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@interface TFBookStoreMenusModel : NSObject
|
||||
|
||||
@property (nonatomic ,copy) NSString *title;
|
||||
@property (nonatomic ,copy) NSString *icon;
|
||||
@property (nonatomic ,copy) NSString *action;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// TFBookStoreModel.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/22.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookStoreModel.h"
|
||||
#import "TFBookStoreLabelModel.h"
|
||||
#import "TFUserCenterModel.h"
|
||||
|
||||
@implementation TFBookStoreModel
|
||||
|
||||
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass
|
||||
{
|
||||
return @{@"banner" : [TFBannerModel class],
|
||||
@"label" : [TFBookStoreLabelModel class],
|
||||
@"menus_tabs": [TFBookStoreMenusModel class]
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation TFBookStoreMenusModel
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// TFBookStoreRecommend.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/12.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class TFProductionListModel;
|
||||
@interface TFBookStoreRecommend : NSObject
|
||||
|
||||
@property (nonatomic ,copy) NSString *recommendTitle;
|
||||
|
||||
@property (nonatomic ,strong) TFProductionListModel *recommendList;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// TFBookStoreRecommend.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/12.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookStoreRecommend.h"
|
||||
|
||||
@implementation TFBookStoreRecommend
|
||||
|
||||
+ (NSDictionary *)modelCustomPropertyMapper
|
||||
{
|
||||
return @{
|
||||
@"recommendTitle":@"recommend.title",
|
||||
@"recommendList": @[@"list", @"book"]
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// TFBookStoreMenuView.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
|
||||
|
||||
typedef NS_ENUM(NSUInteger, TFMenuButtonType) {
|
||||
TFMenuButtonTypeFree, // 免费
|
||||
TFMenuButtonTypeComplete, // 完结
|
||||
TFMenuButtonTypeSort, // 分类
|
||||
TFMenuButtonTypePopularity, // 排行
|
||||
TFMenuButtonTypeMember // 会员
|
||||
};
|
||||
|
||||
typedef void(^BannerrImageClickBlock)(TFBannerModel *bannerModel);
|
||||
|
||||
@interface TFBookStoreMenuView : UIView
|
||||
|
||||
@property (nonatomic ,assign) TFProductionType productionType;
|
||||
@property (nonatomic ,strong) TFBookStoreModel *mallCenterModel;
|
||||
|
||||
@property (nonatomic ,copy) void (^menuButtonClickBlock)(TFMenuButtonType menuButtonType, NSString *menuButtonTitle);
|
||||
|
||||
@property (nonatomic ,copy) void(^bannerrImageClickBlock)(TFBannerModel *bannerModel); // banner点击
|
||||
|
||||
- (void)createSubViews;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,186 @@
|
||||
//
|
||||
// TFBookStoreMenuView.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/2.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookStoreMenuView.h"
|
||||
#import "YJMallCollectionViewCell.h"
|
||||
#import "YJBannerView.h"
|
||||
#import "TFUserCenterModel.h"
|
||||
|
||||
@interface TFBookStoreMenuView () <YJBannerViewDelegate, YJBannerViewDataSource>
|
||||
|
||||
@property (nonatomic ,strong) YJBannerView *bannerView;
|
||||
@property (nonatomic ,strong) UIView *menuBarView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFBookStoreMenuView
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if (self = [super init]) {
|
||||
|
||||
CGFloat headerHeight = SCREEN_WIDTH - kHalfMargin;
|
||||
|
||||
if (is_iPhone6P) {
|
||||
headerHeight = SCREEN_WIDTH - kMargin - kQuarterMargin;
|
||||
} else if (is_iPhoneX) {
|
||||
headerHeight = SCREEN_WIDTH;
|
||||
} else if (is_iPhone6) {
|
||||
headerHeight = SCREEN_WIDTH - kMargin;
|
||||
}
|
||||
|
||||
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, headerHeight);
|
||||
self.clipsToBounds = YES;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setProductionType:(TFProductionType)productionType
|
||||
{
|
||||
_productionType = productionType;
|
||||
|
||||
[self createSubViews];
|
||||
}
|
||||
|
||||
- (void)createSubViews
|
||||
{
|
||||
self.backgroundColor = kWhiteColor;
|
||||
|
||||
[self addSubview:self.bannerView];
|
||||
|
||||
UIImageView *bannerBottonView = [[UIImageView alloc] init];
|
||||
bannerBottonView.image = [UIImage imageNamed:@"banner_bottom_line.png"];
|
||||
[self addSubview:bannerBottonView];
|
||||
|
||||
[bannerBottonView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.bottom.mas_equalTo(self.bannerView.mas_bottom).with.offset(1);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH);
|
||||
make.height.mas_equalTo(kGeometricHeight(SCREEN_WIDTH, 800, 57));
|
||||
}];
|
||||
|
||||
self.menuBarView = [[UIView alloc] init];
|
||||
self.menuBarView.backgroundColor = kWhiteColor;
|
||||
[self addSubview:self.menuBarView];
|
||||
|
||||
[self.menuBarView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.bottom.mas_equalTo(self.mas_bottom);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH);
|
||||
make.height.mas_equalTo(SCREEN_WIDTH / 5 - kQuarterMargin);
|
||||
}];
|
||||
}
|
||||
|
||||
- (YJBannerView *)bannerView
|
||||
{
|
||||
if (!_bannerView) {
|
||||
_bannerView = [YJBannerView bannerViewWithFrame:CGRectMake(0, 0, self.width, self.height - (SCREEN_WIDTH / 5)) dataSource:self delegate:self emptyImage:HoldImage placeholderImage:HoldImage selectorString:NSStringFromSelector(@selector(setImageWithURL:placeholder:))];
|
||||
_bannerView.repeatCount = 9999;
|
||||
_bannerView.pageControlAliment = PageControlAlimentCenter;
|
||||
_bannerView.autoDuration = 5.0f;
|
||||
_bannerView.pageControlStyle = PageControlCustom;
|
||||
_bannerView.pageControlDotSize = CGSizeMake(10, 5);
|
||||
_bannerView.pageControlBottomMargin = 15;
|
||||
_bannerView.customPageControlHighlightImage = [UIImage imageNamed:@"pageControlS"];
|
||||
_bannerView.customPageControlNormalImage = [UIImage imageNamed:@"pageControlN"];
|
||||
}
|
||||
return _bannerView;
|
||||
}
|
||||
|
||||
- (NSArray *)bannerViewImages:(YJBannerView *)bannerView
|
||||
{
|
||||
NSMutableArray *t_arr = [NSMutableArray array];
|
||||
for (TFBannerModel *t_model in self.mallCenterModel.banner) {
|
||||
[t_arr addObject:t_model.image];
|
||||
}
|
||||
return t_arr;
|
||||
}
|
||||
|
||||
// 代理方法 点击了哪个bannerView 的 第几个元素
|
||||
- (void)bannerView:(YJBannerView *)bannerView didSelectItemAtIndex:(NSInteger)index
|
||||
{
|
||||
if (self.bannerrImageClickBlock) {
|
||||
self.bannerrImageClickBlock([self.mallCenterModel.banner objectOrNilAtIndex:index]);
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray *)bannerViewRegistCustomCellClass:(YJBannerView *)bannerView
|
||||
{
|
||||
return @[[YJMallCollectionViewCell class]];
|
||||
}
|
||||
|
||||
/** 根据 Index 选择使用哪个 reuseIdentifier */
|
||||
- (Class)bannerView:(YJBannerView *)bannerView reuseIdentifierForIndex:(NSInteger)index
|
||||
{
|
||||
return [YJMallCollectionViewCell class];
|
||||
}
|
||||
|
||||
/** 自定义 View 刷新数据或者其他配置 */
|
||||
- (UICollectionViewCell *)bannerView:(YJBannerView *)bannerView customCell:(UICollectionViewCell *)customCell index:(NSInteger)index
|
||||
{
|
||||
YJMallCollectionViewCell *cell = (YJMallCollectionViewCell *)customCell;
|
||||
cell.bannerModel = [self.mallCenterModel.banner objectOrNilAtIndex:index];
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (void)setMallCenterModel:(TFBookStoreModel *)mallCenterModel
|
||||
{
|
||||
_mallCenterModel = mallCenterModel;
|
||||
|
||||
[self.menuBarView removeAllSubviews];
|
||||
[self.bannerView reloadData];
|
||||
|
||||
for (int i = 0; i < mallCenterModel.menus_tabs.count; i ++) {
|
||||
|
||||
TFBookStoreMenusModel *t_model = [mallCenterModel.menus_tabs objectAtIndex:i];
|
||||
|
||||
TFButton *button = [[TFButton alloc] initWithFrame:CGRectZero buttonTitle:t_model.title ? : @"" buttonImageName:t_model.icon ? : @"" buttonIndicator:TFButtonIndicatorTitleBottom showMaskView:YES];
|
||||
button.graphicDistance = 0;
|
||||
button.buttonImageScale = 0.6;
|
||||
button.buttonTitleFont = kFont13;
|
||||
button.buttonTag = t_model.action;
|
||||
[button addTarget:self action:@selector(menuButtonClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.menuBarView addSubview:button];
|
||||
|
||||
CGFloat buttonWidth = SCREEN_WIDTH / mallCenterModel.menus_tabs.count;
|
||||
CGFloat buttonHeight = SCREEN_WIDTH / 5 - kQuarterMargin;
|
||||
|
||||
[button mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(i * buttonWidth);
|
||||
make.top.mas_equalTo(0);
|
||||
make.width.mas_equalTo(buttonWidth);
|
||||
make.height.mas_equalTo(buttonHeight);
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)menuButtonClick:(TFButton *)sender
|
||||
{
|
||||
if (self.menuButtonClickBlock) {
|
||||
if ([sender.buttonTag isEqualToString:@"free"]) {
|
||||
self.menuButtonClickBlock(TFMenuButtonTypeFree, sender.buttonTitle ? : @"");
|
||||
}
|
||||
|
||||
if ([sender.buttonTag isEqualToString:@"finished"]) {
|
||||
self.menuButtonClickBlock(TFMenuButtonTypeComplete, sender.buttonTitle ? : @"");
|
||||
}
|
||||
|
||||
if ([sender.buttonTag isEqualToString:@"category"]) {
|
||||
self.menuButtonClickBlock(TFMenuButtonTypeSort, sender.buttonTitle ? : @"");
|
||||
}
|
||||
|
||||
if ([sender.buttonTag isEqualToString:@"rank"]) {
|
||||
self.menuButtonClickBlock(TFMenuButtonTypePopularity, sender.buttonTitle ? : @"");
|
||||
}
|
||||
|
||||
if ([sender.buttonTag isEqualToString:@"vip"]) {
|
||||
self.menuButtonClickBlock(TFMenuButtonTypeMember, sender.buttonTitle ? : @"");
|
||||
}
|
||||
}
|
||||
}
|
||||
@end
|
||||
Reference in New Issue
Block a user