小说绘上架版本

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,19 @@
//
// TFGuideViewController.h
// WXReader
//
// Created by 谢腾飞 on 2020/12/3.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface TFGuideViewController : TFBasicViewController
@property (nonatomic ,copy) NSString *guideString;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,58 @@
//
// TFGuideViewController.m
// WXReader
//
// Created by 谢腾飞 on 2020/12/3.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFGuideViewController.h"
#import "YYTextView.h"
@interface TFGuideViewController ()
@property (nonatomic ,strong) YYTextView *rulesView;
@end
@implementation TFGuideViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self initialize];
[self createSubviews];
}
- (void)initialize
{
[self setNavigationBarTitle:TFLocalizedString(@"签到规则")];
self.view.backgroundColor = [UIColor whiteColor];
}
- (void)createSubviews
{
self.rulesView = [[YYTextView alloc] init];
self.rulesView.backgroundColor = kWhiteColor;
self.rulesView.editable = NO;
self.rulesView.selectable = NO;
self.rulesView.textColor = KGrayTextMiddleColor;
self.rulesView.font = kMainFont;
[self.view addSubview:self.rulesView];
[self.rulesView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT + kHalfMargin);
make.left.mas_equalTo(kHalfMargin);
make.width.mas_equalTo(SCREEN_WIDTH - kMargin);
make.height.mas_equalTo(SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT);
}];
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:self.guideString ? : @""];
text.lineSpacing = 8;
text.font = kMainFont;
text.color = KGrayTextMiddleColor;
self.rulesView.attributedText = text;
}
@end
@@ -0,0 +1,20 @@
//
// TFTaskViewController.h
// WXReader
//
// Created by 谢腾飞 on 2020/12/3.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface TFTaskViewController : TFBasicViewController
// 完成阅读作品任务
+ (void)taskReadRequestWithProduction_id:(NSInteger)production_id;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,284 @@
//
// TFTaskViewController.m
// WXReader
//
// Created by 谢腾飞 on 2020/12/3.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFTaskViewController.h"
#import "TFTaskTableViewCell.h"
#import "TFTaskHeaderView.h"
#import "WXYZ_TaskModel.h"
#import "TFShareManager.h"
// 充值
#import "TFRechargeViewController.h"
// 包月
#import "TFUpgradeMemberController.h"
#import "WXYZ_UserDataViewController.h"
#import "TFGuideViewController.h"
@interface TFTaskViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic ,strong) WXYZ_TaskModel *taskModel;
@property (nonatomic ,weak) TFTaskHeaderView *headerView;
@end
@implementation TFTaskViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self initialize];
[self createSubviews];
}
- (void)initialize
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(shareSuccess) name:Notification_Share_Success object:nil];
[self setNavigationBarTitle:TFLocalizedString(@"福利中心")];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self setStatusBarDefaultStyle];
}
- (void)createSubviews
{
UIButton *_rightBtn = nil;
WS(weakSelf)
[self setNavigationBarRightButton:({
UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
_rightBtn = rightBtn;
rightBtn.adjustsImageWhenHighlighted = NO;
[rightBtn setImage:[UIImage imageNamed:@"book_help"] forState:UIControlStateNormal];
[rightBtn addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) {
NSString *t_rules = [weakSelf.taskModel.sign_info.sign_rules componentsJoinedByString:@"\n"];
// if (t_rules.length > 0 && t_rules) {
TFGuideViewController *vc = [[TFGuideViewController alloc] init];
vc.guideString = t_rules;
[weakSelf.navigationController pushViewController:vc animated:YES];
// }
}]];
rightBtn;
})];
[_rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.navigationBar.navTitleLabel);
make.right.equalTo(self.view).offset(- kMoreHalfMargin);
make.height.width.mas_equalTo(19);
}];
self.mainTableView.delegate = self;
self.mainTableView.dataSource = self;
self.mainTableView.contentInset = UIEdgeInsetsMake(0, 0, PUB_TABBAR_OFFSET, 0);
[self.view addSubview:self.mainTableView];
[self.mainTableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(0);
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT);
make.width.mas_equalTo(SCREEN_WIDTH);
make.height.mas_equalTo(SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT);
}];
#if TF_Sign_Mode
TFTaskHeaderView *headerView = [[TFTaskHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 160)];
self.headerView = headerView;
headerView.signClickBlock = ^{
[weakSelf netRequest];
};
[self.mainTableView setTableHeaderView:headerView];
#endif
self.mainTableView.mj_header = [TFRefreshHeader headerWithRefreshingBlock:^{
[weakSelf netRequest];
}];
[self.mainTableView.mj_header beginRefreshing];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return self.taskModel.task_menu.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.taskModel.task_menu objectAtIndex:section].task_list.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
TFTaskTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TFTaskTableViewCell"];
if (!cell) {
cell = [[TFTaskTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TFTaskTableViewCell"];
}
WS(weakSelf)
cell.taskModel = [[self.taskModel.task_menu objectAtIndex:indexPath.section].task_list objectAtIndex:indexPath.row];
cell.taskClickBlock = ^(NSString * _Nonnull taskAction) {
if ([taskAction isEqualToString:@"share_app"]) {
[TFShareManager shareApp];
} else if ([taskAction isEqualToString:@"read_book"]) {
[self.navigationController popViewControllerAnimated:YES];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Change_Tabbar_Index object:@"1"];
});
} else if ([taskAction isEqualToString:@"comment_book"]) {
[self.navigationController popToRootViewControllerAnimated:YES];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Change_Tabbar_Index object:@"1"];
});
} else if ([taskAction isEqualToString:@"finish_info"]) {
[[TFViewHelper getCurrentNavigationController] pushViewController:[[WXYZ_UserDataViewController alloc] init] animated:YES];
} else if ([taskAction isEqualToString:@"add_book"]) {
[self.navigationController popToRootViewControllerAnimated:YES];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Change_Tabbar_Index object:@"1"];
});
} else if ([taskAction isEqualToString:@"recharge"]) {
[weakSelf.navigationController pushViewController:[[TFRechargeViewController alloc] init] animated:YES];
} else if ([taskAction isEqualToString:@"vip"]) {
[weakSelf.navigationController pushViewController:[[TFUpgradeMemberController alloc] init] animated:YES];
}
};
cell.hiddenEndLine = (indexPath.row == [self.taskModel.task_menu objectAtIndex:indexPath.section].task_list.count - 1);
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 40 + kMargin;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
if (section == self.taskModel.task_menu.count - 1) {
return PUB_TABBAR_OFFSET == 0 ? 10 : PUB_TABBAR_OFFSET;
}
return CGFLOAT_MIN;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, PUB_TABBAR_OFFSET == 0 ? 10 : PUB_TABBAR_OFFSET)];
view.backgroundColor = [UIColor clearColor];
return view;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 50;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 50)];
view.backgroundColor = kGrayViewColor;
UIView *titleLableBack = [[UIView alloc] init];
titleLableBack.backgroundColor = [UIColor whiteColor];
[view addSubview:titleLableBack];
[titleLableBack mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(0);
make.bottom.mas_equalTo(view.mas_bottom);
make.width.mas_equalTo(view.mas_width);
make.height.mas_equalTo(40);
}];
// 主标题
UILabel *mainTitleLabel = [[UILabel alloc] init];
mainTitleLabel.textAlignment = NSTextAlignmentLeft;
mainTitleLabel.textColor = kBlackColor;
mainTitleLabel.backgroundColor = kWhiteColor;
mainTitleLabel.text = [self.taskModel.task_menu objectAtIndex:section].task_title;
mainTitleLabel.font = kBoldFont15;
[view addSubview:mainTitleLabel];
[mainTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(kMargin + 4 + 5);
make.top.mas_equalTo(view.mas_top).with.offset(10);
make.width.mas_equalTo(view.mas_width).with.multipliedBy(0.5);
make.height.mas_equalTo(40);
}];
UIView *mainTitleHoldView = [[UIView alloc] init];
mainTitleHoldView.backgroundColor = kMainColor;
mainTitleHoldView.layer.cornerRadius = 3.0;
[view addSubview:mainTitleHoldView];
[mainTitleHoldView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(kMargin);
make.centerY.mas_equalTo(mainTitleLabel.mas_centerY);
make.width.mas_equalTo(4);
make.height.mas_equalTo(kLabelHeight * 2 - 2 * kMargin - 6);
}];
UIView *line = [[UIView alloc] init];
line.backgroundColor = kGrayLineColor;
[view addSubview:line];
[line mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(kMargin);
make.bottom.mas_equalTo(view.mas_bottom).with.offset( - kCellLineHeight);
make.width.mas_equalTo(SCREEN_WIDTH - kMargin);
make.height.mas_equalTo(kCellLineHeight);
}];
return view;
}
- (void)guideClick
{
NSString *t_rules = [self.taskModel.sign_info.sign_rules componentsJoinedByString:@"\n"];
if (t_rules.length > 0 && t_rules) {
TFGuideViewController *vc = [[TFGuideViewController alloc] init];
vc.guideString = t_rules;
[self.navigationController pushViewController:vc animated:YES];
}
}
- (void)netRequest
{
WS(weakSelf)
[TFNetworkTools POST:Task_Center parameters:nil model:WXYZ_TaskModel.class success:^(BOOL isSuccess, WXYZ_TaskModel *_Nullable t_model, TFNetworkRequestModel *requestModel) {
if (isSuccess) {
weakSelf.taskModel = t_model;
weakSelf.headerView.signInfoModel = self.taskModel.sign_info;
}
[weakSelf.mainTableView endRefreshing];
[weakSelf.mainTableView reloadData];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[weakSelf.mainTableView endRefreshing];
[weakSelf.mainTableView reloadData];
}];
}
// 完成阅读任务
+ (void)taskReadRequestWithProduction_id:(NSInteger)production_id
{
// 完成阅读任务
if (TFUserInfoManager.isLogin) {
if (![TFSystemInfoManager.taskReadProductionId isEqualToString:[TFUtilsHelper formatStringWithInteger:production_id]]) {
[TFNetworkTools POST:Task_Read parameters:nil model:nil success:^(BOOL isSuccess, NSDictionary *_Nullable t_model, TFNetworkRequestModel *requestModel) {
TFSystemInfoManager.taskReadProductionId = [TFUtilsHelper formatStringWithInteger:production_id];
} failure:nil];
}
}
}
- (void)shareSuccess
{
[self netRequest];
}
@end
@@ -0,0 +1,63 @@
//
// WXYZ_TaskModel.h
// WXReader
//
// Created by Andrew on 2018/11/15.
// Copyright © 2018 Andrew. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class WXYZ_TaskMenuModel, WXYZ_TaskListModel, WXYZ_SignInfoModel;
@interface WXYZ_TaskModel : NSObject
@property (nonatomic, strong) WXYZ_SignInfoModel *sign_info;
@property (nonatomic, strong) NSArray <WXYZ_TaskMenuModel *>*task_menu;
@end
@interface WXYZ_SignInfoModel : NSObject
@property (nonatomic, assign) NSInteger sign_status;
@property (nonatomic, strong) NSArray *sign_rules;
@property (nonatomic, copy) NSString *unit;
@property (nonatomic, assign) NSInteger max_award;
@property (nonatomic, assign) NSInteger sign_days;
@end
@interface WXYZ_TaskMenuModel : NSObject
@property (nonatomic, copy) NSString *task_title;
@property (nonatomic, strong) NSArray <WXYZ_TaskListModel *>*task_list;
@end
@interface WXYZ_TaskListModel : NSObject
@property (nonatomic, copy) NSString *task_award;
@property (nonatomic, copy) NSString *task_label;
@property (nonatomic, copy) NSString *task_desc;
@property (nonatomic, assign) NSInteger task_state;
@property (nonatomic, assign) NSInteger task_id;
@property (nonatomic, copy) NSString *task_action;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,38 @@
//
// WXYZ_TaskModel.m
// WXReader
//
// Created by Andrew on 2018/11/15.
// Copyright © 2018 Andrew. All rights reserved.
//
#import "WXYZ_TaskModel.h"
@implementation WXYZ_TaskModel
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass{
return @{@"task_menu" : [WXYZ_TaskMenuModel class]};
}
@end
@implementation WXYZ_SignInfoModel
@end
@implementation WXYZ_TaskMenuModel
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass{
return @{@"task_list" : [WXYZ_TaskListModel class]};
}
@end
@implementation WXYZ_TaskListModel
@end
@@ -0,0 +1,22 @@
//
// TFTaskHeaderView.h
// WXReader
//
// Created by 谢腾飞 on 2020/12/3.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class WXYZ_SignInfoModel;
typedef void(^SignClickBlock)(void);
@interface TFTaskHeaderView : UIView
@property (nonatomic ,strong) WXYZ_SignInfoModel *signInfoModel;
@property (nonatomic ,copy) SignClickBlock signClickBlock;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,167 @@
//
// TFTaskHeaderView.m
// WXReader
//
// Created by 谢腾飞 on 2020/12/3.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFTaskHeaderView.h"
#import "WXYZ_TaskModel.h"
#import "TFSignModel.h"
#import "TFSignAlertView.h"
@interface TFTaskHeaderView ()
@property (nonatomic ,strong) UILabel *signLabel;
@property (nonatomic ,strong) UIButton *signBtn;
@property (nonatomic ,strong) UILabel *promptLabel;
@end
@implementation TFTaskHeaderView
- (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
self.backgroundColor = [UIColor whiteColor];
[self createSubviews];
}
return self;
}
- (void)createSubviews
{
NSMutableAttributedString *t_atr = [[NSMutableAttributedString alloc] initWithString:TFLocalizedString(@"您已连续签到") attributes:@{NSFontAttributeName : kBoldFont19, NSForegroundColorAttributeName : kBlackColor}];
t_atr.lineSpacing = kQuarterMargin;
UIImageView *signImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kGeometricWidth(50, 196, 276), 50.0)];
signImageView.backgroundColor = kMainColor;
signImageView.layer.cornerRadius = 8.5;
signImageView.layer.masksToBounds = YES;
self.signLabel = [[UILabel alloc] init];
self.signLabel.text = @"0";
self.signLabel.backgroundColor = [UIColor clearColor];
self.signLabel.font = kBoldFont27;
self.signLabel.textColor = kWhiteColor;
[signImageView addSubview:self.signLabel];
[self.signLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(signImageView);
}];
NSMutableAttributedString *attributeView = [NSMutableAttributedString attachmentStringWithContent:signImageView contentMode:UIViewContentModeBottom attachmentSize:CGSizeMake(kGeometricWidth(50, 196, 276) + 10, 50.0) alignToFont : kBoldFont19 alignment:YYTextVerticalAlignmentCenter];
[t_atr appendAttributedString:attributeView];
[t_atr appendAttributedString:[[NSAttributedString alloc] initWithString:TFLocalizedString(@"") attributes:@{NSFontAttributeName : kBoldFont19, NSForegroundColorAttributeName : kBlackColor}]];
YYLabel *signLabel = [[YYLabel alloc] init];
signLabel.backgroundColor = [UIColor clearColor];
signLabel.numberOfLines = 0;
signLabel.preferredMaxLayoutWidth = SCREEN_WIDTH - 120.0 - kMargin;
signLabel.attributedText = t_atr;
[self addSubview:signLabel];
[signLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self).offset(kMargin);
make.centerY.equalTo(self);
make.width.mas_equalTo(signLabel.preferredMaxLayoutWidth);
}];
self.signBtn = [UIButton buttonWithType:UIButtonTypeCustom];
self.signBtn.userInteractionEnabled = NO;
[self.signBtn setImage:[UIImage imageNamed:TFLocalizedString(@"task_unsign")] forState:UIControlStateNormal];
[self.signBtn addTarget:self action:@selector(signClick) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:self.signBtn];
[self.signBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.mas_right);
make.centerY.mas_equalTo(self.mas_centerY);
make.width.height.mas_equalTo(120);
}];
self.promptLabel = [[UILabel alloc] init];
self.promptLabel.font = kFont10;
self.promptLabel.textColor = kGrayTextLightColor;
self.promptLabel.textAlignment = NSTextAlignmentLeft;
[self addSubview:self.promptLabel];
[self.promptLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(signLabel.mas_left);
make.bottom.mas_equalTo(self.mas_bottom).with.offset(- kHalfMargin);
make.width.mas_equalTo(self.mas_width);
make.height.mas_equalTo(20);
}];
}
- (void)setSignInfoModel:(WXYZ_SignInfoModel *)signInfoModel
{
_signInfoModel = signInfoModel;
if (signInfoModel.sign_status == 0) {
[self.signBtn setImage:[UIImage imageNamed:TFLocalizedString(@"task_unsign")] forState:UIControlStateNormal];
self.signBtn.userInteractionEnabled = YES;
} else {
[self.signBtn setImage:[UIImage imageNamed:TFLocalizedString(@"task_signed")] forState:UIControlStateNormal];
self.signBtn.userInteractionEnabled = NO;
}
self.signLabel.text = [TFUtilsHelper formatStringWithInteger:signInfoModel.sign_days];
NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@%@%@%@", TFLocalizedString(@"提示:"), TFLocalizedString(@"连续签到最高可获得"), [TFUtilsHelper formatStringWithInteger:signInfoModel.max_award], signInfoModel.unit?:TFSystemInfoManager.masterUnit]];
NSString *suffix = [NSString stringWithFormat:@"%@%@", [TFUtilsHelper formatStringWithInteger:signInfoModel.max_award], signInfoModel.unit?:TFSystemInfoManager.masterUnit];
[attributedStr addAttribute:NSForegroundColorAttributeName value:kColorRGBA(251, 100, 26, 1) range:NSMakeRange(attributedStr.length - suffix.length, suffix.length)];
self.promptLabel.attributedText = attributedStr;
}
- (void)signClick
{
if (!TFUserInfoManager.isLogin) {
[TFLoginOptionsViewController presentLoginView:nil];
return;
}
WS(weakSelf)
[TFNetworkTools POST:Sign_Click parameters:nil model:TFSignModel.class success:^(BOOL isSuccess, TFSignModel *_Nullable t_model, TFNetworkRequestModel *requestModel) {
if (isSuccess) {
if ((t_model.book.count > 0 || t_model.comic.count > 0) && t_model.award.length > 0 && t_model.tomorrow_award.length > 0) {
NSMutableArray *t_arr = [NSMutableArray array];
for (TFProductionModel *t in t_model.book) {
t.productionType = TFProductionTypeNovel;
[t_arr addObject:t];
}
for (TFProductionModel *t in t_model.comic) {
t.productionType = TFProductionTypeComic;
[t_arr addObject:t];
}
for (TFProductionModel *t in t_model.audio) {
t.productionType = TFProductionTypeAudio;
[t_arr addObject:t];
}
TFSignAlertView *alert = [[TFSignAlertView alloc] init];
alert.alertTitle = t_model.award;
alert.alertDetailContent = t_model.tomorrow_award;
alert.bookList = [t_arr copy];
[alert showAlertView];
}
!weakSelf.signClickBlock ?: weakSelf.signClickBlock();
} else {
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:requestModel.msg];
}
} failure:nil];
}
@end
@@ -0,0 +1,23 @@
//
// TFTaskTableViewCell.h
// WXReader
//
// Created by 谢腾飞 on 2020/12/3.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class WXYZ_TaskListModel;
typedef void(^TaskClickBlock)(NSString *taskAction);
@interface TFTaskTableViewCell : TFBasicTableViewCell
@property (nonatomic ,strong) WXYZ_TaskListModel *taskModel;
@property (nonatomic ,copy) TaskClickBlock taskClickBlock;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,135 @@
//
// TFTaskTableViewCell.m
// WXReader
//
// Created by 谢腾飞 on 2020/12/3.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFTaskTableViewCell.h"
#import "WXYZ_TaskModel.h"
@interface TFTaskTableViewCell ()
{
UILabel *taskLabel;
UILabel *taskDescLabel;
UILabel *taskAward;
UIButton *taskStateButton;
}
@end
@implementation TFTaskTableViewCell
- (void)createSubviews
{
[super createSubviews];
taskLabel = [[UILabel alloc] init];
taskLabel.font = kMainFont;
taskLabel.textAlignment = NSTextAlignmentLeft;
taskLabel.textColor = kBlackColor;
[self.contentView addSubview:taskLabel];
[taskLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(kMargin);
make.top.mas_equalTo(kHalfMargin);
make.width.mas_equalTo(SCREEN_WIDTH / 2);
make.height.mas_equalTo(20);
}];
taskDescLabel = [[UILabel alloc] init];
taskDescLabel.textColor = kGrayTextColor;
taskDescLabel.textAlignment = NSTextAlignmentLeft;
taskDescLabel.font = kFont11;
[self.contentView addSubview:taskDescLabel];
[taskDescLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(taskLabel.mas_left);
make.top.mas_equalTo(taskLabel.mas_bottom);
make.height.mas_equalTo(taskLabel.mas_height);
}];
taskAward = [[UILabel alloc] init];
taskAward.textColor = kColorRGBA(251, 100, 26, 1);
taskAward.textAlignment = NSTextAlignmentLeft;
taskAward.font = kFont10;
[self.contentView addSubview:taskAward];
[taskAward mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(taskLabel.mas_right);
make.centerY.mas_equalTo(taskLabel.mas_centerY);
make.height.mas_equalTo(taskLabel.mas_height);
make.right.equalTo(taskDescLabel);
}];
taskStateButton = [UIButton buttonWithType:UIButtonTypeCustom];
taskStateButton.backgroundColor = kColorRGBA(251, 100, 26, 1);
taskStateButton.layer.cornerRadius = 10;
taskStateButton.clipsToBounds = YES;
[taskStateButton setTitle:TFLocalizedString(@"去完成") forState:UIControlStateNormal];
[taskStateButton setTitleColor:kWhiteColor forState:UIControlStateNormal];
[taskStateButton.titleLabel setFont:kFont10];
[taskStateButton addTarget:self action:@selector(taskClick) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:taskStateButton];
[taskStateButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
make.centerY.mas_equalTo(self.contentView.mas_centerY);
make.height.mas_equalTo(20);
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabelFont:kFont10 labelHeight:20.0 labelText:taskStateButton.titleLabel.text] + kHalfMargin);
}];
[taskDescLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(taskStateButton.mas_left).offset(-kHalfMargin);
}];
}
- (void)setTaskModel:(WXYZ_TaskListModel *)taskModel
{
_taskModel = taskModel;
if (taskModel) {
taskLabel.text = taskModel.task_label;
[taskLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabelFont:kMainFont labelHeight:20 labelText:taskModel.task_label]);
}];
taskDescLabel.text = taskModel.task_desc;
taskAward.text = taskModel.task_award;
if (taskModel.task_state == 0) {
[taskStateButton setTitle:TFLocalizedString(@"去完成") forState:UIControlStateNormal];
taskStateButton.backgroundColor = kColorRGBA(251, 100, 26, 1);
[taskStateButton mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabelFont:kFont10 labelHeight:20.0 labelText:taskStateButton.titleLabel.text] + kHalfMargin);
}];
} else {
[taskStateButton setTitle:TFLocalizedString(@"已完成") forState:UIControlStateNormal];
taskStateButton.backgroundColor = kColorRGBA(213, 216, 217, 1);
[taskStateButton mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabelFont:kFont10 labelHeight:20.0 labelText:taskStateButton.titleLabel.text] + kHalfMargin);
}];
}
} else {
}
}
- (void)taskClick
{
if (_taskModel.task_state == 1) {
return;
}
if (!TFUserInfoManager.isLogin && ![_taskModel.task_action isEqualToString:@"recharge"] && ![_taskModel.task_action isEqualToString:@"vip"]) {
[TFLoginOptionsViewController presentLoginView:nil];
return;
}
if (self.taskClickBlock) {
self.taskClickBlock(_taskModel.task_action);
}
}
@end