小说绘上架版本

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,18 @@
//
// TFMineViewController.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/11.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFBasicViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFMineViewController : TFBasicViewController
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,317 @@
//
// TFMineViewController.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/11.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFMineViewController.h"
#import "WXYZ_UserDataViewController.h"
#import "TFAppraiseViewController.h"
#import "TFFeedBackViewController.h"
#import "TFSetViewController.h"
#import "TFRecordsViewController.h"
#if TF_Task_Mode && TF_Super_Member_Mode && TF_Recharge_Mode
#import "TFTaskViewController.h"
#endif
#import "TFDownloadCacheViewController.h"
#import "TFRechargeViewController.h"
#import "TFAboutViewController.h"
#import "TFUpgradeMemberController.h"
#import "TFHistoricalRecordController.h"
#import "TFMineTableViewCell.h"
#import "TFMineHeaderView.h"
#import "TFUserCenterModel.h"
#import "TFCollectionManager.h"
#import "TFShareManager.h"
#import "TFMonthlyTicketViewController.h"
#import "TFRewardRecordViewController.h"
#import "TFWebViewController.h"
#import "TFLoginOptionsViewController.h"
@interface TFMineViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic ,strong) TFMineHeaderView *headerView;
@property (nonatomic ,strong) TFUserCenterModel *userModel;
@end
@implementation TFMineViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self initialize];
[self createSubviews];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self setStatusBarDefaultStyle];
[self netRequest];
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Show_Tabbar object:nil];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self setStatusBarDefaultStyle];
}
- (void)initialize
{
[self hiddenNavigationBar:YES];
self.view.backgroundColor = kGrayViewColor;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(avatarChanged:) name:Notification_Avatar_Changed object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(nicknameChnaged:) name:Notification_NickName_Changed object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pushToUserInfo) name:Notification_Push_UserInfo object:nil];
}
- (void)createSubviews
{
self.mainTableViewGroup.delegate = self;
self.mainTableViewGroup.dataSource = self;
[self.view addSubview:self.mainTableViewGroup];
[self.mainTableViewGroup mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(0);
make.top.mas_equalTo(0);
make.width.mas_equalTo(self.view.mas_width);
make.height.mas_equalTo(self.view.mas_height).with.offset(- PUB_TABBAR_HEIGHT);
}];
UIView *topCoverView = [[UIView alloc] init];
topCoverView.backgroundColor = kWhiteColor;
[self.view addSubview:topCoverView];
[topCoverView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.mas_equalTo(0);
make.width.mas_equalTo(self.view.mas_width);
make.height.mas_equalTo(is_iPhoneX?30:20);
}];
WS(weakSelf)
self.headerView = [[TFMineHeaderView alloc] init];
self.headerView.portraitHandleBlock = ^{
if (TFUserInfoManager.isLogin) {
[weakSelf.navigationController pushViewController:[[WXYZ_UserDataViewController alloc] init] animated:YES];
} else {
[TFLoginOptionsViewController presentLoginView:nil];
}
};
// 金币
#if TF_Records_Mode
self.headerView.goldSelectedBlock = ^{
TFRecordsViewController *vc = [[TFRecordsViewController alloc] init];
vc.pageIndex = 0;
[weakSelf.navigationController pushViewController:vc animated:YES];
};
#endif
#if TF_Task_Mode && TF_Super_Member_Mode && TF_Recharge_Mode
// 书券余额
self.headerView.taskSelectedBlock = ^{
TFRecordsViewController *vc = [[TFRecordsViewController alloc] init];
vc.pageIndex = 1;
[weakSelf.navigationController pushViewController:vc animated:YES];
};
#endif
#if TF_Records_Mode
// 月票余额
self.headerView.voucherSelectedBlock = ^{
[weakSelf.navigationController pushViewController:[[TFMonthlyTicketViewController alloc] init] animated:YES];
};
#endif
[self.mainTableViewGroup setTableHeaderView:self.headerView];
self.mainTableViewGroup.mj_header = [TFRefreshHeader headerWithRefreshingBlock:^{
[weakSelf netRequest];
}];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return self.userModel.panel_list.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.userModel.panel_list[section].count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
TFMineTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TFMineTableViewCell"];
if (!cell) {
cell = [[TFMineTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TFMineTableViewCell"];
}
cell.cellModel = self.userModel.panel_list[indexPath.section][indexPath.row];
cell.hiddenEndLine = (indexPath.row == self.userModel.panel_list[indexPath.section].count - 1);
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 50;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
TFMineTableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
// 充值
if ([cell.cellModel.action isEqualToString:@"recharge"] && cell.cellModel.enable) {
[self.navigationController pushViewController:[[TFRechargeViewController alloc] init] animated:YES];
}
// 包月
if ([cell.cellModel.action isEqualToString:@"vip"] && cell.cellModel.enable) {
[self.navigationController pushViewController:[[TFUpgradeMemberController alloc] init] animated:YES];
}
// 任务
if ([cell.cellModel.action isEqualToString:@"task"] && cell.cellModel.enable) {
[self.navigationController pushViewController:[[TFTaskViewController alloc] init] animated:YES];
}
if ([cell.cellModel.action isEqualToString:@"invite"] && cell.cellModel.enable) {
[self shareToFriend];
}
if ([cell.cellModel.action isEqualToString:@"history"] && cell.cellModel.enable) {
[self.navigationController pushViewController:[[TFHistoricalRecordController alloc] init] animated:YES];
}
if ([cell.cellModel.action isEqualToString:@"download"] && cell.cellModel.enable) {
[self.navigationController pushViewController:[[TFDownloadCacheViewController alloc] init] animated:YES];
}
// 我的书评
if ([cell.cellModel.action isEqualToString:@"comment"] && cell.cellModel.enable) {
[self.navigationController pushViewController:[[TFAppraiseViewController alloc] init] animated:YES];
}
// 联系客服
if ([cell.cellModel.action isEqualToString:@"service"] && cell.cellModel.enable) {
[self.navigationController pushViewController:[[TFAboutViewController alloc] init] animated:YES];
}
// 意见反馈
if ([cell.cellModel.action isEqualToString:@"feedback"] && cell.cellModel.enable) {
[self.navigationController pushViewController:[[TFFeedBackViewController alloc] init] animated:YES];
}
// 设置
if ([cell.cellModel.action isEqualToString:@"setting"] && cell.cellModel.enable) {
[self.navigationController pushViewController:[[TFSetViewController alloc] init] animated:YES];
}
// 打赏记录
if ([cell.cellModel.action isEqualToString:@"reward"] && cell.cellModel.enable) {
[self.navigationController pushViewController:[[TFRewardRecordViewController alloc] init] animated:YES];
}
// 成为作家
if ([cell.cellModel.action isEqualToString:@"url"] && cell.cellModel.enable) {
TFWebViewController *vc = [[TFWebViewController alloc] init];
vc.URLString = cell.cellModel.content;
vc.navTitle = TFLocalizedString(@"成为作家");
[self.navigationController pushViewController:vc animated:YES];
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if ([[self.userModel.panel_list objectOrNilAtIndex:section] count] == 0) {
return CGFLOAT_MIN;
}
return kHalfMargin;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, kHalfMargin)];
view.backgroundColor = kGrayViewColor;
return view;
}
//section底部间距
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
if (section == self.userModel.panel_list.count - 1) {
return kMargin;
}
return CGFLOAT_MIN;
}
//section底部视图
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, kMargin)];
view.backgroundColor = [UIColor clearColor];
return view;
}
- (void)avatarChanged:(NSNotification *)noti
{
if ([noti.object isKindOfClass:[UIImage class]]) {
self.headerView.avatarImage = noti.object;
}
}
- (void)nicknameChnaged:(NSNotification *)noti
{
self.headerView.nickName = noti.object;
}
- (void)pushToUserInfo
{
[self.navigationController pushViewController:[[WXYZ_UserDataViewController alloc] init] animated:YES];
}
- (void)shareToFriend
{
[TFShareManager shareApp];
}
- (void)netRequest
{
WS(weakSelf)
[TFNetworkTools POSTQuick:User_Center parameters:nil model:TFUserCenterModel.class success:^(BOOL isSuccess, TFUserCenterModel *_Nullable t_model, BOOL isCache, TFNetworkRequestModel *requestModel) {
[weakSelf.mainTableViewGroup endRefreshing];
if (isSuccess) {
TFSystemInfoManager.masterUnit = t_model.masterUnit;
TFSystemInfoManager.subUnit = t_model.subUnit;
weakSelf.userModel = t_model;
weakSelf.headerView.userModel = t_model;
[weakSelf.mainTableViewGroup reloadData];
if (!isCache) {
[TFUserInfoManager updateWithDict:requestModel.data];
}
} else {
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:requestModel.msg ?: @""];
if (requestModel.code == 302) {
[TFUserInfoManager logout];
[weakSelf netRequest];
}
}
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[weakSelf.mainTableViewGroup endRefreshing];
[TFPromptManager showPromptWithError:error defaultText:nil];
}];
}
@end
@@ -0,0 +1,69 @@
//
// TFUserCenterModel.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/11.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class TFUserCenterListModel;
/// 个人中心首页
@interface TFUserCenterModel : NSObject
@property (nonatomic ,copy) NSString *nickname;
@property (nonatomic ,copy) NSString *avatar;
@property (nonatomic ,copy) NSString *user_token;
/// 主货币单位
@property (nonatomic ,copy) NSString *masterUnit;
/// 主货币数量
@property (nonatomic ,assign) NSInteger masterRemain;
/// 子货币单位
@property (nonatomic ,copy) NSString *subUnit;
/// 子货币数量
@property (nonatomic ,assign) NSInteger subRemain;
/// 月票余额
@property (nonatomic ,assign) NSInteger ticketRemain;
@property (nonatomic ,assign ,getter = isVip) BOOL vip;
@property (nonatomic ,copy) NSString *mobile;
@property (nonatomic ,assign) NSInteger uid;
@property (nonatomic ,assign) NSInteger gender;
/// 列表信息
@property (nonatomic ,copy) NSArray<NSArray <TFUserCenterListModel *> *> *panel_list;
@end
/// 个人中心列表信息
@interface TFUserCenterListModel : NSObject
@property (nonatomic ,copy) NSString *title;
@property (nonatomic ,copy) NSString *desc;
/// 16进制颜色
@property (nonatomic ,copy) NSString *title_color;
/// 16进制颜色
@property (nonatomic ,copy) NSString *desc_color;
@property (nonatomic ,copy) NSString *icon;
/// 动作类型
@property (nonatomic ,copy) NSString *action;
@property (nonatomic ,copy) NSString *content;
/// 点击状态
@property (nonatomic ,assign ,getter = isEnable) BOOL enable;
@property (nonatomic ,assign) NSInteger group_id;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,48 @@
//
// TFUserCenterModel.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/11.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFUserCenterModel.h"
@implementation TFUserCenterModel
+ (NSDictionary<NSString *, id> *)modelCustomPropertyMapper
{
return @{
@"vip" : @"is_vip",
@"masterUnit" : @"unit",
@"masterRemain" : @"goldRemain",
@"subRemain" : @"silverRemain"
};
}
+ (instancetype)modelWithDictionary:(NSDictionary *)dictionary
{
TFUserCenterModel *t_model = [super modelWithDictionary:dictionary];
NSMutableArray<NSArray <TFUserCenterListModel *> *> *t_list = [NSMutableArray array];
for (NSArray *obj in t_model.panel_list) {
NSArray<TFUserCenterListModel *> *arr = [NSArray modelArrayWithClass:TFUserCenterListModel.class json:obj];
[t_list addObject:arr];
}
t_model.panel_list = t_list;
return t_model;
}
@end
@implementation TFUserCenterListModel
+ (NSDictionary<NSString *, id> *)modelCustomPropertyMapper
{
return @{
@"enable" : @"is_click"
};
}
@end
@@ -0,0 +1,38 @@
//
// TFUserDataModel.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/11.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class TFUserDataListModel;
// 用户资料首页数据
@interface TFUserDataModel : NSObject
@property (nonatomic ,copy) NSArray<NSArray <TFUserDataListModel *> *> *panel_list;
@end
@interface TFUserDataListModel : NSObject
@property (nonatomic ,copy) NSString *title;
@property (nonatomic ,copy) NSString *desc;
@property (nonatomic ,copy) NSString *title_color;
@property (nonatomic ,copy) NSString *desc_color;
@property (nonatomic ,copy) NSString *icon;
@property (nonatomic ,copy) NSString *action;
@property (nonatomic ,assign) BOOL is_click;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,31 @@
//
// TFUserDataModel.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/11.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFUserDataModel.h"
@implementation TFUserDataModel
+ (instancetype)modelWithDictionary:(NSDictionary *)dictionary
{
NSMutableArray<NSArray <TFUserDataListModel *> *> *t_list = [NSMutableArray array];
NSArray *t_arr = dictionary[@"panel_list"];
for (NSArray *obj in t_arr) {
NSArray<TFUserDataListModel *> *arr = [NSArray modelArrayWithClass:TFUserDataListModel.class json:obj];
[t_list addObject:arr];
}
TFUserDataModel *t_model = [[self alloc] init];
t_model.panel_list = [t_list copy];
return t_model;
}
@end
@implementation TFUserDataListModel
@end
@@ -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