小说绘上架版本

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,20 @@
//
// TFMemberInstructionsViewCell.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFBasicTableViewCell.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFMemberInstructionsViewCell : TFBasicTableViewCell
@property (nonatomic ,strong) NSArray<NSString *> *about;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,97 @@
//
// TFMemberInstructionsViewCell.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFMemberInstructionsViewCell.h"
#import "TFWebViewController.h"
#import "WXYZ_FeedbackSubViewController.h"
#import "AppDelegate.h"
@interface TFMemberInstructionsViewCell ()
{
YYTextView *aboutTextView;
}
@end
@implementation TFMemberInstructionsViewCell
- (void)createSubviews
{
[super createSubviews];
aboutTextView = [[YYTextView alloc] init];
aboutTextView.backgroundColor = [UIColor whiteColor];
aboutTextView.editable = NO;
aboutTextView.scrollEnabled = NO;
aboutTextView.selectable = NO;
[self.contentView addSubview:aboutTextView];
[aboutTextView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.contentView.mas_left).with.offset(kHalfMargin);
make.top.mas_equalTo(self.contentView.mas_top);
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kHalfMargin);
make.height.mas_equalTo(10);
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(- kHalfMargin).priorityLow();
}];
}
- (void)setAbout:(NSArray<NSString *> *)about
{
_about = about;
if (about.count > 0 && ![[about firstObject] isEqualToString:@""]) {
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] init];
for (NSString *t_str in about) {
[str appendString:[t_str stringByAppendingString:@"\n\n"]];
}
[str setColor:kGrayTextColor];
[str setFont:kFont12];
[str setTextHighlightRange:[str.string localizedStandardRangeOfString:TFLocalizedString(@"《用户协议》")] color:kMainColor backgroundColor:[UIColor whiteColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
TFWebViewController *vc = [[TFWebViewController alloc] init];
vc.navTitle = TFLocalizedString(@"用户协议");
AppDelegate *delegate = (AppDelegate *)kRCodeSync([UIApplication sharedApplication].delegate);
vc.URLString = delegate.checkSettingModel.protocol_list.user ?: [NSString stringWithFormat:@"%@%@?language=%@", APIURL, User_Agreement, TFLanguageManager.serverLocalized];
vc.isPresentState = NO;
[[TFViewHelper getCurrentNavigationController] pushViewController:vc animated:YES];
}];
[str setTextHighlightRange:[str.string localizedStandardRangeOfString:TFLocalizedString(@"《隐私协议》")] color:kMainColor backgroundColor:[UIColor whiteColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
TFWebViewController *vc = [[TFWebViewController alloc] init];
vc.navTitle = TFLocalizedString(@"隐私协议");
AppDelegate *delegate = (AppDelegate *)kRCodeSync([UIApplication sharedApplication].delegate);
vc.URLString = delegate.checkSettingModel.protocol_list.privacy ?: [NSString stringWithFormat:@"%@%@?language=%@", APIURL, Privacy_Policy, TFLanguageManager.serverLocalized];;
vc.isPresentState = NO;
[[TFViewHelper getCurrentNavigationController] pushViewController:vc animated:YES];
}];
[str setTextHighlightRange:[str.string localizedStandardRangeOfString:TFLocalizedString(@"《会员服务协议》")] color:kMainColor backgroundColor:[UIColor whiteColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
TFWebViewController *vc = [[TFWebViewController alloc] init];
vc.navTitle = TFLocalizedString(@"会员服务协议");
vc.URLString = [NSString stringWithFormat:@"%@%@?language=%@", APIURL, Membership_Service, TFLanguageManager.serverLocalized];
vc.isPresentState = NO;
[[TFViewHelper getCurrentNavigationController] pushViewController:vc animated:YES];
}];
[str setTextHighlightRange:[str.string localizedStandardRangeOfString:TFLocalizedString(@"【意见反馈】")] color:kMainColor backgroundColor:[UIColor whiteColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
[[TFViewHelper getWindowRootController] presentViewController:[[WXYZ_FeedbackSubViewController alloc] init] animated:YES completion:nil];
}];
aboutTextView.attributedText = str;
CGFloat footerHeight = [TFViewHelper getDynamicHeightWithLabelFont:kFont12 labelWidth:SCREEN_WIDTH - kMargin labelText:str.string] - 2 * kMargin;
[aboutTextView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(footerHeight);
}];
}
}
@end
@@ -0,0 +1,20 @@
//
// TFMemberPrivilegeItemCell.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFUpgradeMemberModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFMemberPrivilegeItemCell : UICollectionViewCell
@property (nonatomic ,strong) TFPrivilegeModel *privilegeModel;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,63 @@
//
// TFMemberPrivilegeItemCell.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFMemberPrivilegeItemCell.h"
@interface TFMemberPrivilegeItemCell ()
{
UIImageView *privilegeIcon;
UILabel *privilegeLabel;
}
@end
@implementation TFMemberPrivilegeItemCell
- (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
[self createSubviews];
}
return self;
}
- (void)createSubviews
{
privilegeIcon = [[UIImageView alloc] init];
[self addSubview:privilegeIcon];
[privilegeIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.mas_centerX);
make.top.mas_equalTo(self.mas_top);
make.width.height.mas_equalTo(self.mas_width).multipliedBy(0.5);
}];
privilegeLabel = [[UILabel alloc] init];
privilegeLabel.textAlignment = NSTextAlignmentCenter;
privilegeLabel.textColor = kBlackColor;
privilegeLabel.font = kMainFont;
[self addSubview:privilegeLabel];
[privilegeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.mas_left).with.offset(kQuarterMargin);
make.top.mas_equalTo(privilegeIcon.mas_bottom).with.offset(kHalfMargin + kQuarterMargin);
make.right.mas_equalTo(self.mas_right).with.offset(- kQuarterMargin);
make.height.mas_equalTo(20);
}];
}
- (void)setPrivilegeModel:(TFPrivilegeModel *)privilegeModel
{
_privilegeModel = privilegeModel;
[privilegeIcon setImageWithURL:[NSURL URLWithString:privilegeModel.icon] placeholder:HoldImage options:YYWebImageOptionSetImageWithFadeAnimation completion:nil];
privilegeLabel.text = privilegeModel.label?:@"";
}
@end
@@ -0,0 +1,21 @@
//
// TFMemberPrivilegeViewCell.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFBasicTableViewCell.h"
#import "TFUpgradeMemberModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFMemberPrivilegeViewCell : TFBasicTableViewCell <UICollectionViewDelegate, UICollectionViewDataSource>
@property (nonatomic ,strong) NSArray<TFPrivilegeModel *> *privilege;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,84 @@
//
// TFMemberPrivilegeViewCell.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFMemberPrivilegeViewCell.h"
#import "TFMemberPrivilegeItemCell.h"
@interface TFMemberPrivilegeViewCell ()
{
UICollectionView *mainCollectionView;
}
@end
@implementation TFMemberPrivilegeViewCell
- (void)createSubviews
{
[super createSubviews];
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
flowLayout.minimumLineSpacing = 0;
flowLayout.minimumInteritemSpacing = 0;
flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
flowLayout.itemSize = CGSizeMake(SCREEN_WIDTH / 4 , SCREEN_WIDTH / 4);
mainCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout];
[mainCollectionView registerClass:[TFMemberPrivilegeItemCell class] forCellWithReuseIdentifier:@"TFMemberPrivilegeItemCell"];
mainCollectionView.backgroundColor = [UIColor clearColor];
mainCollectionView.alwaysBounceVertical = NO;
mainCollectionView.showsVerticalScrollIndicator = NO;
mainCollectionView.showsHorizontalScrollIndicator = NO;
mainCollectionView.delegate = self;
mainCollectionView.dataSource = self;
[self.contentView addSubview:mainCollectionView];
[mainCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.contentView.mas_left);
make.top.mas_equalTo(self.contentView.mas_top).with.offset(kHalfMargin);
make.width.mas_equalTo(self.contentView.mas_width);
make.height.mas_equalTo(SCREEN_WIDTH / 4);
make.bottom.mas_equalTo(self.contentView.mas_bottom).priorityLow();
}];
}
- (void)setPrivilege:(NSArray<TFPrivilegeModel *> *)privilege
{
_privilege = privilege;
if (privilege.count > 0) {
[mainCollectionView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo((SCREEN_WIDTH / 4) * (privilege.count % 4 == 0?(privilege.count / 4):((privilege.count / 4) + 1)));
}];
[mainCollectionView reloadData];
}
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return self.privilege.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"TFMemberPrivilegeItemCell";
TFMemberPrivilegeItemCell __weak *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
cell.privilegeModel = [self.privilege objectOrNilAtIndex:indexPath.row];
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
// TFProductionModel *labelListModel = [self.model.list objectOrNilAtIndex:indexPath.row];
// if (self.cellDidSelectItemBlock) {
// self.cellDidSelectItemBlock(labelListModel.production_id);
// }
}
@end
@@ -0,0 +1,20 @@
//
// TFUpgradeMemberHeaderView.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFMemberModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFUpgradeMemberHeaderView : UIView
@property (nonatomic ,strong) TFMemberInfoModel *userModel;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,127 @@
//
// TFUpgradeMemberHeaderView.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFUpgradeMemberHeaderView.h"
@interface TFUpgradeMemberHeaderView ()
{
UIImageView *userBackImageView;
UIImageView *userAvatar;
UILabel *userNickname;
UIImageView *vipImageView;
UILabel *noticeLabel;
}
@end
@implementation TFUpgradeMemberHeaderView
- (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
[self createSubviews];
}
return self;
}
- (void)createSubviews
{
self.backgroundColor = kColorRGB(46, 46, 48);
userBackImageView = [[UIImageView alloc] init];
userBackImageView.image = [UIImage imageNamed:@"member_bg"];
[self addSubview:userBackImageView];
[userBackImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(kHalfMargin);
make.bottom.mas_equalTo(self.mas_bottom);
make.width.mas_equalTo(SCREEN_WIDTH - kMargin);
make.height.mas_equalTo(kGeometricHeight(SCREEN_WIDTH - kMargin, 1053, 215));
}];
userAvatar = [[UIImageView alloc] initWithCornerRadiusAdvance:(kGeometricHeight(SCREEN_WIDTH - kMargin, 1053, 215) - kMargin) / 2 rectCornerType:UIRectCornerAllCorners];
[userBackImageView addSubview:userAvatar];
[userAvatar mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(kHalfMargin);
make.centerY.mas_equalTo(userBackImageView.mas_centerY);
make.width.height.mas_equalTo(kGeometricHeight(SCREEN_WIDTH - kMargin, 1053, 215) - kMargin);
}];
userNickname = [[UILabel alloc] init];
userNickname.backgroundColor = [UIColor clearColor];
userNickname.textColor = kBlackColor;
userNickname.font = kMainFont;
userNickname.textAlignment = NSTextAlignmentLeft;
[userBackImageView addSubview:userNickname];
[userNickname mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(userAvatar.mas_right).with.offset(kHalfMargin);
make.bottom.mas_equalTo(userAvatar.mas_centerY);
make.width.mas_equalTo(10);
make.height.mas_equalTo(20);
}];
vipImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"public_vip_normal"]];
vipImageView.hidden = YES;
[userBackImageView addSubview:vipImageView];
[vipImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(userNickname.mas_right).with.offset(kQuarterMargin);
make.centerY.mas_equalTo(userNickname.mas_centerY);
make.height.mas_equalTo(12);
make.width.mas_equalTo(kGeometricWidth(12, 138, 48));
}];
noticeLabel = [[UILabel alloc] init];
noticeLabel.backgroundColor = [UIColor clearColor];
noticeLabel.textColor = kColorRGB(225, 162, 70);
noticeLabel.font = kFont11;
noticeLabel.textAlignment = NSTextAlignmentLeft;
[userBackImageView addSubview:noticeLabel];
[noticeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(userNickname.mas_left);
make.top.mas_equalTo(userAvatar.mas_centerY).with.offset(6);
make.right.mas_equalTo(userBackImageView.mas_right).with.offset(- kHalfMargin);
make.height.mas_equalTo(userNickname.mas_height);
}];
}
- (void)setUserModel:(TFMemberInfoModel *)userModel
{
if (!userModel) {
userNickname.text = TFLocalizedString(@"未登录");
noticeLabel.text = TFLocalizedString(@"开通会员免费畅读会员书库");
return;
}
[userAvatar setImageWithURL:[NSURL URLWithString:userModel.avatar?:@""] placeholder:HoldUserAvatar options:YYWebImageOptionSetImageWithFadeAnimation completion:nil];
noticeLabel.text = userModel.vip_desc;
if (userModel.nickname.length == 0 || !userModel.nickname || !TFUserInfoManager.isLogin) {
userNickname.text = TFLocalizedString(@"未登录");
vipImageView.hidden = YES;
} else {
userNickname.text = userModel.nickname?:@"";
vipImageView.hidden = NO;
if (userModel.baoyue_status == 1) {
noticeLabel.text = userModel.expiry_date.length > 0 ? userModel.expiry_date :userModel.vip_desc;
vipImageView.image = [UIImage imageNamed:@"public_vip_select"];
} else {
vipImageView.image = [UIImage imageNamed:@"public_vip_normal"];
}
}
[userNickname mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:userNickname maxWidth:SCREEN_WIDTH * 0.7]);
}];
}
@end
@@ -0,0 +1,22 @@
//
// TFUpgradeMemberItemCell.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFRechargeModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFUpgradeMemberItemCell : UICollectionViewCell
@property (nonatomic ,strong) TFGoodsModel *goodsModel;
@property (nonatomic ,assign) BOOL cellSelected;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,167 @@
//
// TFUpgradeMemberItemCell.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFUpgradeMemberItemCell.h"
@interface TFUpgradeMemberItemCell ()
{
UIView *backView;
UIImageView *tagImageView;
UILabel *tagTitleLabel;
UILabel *cellTitleLabel;
UILabel *priceTitleLabel;
UILabel *originPriceTitleLabel;
}
@end
@implementation TFUpgradeMemberItemCell
- (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
[self createSubviews];
}
return self;
}
- (void)createSubviews
{
backView = [[UIView alloc] init];
backView.backgroundColor = kWhiteColor;
backView.layer.cornerRadius = 4;
backView.layer.borderWidth = 1;
backView.layer.borderColor = kColorRGB(243, 231, 213).CGColor;
[self addSubview:backView];
[backView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.mas_centerX);
make.centerY.mas_equalTo(self.mas_centerY);
make.width.mas_equalTo(self.mas_width);
make.height.mas_equalTo(self.mas_height);
}];
// 设置端盖的值
tagImageView = [[UIImageView alloc] init];
tagImageView.hidden = YES;
tagImageView.backgroundColor = [UIColor clearColor];
UIImage *tagImage = [UIImage imageNamed:@"member_tag.png"];
tagImageView.image = [tagImage resizableImageWithCapInsets:UIEdgeInsetsMake(tagImage.size.height * 0.5, tagImage.size.width * 0.5, tagImage.size.height * 0.5 - 1.0, tagImage.size.width * 0.5 - 1.0) resizingMode:UIImageResizingModeTile];
[self addSubview:tagImageView];
tagTitleLabel = [[UILabel alloc] init];
tagTitleLabel.textColor = kWhiteColor;
tagTitleLabel.textAlignment = NSTextAlignmentCenter;
tagTitleLabel.font = kFont10;
tagTitleLabel.hidden = YES;
[self addSubview:tagTitleLabel];
[tagTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(backView.mas_top);
make.left.mas_equalTo(backView.mas_left);
make.height.mas_equalTo(20);
make.width.mas_equalTo(CGFLOAT_MIN);
}];
[tagImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(tagTitleLabel);
}];
priceTitleLabel = [[UILabel alloc] init];
priceTitleLabel.textColor = kColorRGB(232, 165, 72);
priceTitleLabel.textAlignment = NSTextAlignmentCenter;
priceTitleLabel.font = kBoldMainFont;
[self addSubview:priceTitleLabel];
[priceTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(backView.mas_left).with.offset(kQuarterMargin);
make.right.mas_equalTo(backView.mas_right).with.offset(- kQuarterMargin);
make.centerY.mas_equalTo(backView.mas_centerY);
make.height.mas_equalTo(backView.mas_height).multipliedBy(0.2);
}];
cellTitleLabel = [[UILabel alloc] init];
cellTitleLabel.textColor = kColorRGB(101, 101, 101);
cellTitleLabel.textAlignment = NSTextAlignmentCenter;
cellTitleLabel.font = kBoldMainFont;
[self addSubview:cellTitleLabel];
[cellTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(backView.mas_top);
make.left.mas_equalTo(priceTitleLabel.mas_left);
make.width.mas_equalTo(priceTitleLabel.mas_width);
make.height.mas_equalTo(backView.mas_height).multipliedBy(0.4);
}];
originPriceTitleLabel = [[UILabel alloc] init];
originPriceTitleLabel.textColor = kColorRGB(153, 153, 153);
originPriceTitleLabel.textAlignment = NSTextAlignmentCenter;
originPriceTitleLabel.numberOfLines = 2;
originPriceTitleLabel.font = kFont10;
[self addSubview:originPriceTitleLabel];
[originPriceTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(priceTitleLabel.mas_bottom);
make.left.mas_equalTo(priceTitleLabel.mas_left);
make.width.mas_equalTo(priceTitleLabel.mas_width);
make.height.mas_equalTo(backView.mas_height).multipliedBy(0.4);
}];
}
- (void)setGoodsModel:(TFGoodsModel *)goodsModel
{
_goodsModel = goodsModel;
if (goodsModel.tag.count > 0) {
if ([goodsModel.tag firstObject].tab.length > 0) {
tagImageView.hidden = NO;
tagTitleLabel.hidden = NO;
tagTitleLabel.text = [goodsModel.tag firstObject].tab?:@"";
[tagTitleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
if (([TFViewHelper getDynamicWidthWithLabel:tagTitleLabel] + kMargin) > (CGRectGetWidth(self.contentView.bounds) - kHalfMargin)) {
make.width.mas_equalTo(CGRectGetWidth(self.contentView.bounds) - kHalfMargin);
} else {
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:tagTitleLabel] + kMargin);
}
}];
}
} else {
tagImageView.hidden = YES;
tagTitleLabel.hidden = YES;
}
cellTitleLabel.text = goodsModel.title?:@"";
originPriceTitleLabel.text = goodsModel.sub_title?:@"";
if (goodsModel.fat_price.length > 0) {
priceTitleLabel.attributedText = [TFViewHelper resetFontWithFont:kBoldFont25 string:goodsModel.fat_price?:@"" range:NSMakeRange(1, goodsModel.fat_price.length - 1)];
} else {
priceTitleLabel.text = @"0";
}
}
- (void)setCellSelected:(BOOL)cellSelected
{
_cellSelected = cellSelected;
if (cellSelected) {
backView.backgroundColor = kColorRGB(255, 247, 235);
backView.layer.borderColor = kColorRGB(223, 174, 103).CGColor;
cellTitleLabel.textColor = kColorRGB(88, 48, 0);
originPriceTitleLabel.textColor = kColorRGB(130, 106, 80);
} else {
backView.backgroundColor = kWhiteColor;
backView.layer.borderColor = kColorRGB(243, 231, 213).CGColor;
cellTitleLabel.textColor = kColorRGB(101, 101, 101);
originPriceTitleLabel.textColor = kColorRGB(153, 153, 153);
}
}
@end
@@ -0,0 +1,23 @@
//
// TFUpgradeMemberViewCell.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFBasicTableViewCell.h"
#import "TFRechargeModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFUpgradeMemberViewCell : TFBasicTableViewCell <UICollectionViewDelegate, UICollectionViewDataSource>
@property (nonatomic ,strong) NSArray<TFGoodsModel *> *goodsList;
@property (nonatomic ,copy) void (^selectItemBlock)(NSInteger itemIndex);
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,85 @@
//
// TFUpgradeMemberViewCell.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFUpgradeMemberViewCell.h"
#import "TFUpgradeMemberItemCell.h"
#import "WXYZ_ShadowView.h"
@interface TFUpgradeMemberViewCell ()
{
UICollectionView *mainCollectionView;
NSInteger selectIndex;
}
@end
@implementation TFUpgradeMemberViewCell
- (void)createSubviews
{
[super createSubviews];
selectIndex = 0;
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
flowLayout.minimumLineSpacing = kMargin;
flowLayout.minimumInteritemSpacing = 0;
flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
flowLayout.itemSize = CGSizeMake((SCREEN_WIDTH - 5 * kMargin) / 3 , (SCREEN_WIDTH - 5 * kMargin) / 3 * 1.1);
flowLayout.sectionInset = UIEdgeInsetsMake(0, kHalfMargin, 0, kHalfMargin);
mainCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout];
[mainCollectionView registerClass:[TFUpgradeMemberItemCell class] forCellWithReuseIdentifier:@"TFUpgradeMemberItemCell"];
mainCollectionView.backgroundColor = [UIColor clearColor];
mainCollectionView.alwaysBounceVertical = NO;
mainCollectionView.showsVerticalScrollIndicator = NO;
mainCollectionView.showsHorizontalScrollIndicator = NO;
mainCollectionView.delegate = self;
mainCollectionView.dataSource = self;
[self.contentView addSubview:mainCollectionView];
[mainCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.contentView.mas_left);
make.top.mas_equalTo(self.contentView.mas_top);
make.width.mas_equalTo(self.contentView.mas_width);
make.height.mas_equalTo((SCREEN_WIDTH - 5 * kMargin) / 3 * 1.1 + kMargin);
make.bottom.mas_equalTo(self.contentView.mas_bottom).priorityLow();
}];
}
- (void)setGoodsList:(NSArray<TFGoodsModel *> *)goodsList
{
_goodsList = goodsList;
[mainCollectionView reloadData];
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return self.goodsList.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"TFUpgradeMemberItemCell";
TFUpgradeMemberItemCell __weak *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
cell.goodsModel = [self.goodsList objectOrNilAtIndex:indexPath.row];
cell.cellSelected = selectIndex == indexPath.row;
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
selectIndex = indexPath.row;
[mainCollectionView reloadData];
if (self.selectItemBlock) {
self.selectItemBlock(indexPath.row);
}
}
@end