小说绘上架版本
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// TFComicBrowseBottomBar.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#define Comic_Menu_Bottom_Bar_Top_Height 40
|
||||
|
||||
#define Comic_Menu_Bottom_Bar_Height (PUB_TABBAR_HEIGHT + Comic_Menu_Bottom_Bar_Top_Height)
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFComicBrowseBottomBar : UIView <YYTextViewDelegate>
|
||||
|
||||
@property (nonatomic ,strong) TFProductionChapterModel *comicChapterModel;
|
||||
|
||||
@property (nonatomic ,strong) TFProductionModel *productionModel;
|
||||
|
||||
- (void)showMenuBottomBar;
|
||||
|
||||
- (void)hiddenMenuBottomBar;
|
||||
|
||||
- (void)startLoadingData;
|
||||
|
||||
- (void)stopLoadingData;
|
||||
|
||||
- (void)reloadCollectionState;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+694
@@ -0,0 +1,694 @@
|
||||
//
|
||||
// TFComicBrowseBottomBar.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFComicBrowseBottomBar.h"
|
||||
#import "TFComicBrowseSetBar.h"
|
||||
|
||||
#import "TFShareManager.h"
|
||||
#import "WXYZ_ComicDownloadManager.h"
|
||||
#import "TFCollectionManager.h"
|
||||
|
||||
#import "WXYZ_BadgeView.h"
|
||||
#import "UIControl+EventInterval.h"
|
||||
|
||||
#define MenuButtonHeight 50
|
||||
|
||||
@interface TFComicBrowseBottomBar ()
|
||||
{
|
||||
#if TF_Comments_Mode
|
||||
UIButton *commentsButton;
|
||||
#endif
|
||||
|
||||
#if TF_Comments_Mode
|
||||
YYTextView *commentsTextView;
|
||||
UIButton *sendComments;
|
||||
#endif
|
||||
|
||||
UILabel *currentPageLabel;
|
||||
UIButton *previousButton;
|
||||
UIButton *nextButton;
|
||||
UIActivityIndicatorView *indicatorView;
|
||||
|
||||
TFButton *barrageSwitch;
|
||||
|
||||
TFComicBrowseSetBar *settingBar;
|
||||
|
||||
UIButton *scrollToTop;
|
||||
UIButton *collectionButton;
|
||||
|
||||
CGFloat keyboardHeight; //键盘高度
|
||||
|
||||
BOOL isCommentState; // 是否是评论状态
|
||||
|
||||
__weak UIButton *_leftImageButton;
|
||||
|
||||
WXYZ_BadgeView *badgeView;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation TFComicBrowseBottomBar
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if (self = [super init]) {
|
||||
|
||||
#if TF_Comments_Mode
|
||||
self.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, PUB_TABBAR_HEIGHT + Comic_Menu_Bottom_Bar_Top_Height);
|
||||
#else
|
||||
self.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, Comic_Menu_Bottom_Bar_Height - Comic_Menu_Bottom_Bar_Top_Height);
|
||||
#endif
|
||||
|
||||
self.backgroundColor = kGrayViewColor;
|
||||
|
||||
//增加监听,当键盘出现或改变时收出消息
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:)name:UIKeyboardWillShowNotification object:nil];
|
||||
//增加监听,当键退出时收出消息
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:)name:UIKeyboardWillHideNotification object:nil];
|
||||
[self createSubViews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createSubViews
|
||||
{
|
||||
#if TF_Comments_Mode
|
||||
sendComments = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
if ([[[NSUserDefaults standardUserDefaults] objectForKey:Enable_Barrage] isEqualToString:@"1"]) {
|
||||
[sendComments setTitle:TFLocalizedString(@"发射") forState:UIControlStateNormal];
|
||||
isCommentState = NO;
|
||||
} else {
|
||||
[sendComments setTitle:TFLocalizedString(@"发送") forState:UIControlStateNormal];
|
||||
isCommentState = YES;
|
||||
}
|
||||
sendComments.backgroundColor = [UIColor clearColor];
|
||||
[sendComments setTitleColor:kBlackColor forState:UIControlStateNormal];
|
||||
[sendComments.titleLabel setFont:kMainFont];
|
||||
[sendComments addTarget:self action:@selector(sendCommentsClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self addSubview:sendComments];
|
||||
|
||||
[sendComments mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.mas_right);
|
||||
make.top.mas_equalTo(kQuarterMargin);
|
||||
make.width.mas_equalTo(70);
|
||||
make.height.mas_equalTo(Comic_Menu_Bottom_Bar_Top_Height - kHalfMargin);
|
||||
}];
|
||||
|
||||
commentsTextView = [[YYTextView alloc] init];
|
||||
commentsTextView.backgroundColor = kWhiteColor;
|
||||
commentsTextView.contentInset = UIEdgeInsetsMake(2, 30, 0, 0);
|
||||
commentsTextView.textVerticalAlignment = YYTextVerticalAlignmentCenter;
|
||||
if ([[[NSUserDefaults standardUserDefaults] objectForKey:Enable_Barrage] isEqualToString:@"1"]) {
|
||||
commentsTextView.placeholderText = TFLocalizedString(@"发一条弹幕吧");
|
||||
} else {
|
||||
commentsTextView.placeholderText = TFLocalizedString(@"发一条评论吧");
|
||||
}
|
||||
|
||||
commentsTextView.placeholderFont = kFont12;
|
||||
commentsTextView.placeholderTextColor = kGrayTextColor;
|
||||
commentsTextView.font = kFont12;
|
||||
commentsTextView.returnKeyType = UIReturnKeySend;
|
||||
commentsTextView.layer.cornerRadius = (Comic_Menu_Bottom_Bar_Top_Height - kHalfMargin) / 2;
|
||||
commentsTextView.layer.borderColor = kGrayViewColor.CGColor;
|
||||
commentsTextView.layer.borderWidth = 0.8;
|
||||
commentsTextView.delegate = self;
|
||||
[self addSubview:commentsTextView];
|
||||
|
||||
[commentsTextView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kMargin);
|
||||
make.top.mas_equalTo(kQuarterMargin);
|
||||
make.right.mas_equalTo(sendComments.mas_left).with.offset(kHalfMargin);
|
||||
make.height.mas_equalTo(sendComments.mas_height);
|
||||
}];
|
||||
|
||||
|
||||
UIButton *leftImageButton = [[UIButton alloc] init];
|
||||
_leftImageButton = leftImageButton;
|
||||
if ([[[NSUserDefaults standardUserDefaults] objectForKey:Enable_Barrage] isEqualToString:@"1"]) {
|
||||
leftImageButton.tag = 0;
|
||||
[leftImageButton setImage:[UIImage imageNamed:TFLocalizedString(@"comic_barrage")] forState:UIControlStateNormal];
|
||||
} else {
|
||||
leftImageButton.tag = 1;
|
||||
[leftImageButton setImage:[UIImage imageNamed:TFLocalizedString(@"comic_comments_icon")] forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
leftImageButton.adjustsImageWhenHighlighted = NO;
|
||||
[leftImageButton addTarget:self action:@selector(changeCommentsState:) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
[self addSubview:leftImageButton];
|
||||
|
||||
[leftImageButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(commentsTextView.mas_left).with.offset(kQuarterMargin);
|
||||
make.centerY.mas_equalTo(sendComments.mas_centerY);
|
||||
make.width.height.mas_equalTo(30 - kHalfMargin);
|
||||
}];
|
||||
|
||||
#endif
|
||||
|
||||
// 上一话
|
||||
previousButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
previousButton.backgroundColor = [UIColor clearColor];
|
||||
previousButton.adjustsImageWhenHighlighted = NO;
|
||||
previousButton.enabled = NO;
|
||||
[previousButton.titleLabel setFont:kMainFont];
|
||||
[previousButton setImage:[[UIImage imageNamed:@"public_back"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
|
||||
[previousButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
|
||||
[previousButton setTintColor:kGrayTextLightColor];
|
||||
[previousButton setImageEdgeInsets:UIEdgeInsetsMake(14, 20, 14, 8)];
|
||||
[previousButton addTarget:self action:@selector(previousButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self addSubview:previousButton];
|
||||
|
||||
[previousButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.mas_left);
|
||||
make.bottom.mas_equalTo(self.mas_bottom).with.offset(- PUB_TABBAR_OFFSET);
|
||||
make.width.mas_equalTo(PUB_TABBAR_HEIGHT - PUB_TABBAR_OFFSET);
|
||||
make.height.mas_equalTo(PUB_TABBAR_HEIGHT - PUB_TABBAR_OFFSET);
|
||||
}];
|
||||
|
||||
currentPageLabel = [[UILabel alloc] init];
|
||||
currentPageLabel.text = TFLocalizedString(@"当前话");
|
||||
currentPageLabel.textAlignment = NSTextAlignmentCenter;
|
||||
currentPageLabel.textColor = kBlackColor;
|
||||
currentPageLabel.font = kMainFont;
|
||||
[self addSubview:currentPageLabel];
|
||||
|
||||
[currentPageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(previousButton.mas_right);
|
||||
make.centerY.mas_equalTo(previousButton.mas_centerY);
|
||||
make.width.mas_equalTo(70);
|
||||
make.height.mas_equalTo(previousButton.mas_height);
|
||||
}];
|
||||
|
||||
indicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:(UIActivityIndicatorViewStyleGray)];
|
||||
indicatorView.color = kBlackColor;
|
||||
indicatorView.hidesWhenStopped = YES;
|
||||
[currentPageLabel addSubview:indicatorView];
|
||||
|
||||
[indicatorView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(currentPageLabel.mas_centerX);
|
||||
make.centerY.mas_equalTo(currentPageLabel.mas_centerY);
|
||||
make.width.height.mas_equalTo(previousButton.mas_height);
|
||||
}];
|
||||
|
||||
// 下一话
|
||||
nextButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
nextButton.backgroundColor = [UIColor clearColor];
|
||||
nextButton.adjustsImageWhenHighlighted = NO;
|
||||
nextButton.transform = CGAffineTransformMakeRotation(M_PI);
|
||||
nextButton.enabled = NO;
|
||||
[nextButton.titleLabel setFont:kMainFont];
|
||||
[nextButton setImage:[[UIImage imageNamed:@"public_back"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
|
||||
[nextButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
|
||||
[nextButton setTintColor:kGrayTextLightColor];
|
||||
[nextButton setImageEdgeInsets:UIEdgeInsetsMake(14, 20, 14, 8)];
|
||||
[nextButton addTarget:self action:@selector(nextButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self addSubview:nextButton];
|
||||
|
||||
[nextButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(currentPageLabel.mas_right);
|
||||
make.centerY.mas_equalTo(previousButton.mas_centerY);
|
||||
make.width.mas_equalTo(previousButton.mas_width);
|
||||
make.height.mas_equalTo(previousButton.mas_height);
|
||||
}];
|
||||
|
||||
UIView *buttonMenuBar = [[UIView alloc] init];
|
||||
buttonMenuBar.backgroundColor = [UIColor clearColor];
|
||||
[self addSubview:buttonMenuBar];
|
||||
|
||||
[buttonMenuBar mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(nextButton.mas_right).with.offset(kMargin);
|
||||
make.centerY.mas_equalTo(previousButton.mas_centerY);
|
||||
make.right.mas_equalTo(self.mas_right).with.offset(- kMargin);
|
||||
make.height.mas_equalTo(30);
|
||||
}];
|
||||
|
||||
UIButton *settingButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
settingButton.adjustsImageWhenHighlighted = NO;
|
||||
settingButton.tintColor = kColorRGB(111, 111, 111);
|
||||
settingButton.touchEventInterval = 0.5;
|
||||
[settingButton setImage:[[UIImage imageNamed:@"comic_setting"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
|
||||
[settingButton setImageEdgeInsets:UIEdgeInsetsMake(3, 3, 3, 3)];
|
||||
[settingButton addTarget:self action:@selector(settingButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[buttonMenuBar addSubview:settingButton];
|
||||
|
||||
#if TF_Download_Mode
|
||||
UIButton *downloadButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
downloadButton.adjustsImageWhenHighlighted = NO;
|
||||
downloadButton.tintColor = kColorRGB(111, 111, 111);
|
||||
downloadButton.touchEventInterval = 0.5;
|
||||
[downloadButton setImage:[[UIImage imageNamed:@"comic_download"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
|
||||
[downloadButton setImageEdgeInsets:UIEdgeInsetsMake(3, 3, 4, 4)];
|
||||
[downloadButton addTarget:self action:@selector(downloadButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[buttonMenuBar addSubview:downloadButton];
|
||||
#endif
|
||||
|
||||
|
||||
UIButton *shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
shareButton.adjustsImageWhenHighlighted = NO;
|
||||
shareButton.tintColor = kColorRGB(111, 111, 111);
|
||||
shareButton.touchEventInterval = 0.5;
|
||||
[shareButton setImage:[[UIImage imageNamed:@"comic_share"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
|
||||
[shareButton setImageEdgeInsets:UIEdgeInsetsMake(4, 4, 4, 4)];
|
||||
[shareButton addTarget:self action:@selector(shareButtonClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[buttonMenuBar addSubview:shareButton];
|
||||
|
||||
|
||||
#if TF_Comments_Mode
|
||||
commentsButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
commentsButton.adjustsImageWhenHighlighted = NO;
|
||||
commentsButton.tintColor = kColorRGB(111, 111, 111);
|
||||
commentsButton.touchEventInterval = 0.5;
|
||||
[commentsButton setImage:[[UIImage imageNamed:@"comic_comments"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
|
||||
[commentsButton setImageEdgeInsets:UIEdgeInsetsMake(5, 5, 5, 5)];
|
||||
[commentsButton addTarget:self action:@selector(checkCommentsClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[buttonMenuBar addSubview:commentsButton];
|
||||
|
||||
badgeView = [[WXYZ_BadgeView alloc] initWithView:commentsButton];
|
||||
[badgeView setCircleAtFrame:CGRectMake(0, 0, 17, 17)];
|
||||
[badgeView moveCircleByX:18 Y:- 2];
|
||||
badgeView.maxCount = 99;
|
||||
[badgeView setCircleColor:kRedColor labelColor:kWhiteColor];
|
||||
[badgeView setCountLabelFont:kFont9];
|
||||
|
||||
#endif
|
||||
|
||||
NSArray *buttonMenuArr = [NSArray arrayWithObjects:
|
||||
#if TF_Comments_Mode
|
||||
commentsButton,
|
||||
#endif
|
||||
|
||||
shareButton,
|
||||
|
||||
#if TF_Download_Mode
|
||||
downloadButton,
|
||||
#endif
|
||||
settingButton, nil];
|
||||
[buttonMenuArr mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedItemLength:30 leadSpacing:0 tailSpacing:0];
|
||||
[buttonMenuArr mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(0);
|
||||
make.height.mas_equalTo(30);
|
||||
}];
|
||||
|
||||
#if TF_Comments_Mode
|
||||
NSString *imageName = nil;
|
||||
if ([[[NSUserDefaults standardUserDefaults] objectForKey:Enable_Barrage] isEqualToString:@"1"]) {
|
||||
imageName = @"comic_danmu_select";
|
||||
} else {
|
||||
imageName = @"comic_danmu";
|
||||
}
|
||||
barrageSwitch = [[TFButton alloc] initWithFrame:CGRectZero buttonTitle:TFLocalizedString(@"弹幕") buttonSubTitle:@"" buttonImageName:imageName buttonIndicator:TFButtonIndicatorTitleRight showMaskView:NO];
|
||||
barrageSwitch.buttonTitleFont = kFont10;
|
||||
barrageSwitch.buttonTitleColor = kWhiteColor;
|
||||
barrageSwitch.graphicDistance = 2;
|
||||
barrageSwitch.buttonImageScale = 0.5;
|
||||
barrageSwitch.tag = 1;
|
||||
barrageSwitch.backgroundColor = kBlackTransparentColor;
|
||||
barrageSwitch.layer.cornerRadius = 10;
|
||||
[barrageSwitch addTarget:self action:@selector(barrageSwitchClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self addSubview:barrageSwitch];
|
||||
|
||||
CGFloat width = [TFViewHelper getDynamicWidthWithLabelFont:kFont10 labelHeight:22.0 labelText:TFLocalizedString(@"弹幕") maxWidth:SCREEN_WIDTH / 2.0];
|
||||
[barrageSwitch mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kHalfMargin);
|
||||
make.top.mas_equalTo(self.mas_top).with.offset(PUB_TABBAR_HEIGHT + Comic_Menu_Bottom_Bar_Top_Height);
|
||||
make.width.mas_equalTo(width + kLabelHeight);
|
||||
make.height.mas_equalTo(22);
|
||||
}];
|
||||
#endif
|
||||
|
||||
settingBar = [[TFComicBrowseSetBar alloc] init];
|
||||
|
||||
scrollToTop = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
scrollToTop.adjustsImageWhenHighlighted = NO;
|
||||
[scrollToTop setImage:[UIImage imageNamed:TFLocalizedString(@"comic_top")] forState:UIControlStateNormal];
|
||||
[scrollToTop addTarget:self action:@selector(scrollToTopClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self addSubview:scrollToTop];
|
||||
|
||||
[scrollToTop mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.mas_right).with.offset(- kHalfMargin);
|
||||
make.bottom.mas_equalTo(self.mas_top).with.offset(6 * MenuButtonHeight);
|
||||
make.width.height.mas_equalTo(MenuButtonHeight);
|
||||
}];
|
||||
|
||||
if (![[TFCollectionManager shareManagerWithProductionType:TFProductionTypeComic] isCollectedWithProduction_id:self.comicChapterModel.production_id]) {
|
||||
collectionButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
collectionButton.adjustsImageWhenHighlighted = NO;
|
||||
[collectionButton setImage:[UIImage imageNamed:TFLocalizedString(@"comic_collection")] forState:UIControlStateNormal];
|
||||
[collectionButton addTarget:self action:@selector(collectionButtonClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self addSubview:collectionButton];
|
||||
|
||||
[collectionButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.mas_right).with.offset(- kHalfMargin);
|
||||
make.bottom.mas_equalTo(scrollToTop.mas_top).with.offset(- kHalfMargin);
|
||||
make.width.height.mas_equalTo(MenuButtonHeight);
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showMenuBottomBar
|
||||
{
|
||||
[UIView animateWithDuration:kAnimatedDurationFast animations:^{
|
||||
#if TF_Comments_Mode
|
||||
self.frame = CGRectMake(0, SCREEN_HEIGHT - (PUB_TABBAR_HEIGHT + Comic_Menu_Bottom_Bar_Top_Height), SCREEN_WIDTH, PUB_TABBAR_HEIGHT + Comic_Menu_Bottom_Bar_Top_Height);
|
||||
#else
|
||||
self.frame = CGRectMake(0, SCREEN_HEIGHT - (Comic_Menu_Bottom_Bar_Height - Comic_Menu_Bottom_Bar_Top_Height), SCREEN_WIDTH, Comic_Menu_Bottom_Bar_Height - Comic_Menu_Bottom_Bar_Top_Height);
|
||||
#endif
|
||||
}];
|
||||
|
||||
[barrageSwitch mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.mas_top).with.offset(- kHalfMargin - 20);
|
||||
}];
|
||||
|
||||
[scrollToTop mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.mas_equalTo(self.mas_top).with.offset(- kHalfMargin);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)reloadCollectionState
|
||||
{
|
||||
if (![[TFCollectionManager shareManagerWithProductionType:TFProductionTypeComic] isCollectedWithProduction_id:self.comicChapterModel.production_id]) {
|
||||
collectionButton.hidden = NO;
|
||||
} else {
|
||||
collectionButton.hidden = YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)hiddenMenuBottomBar
|
||||
{
|
||||
[[[UIApplication sharedApplication] keyWindow] endEditing:YES];
|
||||
[UIView animateWithDuration:kAnimatedDurationFast animations:^{
|
||||
#if TF_Comments_Mode
|
||||
self.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, PUB_TABBAR_HEIGHT + Comic_Menu_Bottom_Bar_Top_Height);
|
||||
#else
|
||||
self.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, Comic_Menu_Bottom_Bar_Height - Comic_Menu_Bottom_Bar_Top_Height);
|
||||
#endif
|
||||
}];
|
||||
|
||||
[barrageSwitch mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.mas_top).with.offset(PUB_TABBAR_HEIGHT + Comic_Menu_Bottom_Bar_Top_Height);
|
||||
}];
|
||||
|
||||
[scrollToTop mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.mas_equalTo(self.mas_top).with.offset(6 * MenuButtonHeight);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)startLoadingData
|
||||
{
|
||||
currentPageLabel.text = @"";
|
||||
[indicatorView startAnimating];
|
||||
previousButton.enabled = NO;
|
||||
[previousButton setTintColor:kGrayTextLightColor];
|
||||
|
||||
nextButton.enabled = NO;
|
||||
[nextButton setTintColor:kGrayTextLightColor];
|
||||
}
|
||||
|
||||
- (void)stopLoadingData
|
||||
{
|
||||
currentPageLabel.text = TFLocalizedString(@"当前话");
|
||||
[indicatorView stopAnimating];
|
||||
|
||||
previousButton.enabled = YES;
|
||||
[previousButton setTintColor:kBlackColor];
|
||||
|
||||
nextButton.enabled = YES;
|
||||
[nextButton setTintColor:kBlackColor];
|
||||
}
|
||||
|
||||
#pragma mark - 点击事件
|
||||
|
||||
- (void)changeCommentsState:(UIButton *)sender
|
||||
{
|
||||
if (sender.tag == 0) { // 评论
|
||||
[self changeComentInput:YES];
|
||||
} else { // 吐槽
|
||||
[self changeComentInput:NO];
|
||||
}
|
||||
}
|
||||
|
||||
// 改变评论输入框状态
|
||||
- (void)changeComentInput:(BOOL)isComment {
|
||||
#if TF_Comments_Mode
|
||||
if (isComment) {
|
||||
commentsTextView.placeholderText = TFLocalizedString(@"发一条评论吧");
|
||||
[sendComments setTitle:TFLocalizedString(@"发送") forState:UIControlStateNormal];
|
||||
isCommentState = YES;
|
||||
_leftImageButton.tag = 1;
|
||||
[_leftImageButton setImage:[UIImage imageNamed:TFLocalizedString(@"comic_comments_icon")] forState:UIControlStateNormal];
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isComment) {
|
||||
commentsTextView.placeholderText = TFLocalizedString(@"发一条弹幕吧");
|
||||
[sendComments setTitle:TFLocalizedString(@"发射") forState:UIControlStateNormal];
|
||||
isCommentState = NO;
|
||||
_leftImageButton.tag = 0;
|
||||
[_leftImageButton setImage:[UIImage imageNamed:TFLocalizedString(@"comic_barrage")] forState:UIControlStateNormal];
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)previousButtonClick
|
||||
{
|
||||
if (self.comicChapterModel.last_chapter && self.comicChapterModel.last_chapter > 0) {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Switch_Chapter object:[TFUtilsHelper formatStringWithInteger:self.comicChapterModel.last_chapter]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)nextButtonClick
|
||||
{
|
||||
if (self.comicChapterModel.next_chapter && self.comicChapterModel.next_chapter > 0) {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Switch_Chapter object:[TFUtilsHelper formatStringWithInteger:self.comicChapterModel.next_chapter]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)settingButtonClick
|
||||
{
|
||||
[settingBar showSettingBar];
|
||||
}
|
||||
|
||||
- (void)barrageSwitchClick:(UIButton *)sender
|
||||
{
|
||||
if (sender.tag == 0) {
|
||||
sender.tag = 1;
|
||||
barrageSwitch.buttonImageName = @"comic_danmu_select";
|
||||
[[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:Enable_Barrage];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Switch_Barrage object:@"1"];
|
||||
[self changeComentInput:NO];
|
||||
} else {
|
||||
sender.tag = 0;
|
||||
barrageSwitch.buttonImageName = @"comic_danmu";
|
||||
[[NSUserDefaults standardUserDefaults] setObject:@"0" forKey:Enable_Barrage];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Switch_Barrage object:@"0"];
|
||||
[self changeComentInput:YES];
|
||||
}
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
}
|
||||
|
||||
- (void)shareButtonClick:(UIButton *)sender
|
||||
{
|
||||
[TFShareManager shareWithProduction_id:NSStringFromInteger(self.comicChapterModel.production_id) chapter_id:NSStringFromInteger(self.comicChapterModel.chapter_id) type:TFShareTypeComic];
|
||||
}
|
||||
|
||||
- (void)checkCommentsClick
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Push_To_Comments object:nil];
|
||||
}
|
||||
|
||||
- (void)scrollToTopClick
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Reader_Scroll_To_Top object:nil];
|
||||
}
|
||||
|
||||
- (void)downloadButtonClick
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Push_To_Comic_Download object:nil];
|
||||
}
|
||||
|
||||
- (void)collectionButtonClick:(UIButton *)sender
|
||||
{
|
||||
if ([[TFCollectionManager shareManagerWithProductionType:TFProductionTypeComic] isCollectedWithProduction_id:self.comicChapterModel.production_id]) {
|
||||
return;
|
||||
}
|
||||
WS(weakSelf)
|
||||
|
||||
[TFUtilsHelper synchronizationRackProductionWithProduction_id:self.comicChapterModel.production_id productionType:TFProductionTypeComic complete:nil];
|
||||
|
||||
if ([[TFCollectionManager shareManagerWithProductionType:TFProductionTypeComic] addCollectionWithProductionModel:weakSelf.productionModel]) {
|
||||
sender.hidden = YES;
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"已加入书架")];
|
||||
} else {
|
||||
sender.hidden = NO;
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:TFLocalizedString(@"加入书架失败")];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)sendCommentsClick
|
||||
{
|
||||
#if TF_Comments_Mode
|
||||
if (!TFUserInfoManager.isLogin) {
|
||||
[TFLoginOptionsViewController presentLoginView:nil];
|
||||
return;
|
||||
}
|
||||
|
||||
if (commentsTextView.text.length < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *t_text = commentsTextView.text;
|
||||
commentsTextView.text = @"";
|
||||
[[[UIApplication sharedApplication] keyWindow] endEditing:YES];
|
||||
|
||||
WS(weakSelf)
|
||||
if (!isCommentState) {
|
||||
[TFNetworkTools POST:Comic_Send_Barrage parameters:@{@"comic_id":[TFUtilsHelper formatStringWithInteger:self.comicChapterModel.production_id], @"chapter_id":[TFUtilsHelper formatStringWithInteger:self.comicChapterModel.chapter_id], @"content":t_text} model:nil success:^(BOOL isSuccess, NSDictionary * _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
SS(strongSelf)
|
||||
if (isSuccess) {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Change_Barrage object:t_text];
|
||||
strongSelf->commentsTextView.text = @"";
|
||||
strongSelf.frame = CGRectMake(0, SCREEN_HEIGHT - (PUB_TABBAR_HEIGHT + Comic_Menu_Bottom_Bar_Top_Height), SCREEN_WIDTH, PUB_TABBAR_HEIGHT + Comic_Menu_Bottom_Bar_Top_Height);
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"发射成功")];
|
||||
} else if (Compare_Json_isEqualTo(requestModel.code, 315)) {
|
||||
strongSelf->commentsTextView.text = @"";
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:requestModel.msg];
|
||||
} else if (requestModel.code == 319) {// 发送成功,但需要审核
|
||||
strongSelf->commentsTextView.text = @"";
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:requestModel.msg];
|
||||
} else {
|
||||
strongSelf->commentsTextView.text = t_text;
|
||||
[strongSelf->commentsTextView becomeFirstResponder];
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:requestModel.msg];
|
||||
}
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
SS(strongSelf)
|
||||
strongSelf->commentsTextView.text = t_text;
|
||||
}];
|
||||
} else {
|
||||
[TFNetworkTools POST:Comic_Comment_Post parameters:@{@"comic_id":[TFUtilsHelper formatStringWithInteger:self.comicChapterModel.production_id], @"content":t_text} model:nil success:^(BOOL isSuccess, NSDictionary * _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
SS(strongSelf)
|
||||
if (isSuccess) {
|
||||
strongSelf->commentsTextView.text = @"";
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"评论成功")];
|
||||
[badgeView increment];
|
||||
} else if (Compare_Json_isEqualTo(requestModel.code, 315)) {
|
||||
strongSelf->commentsTextView.text = @"";
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:requestModel.msg];
|
||||
} else if (requestModel.code == 318) {// 发送成功,但需要审核
|
||||
strongSelf->commentsTextView.text = @"";
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:requestModel.msg];
|
||||
} else {
|
||||
strongSelf->commentsTextView.text = t_text;
|
||||
[strongSelf->commentsTextView becomeFirstResponder];
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:requestModel.msg];
|
||||
}
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
SS(strongSelf)
|
||||
strongSelf->commentsTextView.text = t_text;
|
||||
}];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
|
||||
{
|
||||
UIView *view = [super hitTest:point withEvent:event];
|
||||
|
||||
if ([barrageSwitch pointInside:[barrageSwitch convertPoint:point fromView:self] withEvent:event]) {
|
||||
return barrageSwitch;
|
||||
}
|
||||
|
||||
if ([collectionButton pointInside:[collectionButton convertPoint:point fromView:self] withEvent:event]) {
|
||||
return collectionButton;
|
||||
}
|
||||
|
||||
if ([scrollToTop pointInside:[scrollToTop convertPoint:point fromView:self] withEvent:event]) {
|
||||
return scrollToTop;
|
||||
}
|
||||
|
||||
if ([view isKindOfClass:[self class]]) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
//当键盘出现或改变时调用
|
||||
- (void)keyboardWillShow:(NSNotification *)aNotification
|
||||
{
|
||||
//获取键盘的高度
|
||||
NSDictionary *userInfo = [aNotification userInfo];
|
||||
keyboardHeight = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size.height;
|
||||
self.frame = CGRectMake(0, SCREEN_HEIGHT - (PUB_TABBAR_HEIGHT + Comic_Menu_Bottom_Bar_Top_Height) - keyboardHeight + PUB_NAVBAR_OFFSET, SCREEN_WIDTH, PUB_TABBAR_HEIGHT + Comic_Menu_Bottom_Bar_Top_Height);
|
||||
}
|
||||
|
||||
//当键退出时调用
|
||||
- (void)keyboardWillHide:(NSNotification *)aNotification
|
||||
{
|
||||
keyboardHeight = PUB_TABBAR_HEIGHT + Comic_Menu_Bottom_Bar_Top_Height;
|
||||
self.frame = CGRectMake(0, SCREEN_HEIGHT - (PUB_TABBAR_HEIGHT + Comic_Menu_Bottom_Bar_Top_Height), SCREEN_WIDTH, PUB_TABBAR_HEIGHT + Comic_Menu_Bottom_Bar_Top_Height);
|
||||
}
|
||||
|
||||
- (void)textViewDidChange:(YYTextView *)textView
|
||||
{
|
||||
CGFloat textViewHeight = [TFViewHelper getDynamicHeightWithLabelFont:textView.font labelWidth:textView.width labelText:textView.text maxHeight:70] - kMargin;
|
||||
if (textViewHeight < 30) {
|
||||
textViewHeight = 30;
|
||||
}
|
||||
|
||||
#if TF_Comments_Mode
|
||||
[sendComments mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(textViewHeight);
|
||||
}];
|
||||
#endif
|
||||
if (is_iPhone6) {
|
||||
self.frame = CGRectMake(0, SCREEN_HEIGHT - keyboardHeight - PUB_TABBAR_HEIGHT + PUB_TABBAR_OFFSET - textViewHeight, SCREEN_WIDTH, PUB_TABBAR_HEIGHT + Comic_Menu_Bottom_Bar_Top_Height);
|
||||
} else {
|
||||
if (![textView.text isEqualToString:@""]) {
|
||||
self.frame = CGRectMake(0, SCREEN_HEIGHT - keyboardHeight - PUB_TABBAR_HEIGHT + PUB_TABBAR_OFFSET - textViewHeight - kMargin, SCREEN_WIDTH, PUB_TABBAR_HEIGHT + Comic_Menu_Bottom_Bar_Top_Height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
|
||||
{
|
||||
if ([text isEqualToString:@"\n"]) {
|
||||
[self sendCommentsClick];
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)setComicChapterModel:(TFProductionChapterModel *)comicChapterModel
|
||||
{
|
||||
_comicChapterModel = comicChapterModel;
|
||||
|
||||
#if TF_Comments_Mode
|
||||
[badgeView setCount:(int)comicChapterModel.total_comment];
|
||||
[badgeView showCount];
|
||||
#endif
|
||||
|
||||
if (comicChapterModel.next_chapter == 0) {
|
||||
[nextButton setTintColor:kGrayTextLightColor];
|
||||
nextButton.enabled = NO;
|
||||
} else {
|
||||
[nextButton setTintColor:kBlackColor];
|
||||
nextButton.enabled = YES;
|
||||
}
|
||||
|
||||
if (comicChapterModel.last_chapter == 0) {
|
||||
[previousButton setTintColor:kGrayTextLightColor];
|
||||
previousButton.enabled = NO;
|
||||
} else {
|
||||
[previousButton setTintColor:kBlackColor];
|
||||
previousButton.enabled = YES;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// TFComicBrowseBottomCell.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFComicBrowseBottomCell : TFBasicTableViewCell
|
||||
|
||||
@property (nonatomic ,strong) TFProductionChapterModel *comicChapterModel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
//
|
||||
// TFComicBrowseBottomCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFComicBrowseBottomCell.h"
|
||||
#import "TFComicBrowseBottomBar.h"
|
||||
|
||||
@interface TFComicBrowseBottomCell ()
|
||||
{
|
||||
TFButton *previousButton;
|
||||
TFButton *nextButton;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation TFComicBrowseBottomCell
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
previousButton = [[TFButton alloc] initWithFrame:CGRectZero buttonTitle:TFLocalizedString(@"上一篇") buttonImageName:@"public_back" buttonIndicator:TFButtonIndicatorTitleRight];
|
||||
previousButton.tag = 0;
|
||||
previousButton.buttonImageScale = 0.2;
|
||||
[previousButton addTarget:self action:@selector(changeChapter:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.contentView addSubview:previousButton];
|
||||
|
||||
[previousButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.contentView.mas_left).with.offset(kMargin);
|
||||
make.top.mas_equalTo(self.contentView.mas_top);
|
||||
make.width.mas_equalTo(self.contentView.mas_width).multipliedBy(0.5).with.offset(- kMargin);
|
||||
make.height.mas_equalTo(60);
|
||||
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(- (PUB_TABBAR_HEIGHT + Comic_Menu_Bottom_Bar_Top_Height)).priorityLow();
|
||||
}];
|
||||
|
||||
UIView *line = [[UIView alloc] init];
|
||||
line.backgroundColor = kGrayLineColor;
|
||||
[self.contentView addSubview:line];
|
||||
|
||||
[line mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(previousButton.mas_right);
|
||||
make.height.mas_equalTo(previousButton.mas_height).with.multipliedBy(0.8);
|
||||
make.width.mas_equalTo(kCellLineHeight);
|
||||
make.centerY.mas_equalTo(previousButton.mas_centerY);
|
||||
}];
|
||||
|
||||
nextButton = [[TFButton alloc] initWithFrame:CGRectZero buttonTitle:TFLocalizedString(@"下一篇") buttonImageName:@"public_back" buttonIndicator:TFButtonIndicatorTitleLeft];
|
||||
nextButton.transformImageView = YES;
|
||||
nextButton.tag = 1;
|
||||
nextButton.buttonImageScale = 0.2;
|
||||
[nextButton addTarget:self action:@selector(changeChapter:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.contentView addSubview:nextButton];
|
||||
|
||||
[nextButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
|
||||
make.top.mas_equalTo(self.contentView.mas_top);
|
||||
make.width.mas_equalTo(previousButton.mas_width);
|
||||
make.height.mas_equalTo(previousButton.mas_height);
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
- (void)setComicChapterModel:(TFProductionChapterModel *)comicChapterModel
|
||||
{
|
||||
_comicChapterModel = comicChapterModel;
|
||||
|
||||
if (comicChapterModel.last_chapter > 0) {
|
||||
previousButton.buttonTintColor = kBlackColor;
|
||||
} else {
|
||||
previousButton.buttonTintColor = kGrayTextLightColor;
|
||||
}
|
||||
|
||||
if (comicChapterModel.next_chapter > 0) {
|
||||
nextButton.buttonTintColor = kBlackColor;
|
||||
} else {
|
||||
nextButton.buttonTintColor = kGrayTextLightColor;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)changeChapter:(UIButton *)sender
|
||||
{
|
||||
if (sender.tag == 0) { // 上一篇
|
||||
if (self.comicChapterModel.last_chapter > 0) {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Switch_Chapter object:[TFUtilsHelper formatStringWithInteger:self.comicChapterModel.last_chapter]];
|
||||
} else {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:TFLocalizedString(@"已是第一篇")];
|
||||
}
|
||||
} else { // 下一篇
|
||||
if (self.comicChapterModel.next_chapter > 0) {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Switch_Chapter object:[TFUtilsHelper formatStringWithInteger:self.comicChapterModel.next_chapter]];
|
||||
} else {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:TFLocalizedString(@"已是最后一篇")];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// TFComicBrowseMenuView.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFComicBrowseMenuView : UIView
|
||||
|
||||
@property (nonatomic ,strong) TFProductionModel *productionModel;
|
||||
|
||||
@property (nonatomic ,strong) TFProductionChapterModel *comicChapterModel;
|
||||
|
||||
@property (nonatomic ,assign) BOOL isShowing;
|
||||
|
||||
interface_singleton
|
||||
|
||||
- (void)autoShowOrHiddenMenuView;
|
||||
|
||||
- (void)showMenuView;
|
||||
|
||||
- (void)hiddenMenuView;
|
||||
|
||||
- (void)startLoadingData;
|
||||
|
||||
- (void)stopLoadingData;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
//
|
||||
// TFComicBrowseMenuView.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFComicBrowseMenuView.h"
|
||||
#import "TFComicBrowseTopBar.h"
|
||||
#import "TFComicBrowseBottomBar.h"
|
||||
|
||||
@interface TFComicBrowseMenuView ()
|
||||
{
|
||||
TFComicBrowseTopBar *topBar;
|
||||
TFComicBrowseBottomBar *bottomBar;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation TFComicBrowseMenuView
|
||||
|
||||
implementation_singleton(TFComicBrowseMenuView)
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if (self = [super init]) {
|
||||
|
||||
[self initialize];
|
||||
|
||||
[self createSubViews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
self.userInteractionEnabled = YES;
|
||||
|
||||
self.isShowing = NO;
|
||||
}
|
||||
|
||||
- (void)createSubViews
|
||||
{
|
||||
topBar = [[TFComicBrowseTopBar alloc] init];
|
||||
[self addSubview:topBar];
|
||||
|
||||
bottomBar = [[TFComicBrowseBottomBar alloc] init];
|
||||
[self addSubview:bottomBar];
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
[self hiddenMenuView];
|
||||
}
|
||||
|
||||
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
|
||||
{
|
||||
UIView *touchView = [super hitTest:point withEvent:event];
|
||||
if (CGRectContainsPoint(topBar.bounds, point)) {
|
||||
if ([touchView isKindOfClass:[UIButton class]]) {
|
||||
return touchView;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
if ([touchView isDescendantOfView:bottomBar]) {
|
||||
return touchView;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)autoShowOrHiddenMenuView
|
||||
{
|
||||
if (!self.isShowing) {
|
||||
[self showMenuView];
|
||||
} else {
|
||||
[self hiddenMenuView];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showMenuView
|
||||
{
|
||||
[bottomBar reloadCollectionState];
|
||||
if (self.isShowing) {
|
||||
return;
|
||||
}
|
||||
self.isShowing = YES;
|
||||
[topBar showMenuTopBar];
|
||||
[bottomBar showMenuBottomBar];
|
||||
[TFViewHelper setStateBarDefaultStyle];
|
||||
[UIApplication sharedApplication].statusBarHidden = NO;
|
||||
}
|
||||
|
||||
- (void)hiddenMenuView
|
||||
{
|
||||
if (!self.isShowing) {
|
||||
return;
|
||||
}
|
||||
self.isShowing = NO;
|
||||
[topBar hiddenMenuTopBar];
|
||||
[bottomBar hiddenMenuBottomBar];
|
||||
[UIApplication sharedApplication].statusBarHidden = YES;
|
||||
}
|
||||
|
||||
- (void)startLoadingData
|
||||
{
|
||||
[bottomBar startLoadingData];
|
||||
}
|
||||
|
||||
- (void)stopLoadingData
|
||||
{
|
||||
[bottomBar stopLoadingData];
|
||||
}
|
||||
|
||||
- (void)setComicChapterModel:(TFProductionChapterModel *)comicChapterModel
|
||||
{
|
||||
_comicChapterModel = comicChapterModel;
|
||||
|
||||
if (comicChapterModel) {
|
||||
[topBar setNavTitle:comicChapterModel.chapter_title?:self.productionModel.name];
|
||||
bottomBar.comicChapterModel = comicChapterModel;
|
||||
} else {
|
||||
[topBar setNavTitle:@""];
|
||||
bottomBar.comicChapterModel = comicChapterModel;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void)setProductionModel:(TFProductionModel *)productionModel
|
||||
{
|
||||
if (_productionModel != productionModel) {
|
||||
_productionModel = productionModel;
|
||||
|
||||
bottomBar.productionModel = productionModel;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// TFComicBrowseSetBar.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFComicBrowseSetBar : UIView
|
||||
|
||||
- (void)showSettingBar;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+276
@@ -0,0 +1,276 @@
|
||||
//
|
||||
// TFComicBrowseSetBar.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFComicBrowseSetBar.h"
|
||||
#import "KLSwitch.h"
|
||||
#import "TFNightModeView.h"
|
||||
#import <AudioToolbox/AudioToolbox.h>
|
||||
|
||||
#define Menu_Setting_Cell_Height 70
|
||||
#define Menu_Setting_Bar_Height (2 * Menu_Setting_Cell_Height + PUB_NAVBAR_OFFSET)
|
||||
|
||||
@interface TFComicBrowseSetBar ()
|
||||
|
||||
@property (nonatomic ,strong) UIView *bottomView;
|
||||
@property (nonatomic ,strong) KLSwitch *clickPageSwitch;
|
||||
@property (nonatomic ,strong) KLSwitch *nightSwitch;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFComicBrowseSetBar
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if (self = [super init]) {
|
||||
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
self.backgroundColor = kBlackTransparentColor;
|
||||
self.hidden = YES;
|
||||
[kMainWindow addSubview:self];
|
||||
|
||||
NSUserDefaults *defualt = [NSUserDefaults standardUserDefaults];
|
||||
// 默认开启
|
||||
if (![defualt objectForKey:Enable_Click_Page]) {
|
||||
[defualt setObject:@"1" forKey:Enable_Click_Page];
|
||||
[defualt synchronize];
|
||||
}
|
||||
|
||||
// 默认关闭
|
||||
if (![defualt objectForKey:Enable_Click_Night]) {
|
||||
[defualt setObject:@"0" forKey:Enable_Click_Night];
|
||||
[defualt synchronize];
|
||||
}
|
||||
|
||||
// 默认开启
|
||||
if (![defualt objectForKey:Enable_Barrage]) {
|
||||
[defualt setObject:@"1" forKey:Enable_Barrage];
|
||||
[defualt synchronize];
|
||||
}
|
||||
|
||||
[self createSubViews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createSubViews
|
||||
{
|
||||
self.bottomView = [[UIView alloc] init];
|
||||
self.bottomView.backgroundColor = [UIColor whiteColor];
|
||||
[self addSubview:self.bottomView];
|
||||
|
||||
[self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(self.mas_bottom);
|
||||
make.width.mas_equalTo(self.mas_width);
|
||||
make.height.mas_equalTo(Menu_Setting_Bar_Height);
|
||||
}];
|
||||
|
||||
NSInteger cellIndex = 0;
|
||||
{
|
||||
UIView *cell = [[UIView alloc] init];
|
||||
cell.backgroundColor = [UIColor whiteColor];
|
||||
[self.bottomView addSubview:cell];
|
||||
|
||||
[cell mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(cellIndex * Menu_Setting_Cell_Height);
|
||||
make.width.mas_equalTo(self.bottomView.mas_width);
|
||||
make.height.mas_equalTo(Menu_Setting_Cell_Height);
|
||||
}];
|
||||
|
||||
self.clickPageSwitch = [[KLSwitch alloc] initWithFrame:CGRectMake(1, 1, 51, 31) didChangeHandler:^(BOOL isOn) {
|
||||
AudioServicesPlaySystemSound(1519);
|
||||
if (isOn) {
|
||||
[[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:Enable_Click_Page];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Enable_Click_Page object:@"1"];
|
||||
} else {
|
||||
[[NSUserDefaults standardUserDefaults] setObject:@"0" forKey:Enable_Click_Page];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Enable_Click_Page object:@"0"];
|
||||
}
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
}];
|
||||
self.clickPageSwitch.onTintColor = kMainColor;
|
||||
self.clickPageSwitch.transform = CGAffineTransformMakeScale(0.7, 0.7);//缩放
|
||||
[cell addSubview:self.clickPageSwitch];
|
||||
|
||||
if ([[[NSUserDefaults standardUserDefaults] objectForKey:Enable_Click_Page] isEqualToString:@"1"]) {
|
||||
[self.clickPageSwitch setDefaultOnState:YES];
|
||||
} else {
|
||||
[self.clickPageSwitch setDefaultOnState:NO];
|
||||
}
|
||||
|
||||
[self.clickPageSwitch mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.mas_equalTo(cell.mas_centerY);
|
||||
make.right.mas_equalTo(cell.mas_right).with.offset(- kHalfMargin);
|
||||
make.width.mas_equalTo(51);
|
||||
make.height.mas_equalTo(31);
|
||||
}];
|
||||
|
||||
UILabel *titleLabel = [[UILabel alloc] init];
|
||||
titleLabel.text = TFLocalizedString(@"点击翻页");
|
||||
titleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
titleLabel.textColor = kBlackColor;
|
||||
titleLabel.font = kMainFont;
|
||||
[cell addSubview:titleLabel];
|
||||
|
||||
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.mas_equalTo(cell.mas_centerY);
|
||||
make.left.mas_equalTo(kHalfMargin);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH / 2);
|
||||
make.height.mas_equalTo(20);
|
||||
}];
|
||||
|
||||
UILabel *subTitleLabel = [[UILabel alloc] init];
|
||||
subTitleLabel.numberOfLines = 2;
|
||||
subTitleLabel.preferredMaxLayoutWidth = SCREEN_WIDTH - kMargin - 51.0 - kQuarterMargin;
|
||||
subTitleLabel.text = TFLocalizedString(@"打开后可点击屏幕上下方翻页");
|
||||
subTitleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
subTitleLabel.textColor = kGrayTextColor;
|
||||
subTitleLabel.font = kFont12;
|
||||
[cell addSubview:subTitleLabel];
|
||||
|
||||
[subTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(titleLabel.mas_left);
|
||||
make.top.mas_equalTo(titleLabel.mas_bottom);
|
||||
make.right.equalTo(self.clickPageSwitch.mas_left).offset(-kQuarterMargin);
|
||||
make.height.mas_equalTo(subTitleLabel.intrinsicContentSize.height);
|
||||
}];
|
||||
|
||||
UIView *line = [[UIView alloc] init];
|
||||
line.backgroundColor = kGrayLineColor;
|
||||
[cell addSubview:line];
|
||||
|
||||
[line mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kMargin);
|
||||
make.height.mas_equalTo(kCellLineHeight);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH);
|
||||
make.bottom.mas_equalTo(cell.mas_bottom);
|
||||
}];
|
||||
|
||||
cellIndex ++;
|
||||
}
|
||||
|
||||
{
|
||||
UIView *cell = [[UIView alloc] init];
|
||||
cell.backgroundColor = [UIColor whiteColor];
|
||||
[self.bottomView addSubview:cell];
|
||||
|
||||
[cell mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(cellIndex * Menu_Setting_Cell_Height);
|
||||
make.width.mas_equalTo(self.bottomView.mas_width);
|
||||
make.height.mas_equalTo(Menu_Setting_Cell_Height);
|
||||
}];
|
||||
|
||||
self.nightSwitch = [[KLSwitch alloc] initWithFrame:CGRectMake(1, 1, 51, 31) didChangeHandler:^(BOOL isOn) {
|
||||
AudioServicesPlaySystemSound(1519);
|
||||
if (isOn) {
|
||||
[[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:Enable_Click_Night];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Enable_Click_Night object:@"1"];
|
||||
} else {
|
||||
[[NSUserDefaults standardUserDefaults] setObject:@"0" forKey:Enable_Click_Night];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Enable_Click_Night object:@"0"];
|
||||
}
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
}];
|
||||
self.nightSwitch.onTintColor = kMainColor;
|
||||
self.nightSwitch.transform = CGAffineTransformMakeScale(0.7, 0.7); // 缩放
|
||||
[cell addSubview:self.nightSwitch];
|
||||
|
||||
if ([[[NSUserDefaults standardUserDefaults] objectForKey:Enable_Click_Night] isEqualToString:@"1"]) {
|
||||
[self.nightSwitch setDefaultOnState:YES];
|
||||
} else {
|
||||
[self.nightSwitch setDefaultOnState:NO];
|
||||
}
|
||||
|
||||
[self.nightSwitch mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.mas_equalTo(cell.mas_centerY);
|
||||
make.right.mas_equalTo(cell.mas_right).with.offset(- kHalfMargin);
|
||||
make.width.mas_equalTo(51);
|
||||
make.height.mas_equalTo(31);
|
||||
}];
|
||||
|
||||
UILabel *titleLabel = [[UILabel alloc] init];
|
||||
titleLabel.text = TFLocalizedString(@"夜间模式");
|
||||
titleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
titleLabel.textColor = kBlackColor;
|
||||
titleLabel.font = kMainFont;
|
||||
[cell addSubview:titleLabel];
|
||||
|
||||
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.mas_equalTo(cell.mas_centerY);
|
||||
make.left.mas_equalTo(kHalfMargin);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH / 2);
|
||||
make.height.mas_equalTo(30);
|
||||
}];
|
||||
|
||||
cellIndex ++;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
UIView *touchView = [[touches anyObject] view];
|
||||
if (![touchView isEqual:self.bottomView]) {
|
||||
[self hiddenSettingBar];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showSettingBar
|
||||
{
|
||||
self.hidden = NO;
|
||||
|
||||
[UIView animateWithDuration:kAnimatedDuration animations:^{
|
||||
[self.bottomView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.mas_bottom).with.offset(- Menu_Setting_Bar_Height);
|
||||
}];
|
||||
}];
|
||||
|
||||
[UIView animateWithDuration:kAnimatedDuration animations:^{
|
||||
[self.bottomView.superview layoutIfNeeded];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)hiddenSettingBar
|
||||
{
|
||||
[self.bottomView.superview setNeedsUpdateConstraints];
|
||||
|
||||
[UIView animateWithDuration:kAnimatedDuration animations:^{
|
||||
[self.bottomView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.mas_bottom);
|
||||
}];
|
||||
}];
|
||||
|
||||
[UIView animateWithDuration:kAnimatedDuration animations:^{
|
||||
[self.bottomView.superview layoutIfNeeded];
|
||||
} completion:^(BOOL finished) {
|
||||
self.hidden = YES;
|
||||
}];
|
||||
}
|
||||
|
||||
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
|
||||
{
|
||||
UIView *view = [super hitTest:point withEvent:event];
|
||||
|
||||
if ([self.clickPageSwitch pointInside:[self.clickPageSwitch convertPoint:point fromView:self] withEvent:event]) {
|
||||
return self.clickPageSwitch;
|
||||
}
|
||||
|
||||
if ([self.nightSwitch pointInside:[self.nightSwitch convertPoint:point fromView:self] withEvent:event]) {
|
||||
return self.nightSwitch;
|
||||
}
|
||||
|
||||
if ([self.bottomView pointInside:[self.bottomView convertPoint:point fromView:self] withEvent:event]) {
|
||||
return self.bottomView;
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// TFComicBrowseTopBar.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFComicBrowseTopBar : UIView
|
||||
|
||||
- (void)showMenuTopBar;
|
||||
|
||||
- (void)hiddenMenuTopBar;
|
||||
|
||||
- (void)setNavTitle:(NSString *)titleString;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
//
|
||||
// TFComicBrowseTopBar.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFComicBrowseTopBar.h"
|
||||
|
||||
@interface TFComicBrowseTopBar ()
|
||||
{
|
||||
UILabel *navTitleLabel;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation TFComicBrowseTopBar
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if (self = [super init]) {
|
||||
self.frame = CGRectMake(0, - PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, PUB_NAVBAR_HEIGHT);
|
||||
[self createSubViews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createSubViews
|
||||
{
|
||||
self.backgroundColor = kWhiteColor;
|
||||
|
||||
// 默认左侧显示返回按钮
|
||||
UIButton *leftBackButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
leftBackButton.backgroundColor = [UIColor clearColor];
|
||||
[leftBackButton.titleLabel setFont:kMainFont];
|
||||
leftBackButton.adjustsImageWhenHighlighted = NO;
|
||||
[leftBackButton setImage:[[UIImage imageNamed:@"public_back"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
|
||||
[leftBackButton setImageEdgeInsets:UIEdgeInsetsMake(12, 6, 12, 18)];
|
||||
[leftBackButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
|
||||
[leftBackButton setTintColor:kBlackColor];
|
||||
[leftBackButton addTarget:self action:@selector(leftBack) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self addSubview:leftBackButton];
|
||||
|
||||
[leftBackButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kHalfMargin);
|
||||
make.bottom.mas_equalTo(self.bottom);
|
||||
make.width.mas_equalTo(44);
|
||||
make.height.mas_equalTo(44);
|
||||
}];
|
||||
|
||||
navTitleLabel = [[UILabel alloc] init];
|
||||
navTitleLabel.backgroundColor = [UIColor clearColor];
|
||||
navTitleLabel.textColor = [UIColor blackColor];
|
||||
navTitleLabel.numberOfLines = 1;
|
||||
navTitleLabel.font = kFont16;
|
||||
navTitleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
[self addSubview:navTitleLabel];
|
||||
|
||||
[navTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.mas_equalTo(leftBackButton.mas_centerY);
|
||||
make.height.mas_equalTo(20);
|
||||
make.left.equalTo(leftBackButton.mas_right).offset(kHalfMargin);
|
||||
}];
|
||||
|
||||
UIButton *completeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
completeButton.backgroundColor = [UIColor clearColor];
|
||||
completeButton.adjustsImageWhenHighlighted = NO;
|
||||
[completeButton setTitleColor:kMainColor forState:UIControlStateNormal];
|
||||
[completeButton setTitle:TFLocalizedString(@"全集") forState:UIControlStateNormal];
|
||||
[completeButton.titleLabel setFont:kMainFont];
|
||||
[completeButton addTarget:self action:@selector(completeButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self addSubview:completeButton];
|
||||
|
||||
[navTitleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.equalTo(completeButton.mas_left).offset(-kHalfMargin);
|
||||
}];
|
||||
|
||||
[completeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.mas_right).with.offset(- kHalfMargin);
|
||||
make.bottom.mas_equalTo(self.bottom);
|
||||
make.width.mas_equalTo(completeButton.intrinsicContentSize.width);
|
||||
make.height.mas_equalTo(44);
|
||||
}];
|
||||
|
||||
UIImageView *navBottomLine = [[UIImageView alloc] init];
|
||||
navBottomLine.userInteractionEnabled = YES;
|
||||
navBottomLine.image = [UIImage imageNamed:@"navbar_bottom_line"];
|
||||
[self addSubview:navBottomLine];
|
||||
|
||||
[navBottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(self.mas_bottom);
|
||||
make.width.mas_equalTo(self.mas_width);
|
||||
make.height.mas_equalTo(1);
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
- (void)showMenuTopBar
|
||||
{
|
||||
[UIView animateWithDuration:kAnimatedDurationFast animations:^{
|
||||
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, PUB_NAVBAR_HEIGHT);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)hiddenMenuTopBar
|
||||
{
|
||||
[UIView animateWithDuration:kAnimatedDurationFast animations:^{
|
||||
self.frame = CGRectMake(0, - PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, PUB_NAVBAR_HEIGHT);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setNavTitle:(NSString *)titleString
|
||||
{
|
||||
navTitleLabel.text = titleString?:@"";
|
||||
}
|
||||
|
||||
- (void)leftBack
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Pop_Comic_Reader object:nil];
|
||||
}
|
||||
|
||||
- (void)completeButtonClick
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Push_To_Directory object:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// TFComicBrowseViewCell.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFComicBrowseViewCell : TFBasicTableViewCell
|
||||
|
||||
@property (nonatomic ,strong) TFImageListModel *imageModel;
|
||||
|
||||
@property (nonatomic ,assign) NSInteger comic_id;
|
||||
|
||||
@property (nonatomic ,assign) NSInteger chapter_id;
|
||||
|
||||
@property (nonatomic ,assign) NSInteger chapter_update_time;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// TFComicBrowseViewCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFComicBrowseViewCell.h"
|
||||
#import "WXYZ_ComicDownloadManager.h"
|
||||
|
||||
@interface TFComicBrowseViewCell ()
|
||||
{
|
||||
UIImageView *chapterImageView;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation TFComicBrowseViewCell
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
chapterImageView = [[UIImageView alloc] init];
|
||||
chapterImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
[self.contentView addSubview:chapterImageView];
|
||||
|
||||
[chapterImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.contentView.mas_left);
|
||||
make.top.mas_equalTo(self.contentView.mas_top);
|
||||
make.width.mas_equalTo(self.contentView.mas_width);
|
||||
make.height.mas_equalTo(SCREEN_HEIGHT);
|
||||
make.bottom.mas_equalTo(self.contentView.mas_bottom).priorityLow();
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setImageModel:(TFImageListModel *)imageModel
|
||||
{
|
||||
_imageModel = imageModel;
|
||||
|
||||
[chapterImageView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(kGeometricHeight(SCREEN_WIDTH, imageModel.width <= 0?SCREEN_WIDTH:imageModel.width, imageModel.height <= 0?SCREEN_HEIGHT:imageModel.height));
|
||||
}];
|
||||
|
||||
// 查找内存中的图片缓存
|
||||
UIImage *cacheImage = [[YYImageCache sharedCache] getImageForKey:imageModel.image withType:YYImageCacheTypeMemory];
|
||||
|
||||
// 如果有则使用缓存加载图片
|
||||
if (cacheImage) {
|
||||
chapterImageView.image = cacheImage;
|
||||
} else { // 缓存中不存在,则从本地查找图片,获取本地图片后,也放置内存中,提高运行速度
|
||||
|
||||
// 查找沙盒中的文件
|
||||
UIImage *localImage = [[WXYZ_ComicDownloadManager sharedManager] getDownloadLocalImageWithProduction_id:self.comic_id chapter_id:self.chapter_id image_id:imageModel.image_id image_update_time:imageModel.image_update_time];
|
||||
if (localImage) {
|
||||
chapterImageView.image = localImage;
|
||||
|
||||
// 将沙盒中的文件存储到内存中
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
[[YYImageCache sharedCache] setImage:localImage imageData:nil forKey:imageModel.image withType:YYImageCacheTypeMemory];
|
||||
});
|
||||
|
||||
} else { // 沙盒中没有缓存图片
|
||||
|
||||
// 加载网络图片
|
||||
[chapterImageView setImageWithURL:[NSURL URLWithString:imageModel.image] placeholder:HoldImage options:YYWebImageOptionSetImageWithFadeAnimation completion:nil];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user