小说绘上架版本
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TFGenderViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/14.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFGenderViewController : TFBasicViewController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,169 @@
|
||||
//
|
||||
// TFGenderViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/14.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFGenderViewController.h"
|
||||
#import "TFRecommendBookController.h"
|
||||
|
||||
@interface TFGenderViewController ()
|
||||
|
||||
@property (nonatomic ,strong) YYLabel *titleTop;
|
||||
@property (nonatomic ,strong) YYLabel *titleBottom;
|
||||
@property (nonatomic ,strong) UIButton *nextStepButton;
|
||||
@property (nonatomic ,strong) UIButton *boyButton;
|
||||
@property (nonatomic ,strong) UIButton *girlButton;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFGenderViewController
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
self.view.backgroundColor = kWhiteColor;
|
||||
|
||||
[self hiddenNavigationBar:YES];
|
||||
[self setupSubview];
|
||||
[self setupSubviewFrame];
|
||||
}
|
||||
|
||||
- (void)setupSubview
|
||||
{
|
||||
self.titleTop = [[YYLabel alloc] init];
|
||||
self.titleTop.text = TFLocalizedString(@"你终于来了");
|
||||
self.titleTop.textColor = kBlackColor;
|
||||
self.titleTop.textAlignment = NSTextAlignmentCenter;
|
||||
self.titleTop.textVerticalAlignment = YYTextVerticalAlignmentBottom;
|
||||
self.titleTop.font = kFont18;
|
||||
[self.view addSubview:self.titleTop];
|
||||
|
||||
|
||||
self.titleBottom = [[YYLabel alloc] init];
|
||||
self.titleBottom.text = TFLocalizedString(@"现在快选择你的性别吧");
|
||||
self.titleBottom.textColor = kGrayTextColor;
|
||||
self.titleBottom.textAlignment = NSTextAlignmentCenter;
|
||||
self.titleBottom.textVerticalAlignment = YYTextVerticalAlignmentTop;
|
||||
self.titleBottom.font = kMainFont;
|
||||
[self.view addSubview:self.titleBottom];
|
||||
|
||||
|
||||
self.boyButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[self.boyButton setAdjustsImageWhenHighlighted:NO];
|
||||
[self.boyButton setImage:[UIImage imageNamed:TFLocalizedString(@"insterest_boy_normal")] forState:UIControlStateNormal];
|
||||
[self.boyButton addTarget:self action:@selector(boyButtonClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.view addSubview:self.boyButton];
|
||||
|
||||
|
||||
self.girlButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[self.girlButton setAdjustsImageWhenHighlighted:NO];
|
||||
[self.girlButton setImage:[UIImage imageNamed:TFLocalizedString(@"insterest_girl_normal")] forState:UIControlStateNormal];
|
||||
[self.girlButton addTarget:self action:@selector(girlButtonClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.view addSubview:self.girlButton];
|
||||
|
||||
|
||||
self.nextStepButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[self.nextStepButton setBackgroundColor:kColorRGBA(218, 218, 218, 1)];
|
||||
[self.nextStepButton setTitleColor:kWhiteColor forState:UIControlStateNormal];
|
||||
[self.nextStepButton.layer setCornerRadius:20];
|
||||
[self.nextStepButton setUserInteractionEnabled:NO];
|
||||
[self.nextStepButton setTitle:TFLocalizedString(@"确定") forState:UIControlStateNormal];
|
||||
[self.nextStepButton addTarget:self action:@selector(nextStep) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.view addSubview:self.nextStepButton];
|
||||
}
|
||||
|
||||
- (void)setupSubviewFrame
|
||||
{
|
||||
[self.titleTop mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(PUB_NAVBAR_OFFSET);
|
||||
make.left.mas_equalTo(0);
|
||||
make.width.mas_equalTo(self.view.mas_width);
|
||||
make.height.mas_equalTo(65);
|
||||
}];
|
||||
|
||||
|
||||
[self.titleBottom mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.titleTop.mas_bottom).with.offset(kHalfMargin);
|
||||
make.left.mas_equalTo(0);
|
||||
make.width.mas_equalTo(self.view.mas_width);
|
||||
make.height.mas_equalTo(self.titleTop.mas_height);
|
||||
}];
|
||||
|
||||
|
||||
[self.boyButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kMargin);
|
||||
make.top.mas_equalTo(self.titleBottom.mas_bottom).with.offset(4 * kMargin);
|
||||
make.width.height.mas_equalTo((SCREEN_WIDTH - 2 * kMargin) / 2);
|
||||
}];
|
||||
|
||||
|
||||
[self.girlButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.view.mas_right).with.offset(- kMargin);
|
||||
make.top.mas_equalTo(self.titleBottom.mas_bottom).with.offset(4 * kMargin);
|
||||
make.width.height.mas_equalTo((SCREEN_WIDTH - 2 * kMargin) / 2);
|
||||
}];
|
||||
|
||||
|
||||
[self.nextStepButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.mas_equalTo(self.view.mas_bottom).with.offset(- PUB_NAVBAR_OFFSET - kMargin);
|
||||
make.left.mas_equalTo(2 * kMargin);
|
||||
make.width.mas_equalTo(self.view.mas_width).with.offset(- 4 * kMargin);
|
||||
make.height.mas_equalTo(40);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)nextStep
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Insterest_Change object:@"step_one"];
|
||||
}
|
||||
|
||||
- (void)boyButtonClick:(UIButton *)sender
|
||||
{
|
||||
sender.selected = YES;
|
||||
|
||||
[TFUserInfoManager shareInstance].gender = 2;
|
||||
|
||||
self.girlButton.selected = NO;
|
||||
self.nextStepButton.backgroundColor = kMainColor;
|
||||
self.nextStepButton.userInteractionEnabled = YES;
|
||||
|
||||
[self.girlButton setImage:[UIImage imageNamed:TFLocalizedString(@"insterest_girl_normal")] forState:UIControlStateNormal];
|
||||
[self.boyButton setImage:[UIImage imageNamed:TFLocalizedString(@"insterest_boy_select")] forState:UIControlStateNormal];
|
||||
|
||||
TFSystemInfoManager.sexChannel = 1;
|
||||
TFSystemInfoManager.firstGenderSelecte = @"1";
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Channel_Change object:nil];
|
||||
}
|
||||
|
||||
- (void)girlButtonClick:(UIButton *)sender
|
||||
{
|
||||
sender.selected = YES;
|
||||
|
||||
[TFUserInfoManager shareInstance].gender = 1;
|
||||
|
||||
self.boyButton.selected = NO;
|
||||
self.nextStepButton.backgroundColor = kMainColor;
|
||||
self.nextStepButton.userInteractionEnabled = YES;
|
||||
|
||||
[self.girlButton setImage:[UIImage imageNamed:TFLocalizedString(@"insterest_girl_select")] forState:UIControlStateNormal];
|
||||
[self.boyButton setImage:[UIImage imageNamed:TFLocalizedString(@"insterest_boy_normal")] forState:UIControlStateNormal];
|
||||
|
||||
TFSystemInfoManager.sexChannel = 2;
|
||||
TFSystemInfoManager.firstGenderSelecte = @"2";
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Channel_Change object:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TFInterimViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/14.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFInterimViewController : TFBasicViewController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,131 @@
|
||||
//
|
||||
// TFInterimViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/14.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFInterimViewController.h"
|
||||
#import "TFGenderViewController.h"
|
||||
#import "TFRecommendBookController.h"
|
||||
#import "TFRecommendBookModel.h"
|
||||
|
||||
@interface TFInterimViewController ()
|
||||
|
||||
@property (nonatomic ,strong) TFGenderViewController *insterestGender;
|
||||
@property (nonatomic ,strong) TFRecommendBookController *insterestBooks;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFInterimViewController
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[UIApplication sharedApplication].statusBarHidden = NO;
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self hiddenNavigationBar:YES];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(nextStepNotification:) name:Notification_Insterest_Change object:nil];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.insterestBooks = [[TFRecommendBookController alloc] init];
|
||||
[self addChildViewController:self.insterestBooks];
|
||||
[self.view addSubview:self.insterestBooks.view];
|
||||
|
||||
self.insterestGender = [[TFGenderViewController alloc] init];
|
||||
[self addChildViewController:self.insterestGender];
|
||||
[self.view addSubview:self.insterestGender.view];
|
||||
|
||||
UIButton *skipButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
skipButton.backgroundColor = [UIColor clearColor];
|
||||
[skipButton setTitle:TFLocalizedString(@"跳过") forState:UIControlStateNormal];
|
||||
[skipButton setTitleColor:kGrayTextColor forState:UIControlStateNormal];
|
||||
[skipButton.titleLabel setFont:kFont12];
|
||||
[skipButton addTarget:self action:@selector(skipButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.view addSubview:skipButton];
|
||||
|
||||
[skipButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.view.mas_right).with.offset(- kHalfMargin);
|
||||
make.top.mas_equalTo(kStatusBarHeight + kMargin);
|
||||
make.width.mas_equalTo(50);
|
||||
make.height.mas_equalTo(20);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)nextStepNotification:(NSNotification *)notification
|
||||
{
|
||||
if ([notification.object isEqualToString:@"step_one"]) {
|
||||
[self networkRequest];
|
||||
|
||||
} else if ([notification.object isEqualToString:@"step_two"]) {
|
||||
[self skipButtonClick];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)skipButtonClick
|
||||
{
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (void)networkRequest
|
||||
{
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
params[@"channel_id"] = @(TFSystemInfoManager.sexChannel);
|
||||
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:Start_Recommend parameters:params model:TFRecommendBookModel.class success:^(BOOL isSuccess, TFRecommendBookModel *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
|
||||
if (isSuccess) {
|
||||
NSMutableArray *t_arr = [NSMutableArray array];
|
||||
|
||||
for (TFProductionModel *model in t_model.book) {
|
||||
model.productionType = TFProductionTypeNovel;
|
||||
[t_arr addObject:model];
|
||||
}
|
||||
|
||||
for (TFProductionModel *model in t_model.comic) {
|
||||
model.productionType = TFProductionTypeComic;
|
||||
[t_arr addObject:model];
|
||||
}
|
||||
|
||||
for (TFProductionModel *model in t_model.audio) {
|
||||
model.productionType = TFProductionTypeAudio;
|
||||
[t_arr addObject:model];
|
||||
}
|
||||
|
||||
SS(strongSelf)
|
||||
if (t_arr.count == 0) {
|
||||
[weakSelf skipButtonClick];
|
||||
} else {
|
||||
[self.insterestGender willMoveToParentViewController:nil];
|
||||
[self.insterestGender removeFromParentViewController];
|
||||
[self.insterestGender.view removeFromSuperview];
|
||||
strongSelf.insterestBooks.productionArray = [t_arr copy];
|
||||
}
|
||||
} else {
|
||||
[weakSelf skipButtonClick];
|
||||
}
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[weakSelf skipButtonClick];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TFRecommendBookController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/14.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFRecommendBookController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,strong) NSArray *productionArray;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+290
@@ -0,0 +1,290 @@
|
||||
//
|
||||
// TFRecommendBookController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/14.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFRecommendBookController.h"
|
||||
#import "TFRecommendBookModel.h"
|
||||
#import "TFCollectionManager.h"
|
||||
#import "NSMutableArray+KVO.h"
|
||||
|
||||
@interface TFRecommendBookController ()
|
||||
|
||||
@property (nonatomic ,strong) YYLabel *titleTop;
|
||||
@property (nonatomic ,strong) YYLabel *titleBottom;
|
||||
|
||||
@property (nonatomic ,strong) UIScrollView *scrollView;
|
||||
@property (nonatomic ,strong) UIButton *nextStepButton;
|
||||
@property (nonatomic ,strong) NSMutableArray *addBookArray;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFRecommendBookController
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if (self = [super init]) {
|
||||
|
||||
self.view.backgroundColor = kWhiteColor;
|
||||
self.addBookArray = [NSMutableArray array];
|
||||
|
||||
[self setupSubview];
|
||||
[self setupSubviewFrame];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self hiddenNavigationBar:YES];
|
||||
}
|
||||
|
||||
- (void)setupSubview
|
||||
{
|
||||
self.titleTop = [[YYLabel alloc] init];
|
||||
self.titleTop.text = TFLocalizedString(@"独特的你");
|
||||
self.titleTop.textColor = kBlackColor;
|
||||
self.titleTop.textAlignment = NSTextAlignmentCenter;
|
||||
self.titleTop.textVerticalAlignment = YYTextVerticalAlignmentBottom;
|
||||
self.titleTop.font = kFont18;
|
||||
[self.view addSubview:self.titleTop];
|
||||
|
||||
self.titleBottom = [[YYLabel alloc] init];
|
||||
self.titleBottom.text = TFLocalizedString(@"请选择你感兴趣的书籍");
|
||||
self.titleBottom.textColor = kGrayTextColor;
|
||||
self.titleBottom.textAlignment = NSTextAlignmentCenter;
|
||||
self.titleBottom.textVerticalAlignment = YYTextVerticalAlignmentTop;
|
||||
self.titleBottom.font = kMainFont;
|
||||
[self.view addSubview:self.titleBottom];
|
||||
|
||||
self.nextStepButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[self.nextStepButton setBackgroundColor:kColorRGBA(218, 218, 218, 1)];
|
||||
[self.nextStepButton setTitleColor:kWhiteColor forState:UIControlStateNormal];
|
||||
[self.nextStepButton.layer setCornerRadius:20];
|
||||
[self.nextStepButton setUserInteractionEnabled:NO];
|
||||
[self.nextStepButton setTitle:TFLocalizedString(@"完成") forState:UIControlStateNormal];
|
||||
[self.nextStepButton addTarget:self action:@selector(nextStep) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.view addSubview:self.nextStepButton];
|
||||
|
||||
self.scrollView = [[UIScrollView alloc] init];
|
||||
[self.view addSubview:self.scrollView];
|
||||
}
|
||||
|
||||
- (void)setupSubviewFrame
|
||||
{
|
||||
[self.titleTop mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(PUB_NAVBAR_OFFSET);
|
||||
make.left.mas_equalTo(0);
|
||||
make.width.mas_equalTo(self.view.mas_width);
|
||||
make.height.mas_equalTo(65);
|
||||
}];
|
||||
|
||||
[self.titleBottom mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.titleTop.mas_bottom).with.offset(kHalfMargin);
|
||||
make.left.mas_equalTo(0);
|
||||
make.width.mas_equalTo(self.view.mas_width);
|
||||
make.height.mas_equalTo(self.titleTop.mas_height);
|
||||
}];
|
||||
|
||||
WS(weakSelf)
|
||||
self.addBookArray.changeBlock = ^(NSMutableArray * _Nonnull newVal) {
|
||||
SS(strongSelf)
|
||||
if (newVal.count <= 0) {
|
||||
strongSelf.nextStepButton.backgroundColor = kColorRGBA(218, 218, 218, 1);
|
||||
strongSelf.nextStepButton.userInteractionEnabled = NO;
|
||||
} else {
|
||||
strongSelf.nextStepButton.backgroundColor = kMainColor;
|
||||
strongSelf.nextStepButton.userInteractionEnabled = YES;
|
||||
}
|
||||
};
|
||||
|
||||
[self.nextStepButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.mas_equalTo(self.view.mas_bottom).with.offset(- PUB_NAVBAR_OFFSET - kMargin);
|
||||
make.left.mas_equalTo(2 * kMargin);
|
||||
make.width.mas_equalTo(self.view.mas_width).with.offset(- 4 * kMargin);
|
||||
make.height.mas_equalTo(40);
|
||||
}];
|
||||
|
||||
[self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH);
|
||||
make.top.mas_equalTo(self.titleBottom.mas_bottom);
|
||||
make.bottom.mas_equalTo(self.nextStepButton.mas_top).with.offset(- kMargin);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setProductionArray:(NSArray *)productionArray
|
||||
{
|
||||
_productionArray = productionArray;
|
||||
|
||||
if (productionArray.count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int buttonNum = 3; // 每行多少按钮
|
||||
CGFloat button_W = BOOK_WIDTH; // 按钮宽
|
||||
CGFloat button_H = BOOK_HEIGHT + BOOK_CELL_TITLE_HEIGHT + kQuarterMargin; // 按钮高
|
||||
CGFloat margin_X = kHalfMargin; // 第一个按钮的X坐标
|
||||
CGFloat margin_Y = 0; // 第一个按钮的Y坐标
|
||||
CGFloat space_X = kHalfMargin; // 按钮间距
|
||||
CGFloat space_Y = kMargin; // 行间距
|
||||
|
||||
[self.scrollView setContentSize:CGSizeMake(0, productionArray.count < 4 ? (button_H + space_Y) : 2 * (button_H + space_Y))];
|
||||
|
||||
for (int i = 0; i < (productionArray.count <= 6 ? productionArray.count : 6); i++) {
|
||||
int row = i / buttonNum; // 行号
|
||||
int loc = i % buttonNum; // 列号
|
||||
CGFloat button_X = margin_X + (space_X + button_W) * loc;
|
||||
CGFloat button_Y = margin_Y + (space_Y + button_H) * row;
|
||||
|
||||
TFProductionModel *t_model = [productionArray objectOrNilAtIndex:i];
|
||||
|
||||
UIButton *bottomButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
bottomButton.frame = CGRectMake(button_X, button_Y, button_W, button_H);
|
||||
bottomButton.tag = i;
|
||||
bottomButton.backgroundColor = [UIColor clearColor];
|
||||
[bottomButton addTarget:self action:@selector(bookButtonClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
bottomButton.selected = YES;
|
||||
[self.scrollView addSubview:bottomButton];
|
||||
|
||||
TFProductionCoverView *bookImageView = [[TFProductionCoverView alloc] initWithProductionType:t_model.productionType coverDirection:TFProductionCoverDirectionVertical];
|
||||
bookImageView.coverImageUrl = t_model.cover;
|
||||
bookImageView.userInteractionEnabled = NO;
|
||||
[bottomButton addSubview:bookImageView];
|
||||
|
||||
[bookImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(bottomButton.mas_centerX);
|
||||
make.top.mas_equalTo(bottomButton.mas_top);
|
||||
make.width.mas_equalTo(BOOK_WIDTH);
|
||||
make.height.mas_equalTo(BOOK_HEIGHT);
|
||||
}];
|
||||
|
||||
UILabel *connerLabel = [[UILabel alloc] init];
|
||||
connerLabel.font = kFont10;
|
||||
connerLabel.layer.cornerRadius = 4.0f;
|
||||
connerLabel.textAlignment = NSTextAlignmentCenter;
|
||||
connerLabel.textColor = kWhiteColor;
|
||||
connerLabel.clipsToBounds = YES;
|
||||
[bookImageView addSubview:connerLabel];
|
||||
|
||||
[connerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(bookImageView.mas_right).with.offset(- kQuarterMargin);
|
||||
make.top.mas_equalTo(bookImageView.mas_top).with.offset(kQuarterMargin);
|
||||
make.width.mas_equalTo(40);
|
||||
make.height.mas_equalTo(20);
|
||||
}];
|
||||
|
||||
if (t_model.productionType == TFProductionTypeNovel) {
|
||||
connerLabel.backgroundColor = kMainColor;
|
||||
connerLabel.text = TFLocalizedString(@"小说");
|
||||
}
|
||||
|
||||
if (t_model.productionType == TFProductionTypeComic) {
|
||||
connerLabel.backgroundColor = kRedColor;
|
||||
connerLabel.text = TFLocalizedString(@"漫画");
|
||||
}
|
||||
|
||||
if (t_model.productionType == TFProductionTypeAudio) {
|
||||
connerLabel.backgroundColor = [UIColor colorWithHexString:@"#56a0ef"];
|
||||
connerLabel.text = TFLocalizedString(@"听书");
|
||||
}
|
||||
|
||||
UILabel *titleLabel = [[UILabel alloc] init];
|
||||
titleLabel.numberOfLines = 2;
|
||||
titleLabel.text = t_model.name;
|
||||
titleLabel.backgroundColor = kWhiteColor;
|
||||
titleLabel.font = kMainFont;
|
||||
titleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
titleLabel.textColor = kBlackColor;
|
||||
[bottomButton addSubview:titleLabel];
|
||||
|
||||
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(bookImageView.mas_left);
|
||||
make.top.mas_equalTo(bookImageView.mas_bottom).with.offset(kQuarterMargin);
|
||||
make.width.mas_equalTo(bookImageView.mas_width);
|
||||
make.height.mas_equalTo(BOOK_CELL_TITLE_HEIGHT);
|
||||
}];
|
||||
|
||||
UIImageView *selectView = [[UIImageView alloc] init];
|
||||
selectView.userInteractionEnabled = YES;
|
||||
selectView.image = [UIImage imageNamed:@"audio_download_select"];
|
||||
[bottomButton addSubview:selectView];
|
||||
|
||||
[selectView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(bookImageView.mas_right).with.offset(- 5);
|
||||
make.bottom.mas_equalTo(bookImageView.mas_bottom).with.offset(- 5);
|
||||
make.height.width.mas_equalTo(18);
|
||||
}];
|
||||
}
|
||||
|
||||
[self.addBookArray KVO_addObjectsFromArray:productionArray];
|
||||
}
|
||||
|
||||
- (void)bookButtonClick:(UIButton *)sender
|
||||
{
|
||||
TFProductionModel *t_books = [self.productionArray objectOrNilAtIndex:sender.tag];
|
||||
if (sender.selected) {
|
||||
[sender.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
if ([obj isKindOfClass:[TFProductionCoverView class]]) {
|
||||
obj.alpha = 0.5;
|
||||
}
|
||||
|
||||
if ([obj isKindOfClass:[UIImageView class]]) {
|
||||
UIImageView *t_obj = (UIImageView *)obj;
|
||||
t_obj.image = [UIImage imageNamed:@"audio_download_unselect"];
|
||||
*stop = YES;
|
||||
}
|
||||
}];
|
||||
[self.addBookArray KVO_removeObject:t_books];
|
||||
|
||||
} else {
|
||||
[sender.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
if ([obj isKindOfClass:[TFProductionCoverView class]]) {
|
||||
obj.alpha = 1;
|
||||
}
|
||||
|
||||
if ([obj isKindOfClass:[UIImageView class]]) {
|
||||
UIImageView *t_obj = (UIImageView *)obj;
|
||||
t_obj.image = [UIImage imageNamed:@"audio_download_select"];
|
||||
*stop = YES;
|
||||
}
|
||||
}];
|
||||
[self.addBookArray KVO_addObject:t_books];
|
||||
}
|
||||
sender.selected = !sender.selected;
|
||||
}
|
||||
|
||||
- (void)nextStep
|
||||
{
|
||||
for (TFProductionModel *t_model in self.addBookArray) {
|
||||
switch (t_model.productionType) {
|
||||
case TFProductionTypeNovel:
|
||||
[[TFCollectionManager shareManagerWithProductionType:TFProductionTypeNovel] addCollectionWithProductionModel:t_model atIndex:0];
|
||||
break;
|
||||
case TFProductionTypeComic:
|
||||
[[TFCollectionManager shareManagerWithProductionType:TFProductionTypeComic] addCollectionWithProductionModel:t_model];
|
||||
break;
|
||||
case TFProductionTypeAudio:
|
||||
[[TFCollectionManager shareManagerWithProductionType:TFProductionTypeAudio] addCollectionWithProductionModel:t_model];
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Insterest_Change object:@"step_two"];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// TFRecommendBookModel.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/14.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFRecommendBookModel : NSObject
|
||||
|
||||
@property (nonatomic ,strong) NSArray <TFProductionModel *>*book;
|
||||
|
||||
@property (nonatomic ,strong) NSArray <TFProductionModel *>*comic;
|
||||
|
||||
@property (nonatomic ,strong) NSArray <TFProductionModel *>*audio;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// TFRecommendBookModel.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/14.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFRecommendBookModel.h"
|
||||
|
||||
@implementation TFRecommendBookModel
|
||||
|
||||
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass
|
||||
{
|
||||
return @{
|
||||
@"book" : [TFProductionModel class],
|
||||
@"comic" : [TFProductionModel class],
|
||||
@"audio": [TFProductionModel class]
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user