小说绘上架版本

This commit is contained in:
xtfei2011
2021-02-07 11:24:08 +08:00
commit ee5c1c8b12
1762 changed files with 115892 additions and 0 deletions
@@ -0,0 +1,36 @@
//
// TFMineHeaderView.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/11.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class TFUserCenterModel;
// 触摸头像
typedef void(^PortraitHandleBlock)(void);
// 触摸头像
typedef void(^GoldSelectedBlock)(void);
// 触摸头像
typedef void(^TaskSelectedBlock)(void);
// 触摸头像
typedef void(^VoucherSelectedBlock)(void);
@interface TFMineHeaderView : UIView
@property (nonatomic ,strong) UIImage *avatarImage;
@property (nonatomic ,copy) NSString *nickName;
@property (nonatomic ,strong) TFUserCenterModel *userModel;
@property (nonatomic ,copy) PortraitHandleBlock portraitHandleBlock;
@property (nonatomic ,copy) GoldSelectedBlock goldSelectedBlock;
@property (nonatomic ,copy) TaskSelectedBlock taskSelectedBlock;
@property (nonatomic ,copy) VoucherSelectedBlock voucherSelectedBlock;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,389 @@
//
// TFMineHeaderView.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/11.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFMineHeaderView.h"
#import "TFUserCenterModel.h"
#import "AppDelegate.h"
#define MenuAvatar_H 70
#define MenuNumLabel_H 30
#define MenuLabel_H 20
@interface TFMineHeaderView ()
@property (nonatomic ,strong) UIButton *userAvatar;
@property (nonatomic ,strong) UILabel *userNickname;
@property (nonatomic ,strong) UIImageView *vipView;
@property (nonatomic ,strong) UILabel *userIDLabel;
// 书币
@property (nonatomic ,strong) UILabel *goldNumLabel;
@property (nonatomic ,strong) UILabel *goldLabel;
// 书券
#if TF_Task_Mode
@property (nonatomic ,strong) UILabel *taskNumLabel;
@property (nonatomic ,strong) UILabel *taskLabel;
#endif
// 月票
@property (nonatomic ,strong) UILabel *voucherNumLabel;
@property (nonatomic ,strong) UILabel *voucherLabel;
@property (nonatomic ,strong) NSString *avatarString;
@end
@implementation TFMineHeaderView
- (instancetype)init
{
if (self = [super init]) {
self.backgroundColor = kWhiteColor;
#if TF_Recharge_Mode
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, 3 * kMargin + PUB_NAVBAR_OFFSET + MenuAvatar_H + MenuNumLabel_H + MenuLabel_H + kHalfMargin);
#else
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, 3 * kMargin + PUB_NAVBAR_OFFSET + MenuAvatar_H);
#endif
[self createSubViews];
}
return self;
}
- (void)createSubViews
{
self.userAvatar = [UIButton buttonWithType:UIButtonTypeCustom];
[self.userAvatar.layer setCornerRadius:35];
[self.userAvatar setClipsToBounds:YES];
[self.userAvatar setBackgroundImage:HoldUserAvatar forState:UIControlStateNormal];
[self.userAvatar addTarget:self action:@selector(avatarSelected) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:self.userAvatar];
[self.userAvatar mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.mas_left).with.offset(kMargin);
make.top.mas_equalTo(2 * kMargin + PUB_NAVBAR_OFFSET);
make.width.mas_equalTo(MenuAvatar_H);
make.height.mas_equalTo(MenuAvatar_H);
}];
self.userNickname = [[UILabel alloc] init];
self.userNickname.font = kBoldFont20;
self.userNickname.backgroundColor = kWhiteColor;
self.userNickname.textColor = kBlackColor;
self.userNickname.textAlignment = NSTextAlignmentLeft;
self.userNickname.userInteractionEnabled = YES;
if (TFUserInfoManager.isLogin) {
self.userNickname.text = [TFUserInfoManager shareInstance].nickname;
} else {
self.userNickname.text = TFLocalizedString(@"点我登录");
self.userNickname.textColor = kBlackColor;
}
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(avatarSelected)];
[self addSubview:self.userNickname];
[self.userNickname addGestureRecognizer:tap];
[self.userNickname mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.userAvatar.mas_right).with.offset(kHalfMargin);
make.width.mas_equalTo(SCREEN_WIDTH - 100);
make.top.mas_equalTo(self.userAvatar.mas_top);
make.height.mas_equalTo(MenuAvatar_H);
}];
self.userIDLabel = [[UILabel alloc] init];
self.userIDLabel.backgroundColor = kWhiteColor;
self.userIDLabel.textColor = kGrayTextColor;
self.userIDLabel.textAlignment = NSTextAlignmentLeft;
self.userIDLabel.font = kFont12;
[self addSubview:self.userIDLabel];
[self.userIDLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.userAvatar.mas_right).with.offset(kHalfMargin);
make.top.mas_equalTo(self.userAvatar.mas_centerY).with.offset(kQuarterMargin + 2);
make.width.mas_equalTo(CGFLOAT_MIN);
make.height.mas_equalTo(15);
}];
#if TF_Super_Member_Mode
self.vipView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"public_vip_normal"]];
self.vipView.hidden = YES;
[self addSubview:self.vipView];
[self.vipView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.userIDLabel.mas_right).with.offset(kQuarterMargin);
make.centerY.mas_equalTo(self.userIDLabel.mas_centerY);
make.height.mas_equalTo(10);
make.width.mas_equalTo(kGeometricWidth(10, 138, 48));
}];
#endif
#if TF_Recharge_Mode
self.goldNumLabel = [[UILabel alloc] init];
self.goldNumLabel.text = @"--";
self.goldNumLabel.textColor = kMainColor;
self.goldNumLabel.textAlignment = NSTextAlignmentCenter;
self.goldNumLabel.backgroundColor = kWhiteColor;
self.goldNumLabel.font = kMainFont;
self.goldNumLabel.userInteractionEnabled = YES;
[self addSubview:self.goldNumLabel];
[self.goldNumLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goldSelected)]];
{
UIView *line = [[UIView alloc] init];
line.backgroundColor = kGrayLineColor;
[self addSubview:line];
[line mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.goldNumLabel.mas_right);
make.top.mas_equalTo(self.goldNumLabel.mas_top).with.offset(5);
make.width.mas_equalTo(kCellLineHeight);
make.height.mas_equalTo(40);
}];
}
#if TF_Task_Mode
self.taskNumLabel = [[UILabel alloc] init];
self.taskNumLabel.text = @"--";
self.taskNumLabel.textColor = kMainColor;
self.taskNumLabel.textAlignment = NSTextAlignmentCenter;
self.taskNumLabel.backgroundColor = kWhiteColor;
self.taskNumLabel.font = kMainFont;
self.taskNumLabel.userInteractionEnabled = YES;
[self addSubview:self.taskNumLabel];
[self.taskNumLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(taskSelected)]];
{
UIView *line = [[UIView alloc] init];
line.backgroundColor = kGrayLineColor;
[self addSubview:line];
[line mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.taskNumLabel.mas_right);
make.top.mas_equalTo(self.taskNumLabel.mas_top).with.offset(5);
make.width.mas_equalTo(kCellLineHeight);
make.height.mas_equalTo(40);
}];
}
#endif
self.voucherNumLabel = [[UILabel alloc] init];
self.voucherNumLabel.text = @"--";
self.voucherNumLabel.textColor = kMainColor;
self.voucherNumLabel.textAlignment = NSTextAlignmentCenter;
self.voucherNumLabel.backgroundColor = kWhiteColor;
self.voucherNumLabel.font = kMainFont;
self.voucherNumLabel.userInteractionEnabled = YES;
[self addSubview:self.voucherNumLabel];
[self.voucherNumLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(voucherSelected)]];
AppDelegate *delegate = (AppDelegate *)kRCodeSync([UIApplication sharedApplication].delegate);
NSMutableArray *labelNumConstraints = [NSMutableArray arrayWithObjects:self.goldNumLabel,
#if TF_Task_Mode
self.taskNumLabel,
#endif
nil];
if (delegate.checkSettingModel.system_setting.monthly_ticket_switch == 1) {
[labelNumConstraints addObject:self.voucherNumLabel];
}
[labelNumConstraints mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing:0 leadSpacing:0 tailSpacing:0];
[labelNumConstraints mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.userAvatar.mas_bottom).with.offset(kMargin);
make.height.mas_equalTo(MenuNumLabel_H);
}];
self.goldLabel = [[UILabel alloc] init];
self.goldLabel.text = [NSString stringWithFormat:@"%@", TFSystemInfoManager.masterUnit];
self.goldLabel.textColor = kGrayTextColor;
self.goldLabel.textAlignment = NSTextAlignmentCenter;
self.goldLabel.backgroundColor = kWhiteColor;
self.goldLabel.font = kFont12;
self.goldLabel.userInteractionEnabled = YES;
[self addSubview:self.goldLabel];
[self.goldLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goldSelected)]];
#if TF_Task_Mode
self.taskLabel = [[UILabel alloc] init];
self.taskLabel.text = TFLocalizedString(@"书券");
self.taskLabel.textColor = kGrayTextColor;
self.taskLabel.textAlignment = NSTextAlignmentCenter;
self.taskLabel.backgroundColor = kWhiteColor;
self.taskLabel.font = kFont12;
self.taskLabel.userInteractionEnabled = YES;
[self addSubview:self.taskLabel];
[self.taskLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(taskSelected)]];
#endif
self.voucherLabel = [[UILabel alloc] init];
self.voucherLabel.text = TFLocalizedString(@"月票");
self.voucherLabel.textColor = kGrayTextColor;
self.voucherLabel.textAlignment = NSTextAlignmentCenter;
self.voucherLabel.backgroundColor = kWhiteColor;
self.voucherLabel.font = kFont12;
self.voucherLabel.userInteractionEnabled = YES;
[self addSubview:self.voucherLabel];
[self.voucherLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(voucherSelected)]];
NSMutableArray *labelConstraints = [NSMutableArray arrayWithObjects:self.goldLabel,
#if TF_Task_Mode
self.taskLabel,
#endif
nil];
if (delegate.checkSettingModel.system_setting.monthly_ticket_switch == 1) {
[labelConstraints addObject:self.voucherLabel];
}
[labelConstraints mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing:0 leadSpacing:0 tailSpacing:0];
[labelConstraints mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.goldNumLabel.mas_bottom);
make.height.mas_equalTo(MenuLabel_H);
}];
#endif
}
#pragma mark - 点击事件
- (void)avatarSelected
{
if (self.portraitHandleBlock) {
self.portraitHandleBlock();
}
}
- (void)goldSelected
{
if (self.goldSelectedBlock) {
self.goldSelectedBlock();
}
}
- (void)taskSelected
{
if (self.taskSelectedBlock) {
self.taskSelectedBlock();
}
}
- (void)voucherSelected
{
if (self.voucherSelectedBlock) {
self.voucherSelectedBlock();
}
}
#pragma mark - 设置变量
- (void)setAvatarImage:(UIImage *)avatarImage
{
_avatarImage = avatarImage;
[self.userAvatar setBackgroundImage:avatarImage forState:UIControlStateNormal];
}
- (void)setNickName:(NSString *)nickName
{
_nickName = nickName;
self.userNickname.text = nickName;
}
- (void)setUserModel:(TFUserCenterModel *)userModel
{
_userModel = userModel;
#if TF_Super_Member_Mode
// VIP
if (userModel.isVip) {
self.vipView.image = [UIImage imageNamed:@"public_vip_select"];
} else {
self.vipView.image = [UIImage imageNamed:@"public_vip_normal"];
}
#endif
// 昵称
if (userModel.nickname.length > 0) {
self.userNickname.text = userModel.nickname?:@"";
self.userNickname.textColor = kBlackColor;
self.userIDLabel.hidden = NO;
self.vipView.hidden = NO;
[self.userNickname mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(40);
}];
} else {
self.userNickname.text = TFLocalizedString(@"点我登录");
self.userNickname.textColor = kBlackColor;
self.userIDLabel.hidden = YES;
self.vipView.hidden = YES;
[self.userNickname mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(MenuAvatar_H);
}];
}
// 用户id
if (!userModel.uid) {
self.userIDLabel.hidden = YES;
self.userIDLabel.text = @"";
} else {
self.userIDLabel.hidden = NO;
self.userIDLabel.text = [NSString stringWithFormat:@"ID%@", [TFUtilsHelper formatStringWithInteger:userModel.uid]];
}
[self.userIDLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:self.userIDLabel]);
}];
// 主货币单位
if (userModel.masterUnit.length > 0) {
self.goldLabel.text = [NSString stringWithFormat:@"%@", userModel.masterUnit];
} else {
self.goldLabel.text = [NSString stringWithFormat:@"%@", TFSystemInfoManager.masterUnit];
}
#if TF_Task_Mode
// 子货币单位
if (userModel.subUnit.length > 0) {
self.taskLabel.text = [NSString stringWithFormat:@"%@", userModel.subUnit];
} else {
self.taskLabel.text = [NSString stringWithFormat:@"%@", TFSystemInfoManager.subUnit];
}
#endif
if (userModel.masterRemain <= 0 && !TFUserInfoManager.isLogin) {
self.goldNumLabel.text = @"--";
} else {
self.goldNumLabel.text = [TFUtilsHelper formatStringWithInteger:userModel.masterRemain];
}
// 月票数量
if (userModel.ticketRemain <= 0 && !TFUserInfoManager.isLogin) {
self.voucherNumLabel.text = @"--";
} else {
self.voucherNumLabel.text = [TFUtilsHelper formatStringWithInteger:userModel.ticketRemain];
}
#if TF_Task_Mode
// 子货币数量
if (userModel.subRemain <= 0 && !TFUserInfoManager.isLogin) {
self.taskNumLabel.text = @"--";
} else {
self.taskNumLabel.text = [TFUtilsHelper formatStringWithInteger:userModel.subRemain];
}
#endif
if (![self.avatarString isEqualToString:userModel.avatar]) {
self.avatarString = userModel.avatar;
[self.userAvatar setBackgroundImageWithURL:[NSURL URLWithString:userModel.avatar?:@""] forState:UIControlStateNormal placeholder:HoldUserAvatar];
}
}
@end
@@ -0,0 +1,20 @@
//
// TFMineTableViewCell.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/11.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class TFUserCenterListModel;
@interface TFMineTableViewCell : TFBasicTableViewCell
@property (nonatomic ,strong) TFUserCenterListModel *cellModel;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,114 @@
//
// TFMineTableViewCell.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/11.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFMineTableViewCell.h"
#import "TFUserCenterModel.h"
@interface TFMineTableViewCell ()
@property (nonatomic ,strong) UIImageView *iconView;
@property (nonatomic ,strong) UILabel *titleLabel;
@property (nonatomic ,strong) UILabel *subtitleLabel;
@property (nonatomic ,strong) UIImageView *connerView;
@end
@implementation TFMineTableViewCell
- (void)createSubviews
{
[super createSubviews];
[self setupSubview];
[self setupSubviewFrame];
}
- (void)setupSubview
{
self.iconView = [[UIImageView alloc] init];
self.iconView.image = HoldImage;
[self.contentView addSubview:self.iconView];
self.titleLabel = [[UILabel alloc] init];
self.titleLabel.backgroundColor = kWhiteColor;
self.titleLabel.textAlignment = NSTextAlignmentLeft;
self.titleLabel.textColor = kBlackColor;
self.titleLabel.font = kMainFont;
[self.contentView addSubview:self.titleLabel];
self.connerView = [[UIImageView alloc] init];
self.connerView.image = [UIImage imageNamed:@"public_more"];
[self.contentView addSubview:self.connerView];
self.subtitleLabel = [[UILabel alloc] init];
self.subtitleLabel.numberOfLines = 2;
self.subtitleLabel.textAlignment = NSTextAlignmentRight;
self.subtitleLabel.textColor = kGrayTextColor;
self.subtitleLabel.backgroundColor = kWhiteColor;
self.subtitleLabel.font = kFont12;
[self.contentView addSubview:self.subtitleLabel];
}
- (void)setupSubviewFrame
{
[self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(kHalfMargin + kQuarterMargin);
make.centerY.mas_equalTo(self.contentView.mas_centerY);
make.width.height.mas_equalTo(20);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.iconView.mas_right).with.offset(kHalfMargin + kQuarterMargin);
make.centerY.mas_equalTo(self.contentView.mas_centerY);
make.width.mas_equalTo(120);
make.height.mas_equalTo(kLabelHeight);
}];
[self.connerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
make.centerY.mas_equalTo(self.contentView.mas_centerY);
make.width.height.mas_equalTo(10);
}];
[self.subtitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.connerView.mas_left).with.offset(- kQuarterMargin);
make.centerY.mas_equalTo(self.contentView.mas_centerY);
make.left.equalTo(self.titleLabel.mas_right).offset(kQuarterMargin);
}];
}
- (void)setCellModel:(TFUserCenterListModel *)cellModel
{
if (_cellModel != cellModel) {
_cellModel = cellModel;
self.titleLabel.text = cellModel.title ? : @"";
[self.titleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:self.titleLabel]);
}];
self.subtitleLabel.text = cellModel.desc ? : @"";
self.titleLabel.textColor = [UIColor colorWithHexString:cellModel.title_color ? : @""];
self.subtitleLabel.textColor = [UIColor colorWithHexString:cellModel.desc_color ? : @""];
[self.iconView setImageWithURL:[NSURL URLWithString:cellModel.icon ? : @""] placeholder:HoldImage options:YYWebImageOptionSetImageWithFadeAnimation completion:nil];
self.connerView.hidden = !cellModel.enable;
}
}
@end