小说绘上架版本
This commit is contained in:
@@ -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