小说绘上架版本
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user