Files
peko-ios/YuMi/Modules/YMRoom/View/SendRedPacket/PIRoomSendRedPacketVC.m
2023-10-19 15:06:34 +08:00

181 lines
7.3 KiB
Objective-C

//
// PIRoomSendRedPacketVC.m
// YuMi
//
// Created by duoban on 2023/10/18.
//
#import "PIRoomSendRedPacketVC.h"
#import <JXCategoryView/JXCategoryView.h>
#import <JXCategoryView/JXCategoryIndicatorBackgroundView.h>
#import <JXCategoryView/JXCategoryListContainerView.h>
#import "PIRoomSendRedPacketItemVC.h"
@interface PIRoomSendRedPacketVC ()<JXCategoryViewDelegate, JXCategoryListContainerViewDelegate>
///分页标题
@property (nonatomic, strong) NSArray<NSString *> *titles;
///分页控件
@property (nonatomic, strong) JXCategoryTitleView *titleView;
///分页lineView
@property (nonatomic, strong) JXCategoryListContainerView *contentView;
@property(nonatomic,strong) UIView *bgView;
@property(nonatomic,strong) UIImageView *topImageView;
@property(nonatomic,strong) UIButton *tipsBtn;
@property(nonatomic,strong) UIImageView *diamondNumView;
@property(nonatomic,strong) UILabel *diamondNumTextView;
@end
@implementation PIRoomSendRedPacketVC
- (void)viewDidLoad {
[super viewDidLoad];
[self installUI];
[self installConstraints];
}
-(void)installUI{
self.view.backgroundColor = [UIColor clearColor];
self.navigationController.view.backgroundColor = [UIColor clearColor];
[self.navigationController setNavigationBarHidden:YES];
[self.view addSubview:self.bgView];
[self.view addSubview:self.topImageView];
[self.view addSubview:self.titleView];
[self.view addSubview:self.contentView];
}
-(void)installConstraints{
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.bottom.equalTo(self.view);
make.height.mas_equalTo(kGetScaleWidth(543));
}];
[self.topImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.bgView.mas_bottom).mas_offset(-kGetScaleWidth(120));
make.leading.trailing.equalTo(self.view);
}];
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.view);
make.left.right.mas_equalTo(self.view);
make.height.mas_equalTo(kGetScaleWidth(44));
}];
[self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.titleView.mas_bottom);
make.left.right.bottom.mas_equalTo(self.view);
}];
}
#pragma mark - JXCategoryViewDelegate
- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
return self.titles.count;
}
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
UIViewController<JXCategoryListContentViewDelegate> * list = (UIViewController<JXCategoryListContentViewDelegate> *)[self.contentView.validListDict objectForKey:[NSNumber numberWithInteger:index]];
if (list) {
return list;
} else {
PIRoomSendRedPacketItemVC *vc = [[PIRoomSendRedPacketItemVC alloc]init];
return vc;
}
}
-(void)tipsAction{
}
#pragma mark - 懒加载
- (UIView *)bgView{
if(!_bgView){
_bgView = [UIView new];
_bgView.backgroundColor = [UIColor whiteColor];
}
return _bgView;
}
- (UIImageView *)topImageView{
if(!_topImageView){
_topImageView = [UIImageView new];
_topImageView.image = kImage(@"pi_red_packet_top_icon_logo");
_topImageView.userInteractionEnabled = YES;
}
return _topImageView;
}
- (UIButton *)tipsBtn{
if(!_tipsBtn){
_tipsBtn = [UIButton new];
[_tipsBtn setEnlargeEdgeWithTop:10 right:10 bottom:10 left:10];
[_tipsBtn addTarget:self action:@selector(tipsAction) forControlEvents:UIControlEventTouchUpInside];
[_tipsBtn setBackgroundImage:kImage(@"pi_red_packet_top_tip_logo") forState:UIControlStateNormal];
}
return _tipsBtn;
}
- (UIImageView *)diamondNumView{
if(!_diamondNumView){
_diamondNumView = [UIImageView new];
_diamondNumView.image = kImage(@"pi_red_packet_top_diamond_bg");
}
return _diamondNumView;
}
- (UILabel *)diamondNumTextView{
if(!_diamondNumTextView){
_diamondNumTextView = [UILabel new];
NSMutableAttributedString *numAtt = [[NSMutableAttributedString alloc]initWithString:@"9999" attributes:@{NSFontAttributeName:kFontMedium(13),NSForegroundColorAttributeName:[UIColor whiteColor]}];
NSTextAttachment * diamondAttachment = [[NSTextAttachment alloc] init];
UIImage *diamondIconImage = [UIImage imageNamed:@"pi_red_packet_top_diamond_icon"];;
diamondAttachment.bounds = CGRectMake(0, roundf(kFontMedium(13).capHeight - diamondIconImage.size.height)/2.f, diamondIconImage.size.width, diamondIconImage.size.height);
diamondAttachment.image = diamondIconImage;
NSAttributedString * diamondAtt = [NSMutableAttributedString attributedStringWithAttachment:(NSTextAttachment *)diamondAttachment];
[numAtt insertAttributedString:diamondAtt atIndex:0];
NSTextAttachment * addAttachment = [[NSTextAttachment alloc] init];
UIImage *addIconImage = [UIImage imageNamed:@"pi_red_packet_top_diamond_icon"];;
diamondAttachment.bounds = CGRectMake(0, roundf(kFontMedium(13).capHeight - addIconImage.size.height)/2.f, addIconImage.size.width, addIconImage.size.height);
addAttachment.image = addIconImage;
NSAttributedString * addAtt = [NSMutableAttributedString attributedStringWithAttachment:(NSTextAttachment *)addAttachment];
[numAtt insertAttributedString:addAtt atIndex:numAtt.length];
_diamondNumTextView.attributedText = numAtt;
}
return _diamondNumTextView;
}
- (JXCategoryTitleView *)titleView {
if (!_titleView) {
_titleView = [[JXCategoryTitleView alloc] init];
_titleView.delegate = self;
_titleView.titles = self.titles;
_titleView.backgroundColor = [UIColor clearColor];
_titleView.titleColor = UIColorFromRGB(0x767585);
_titleView.titleSelectedColor = UIColorFromRGB(0xFF285C);
_titleView.titleFont =kFontMedium(18);
_titleView.titleSelectedFont = kFontSemibold(18);
_titleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyleCenter;
_titleView.contentScrollViewClickTransitionAnimationEnabled = NO;
_titleView.averageCellSpacingEnabled = NO;
_titleView.contentEdgeInsetLeft = kGetScaleWidth(78);
_titleView.contentEdgeInsetRight = kGetScaleWidth(78);
_titleView.cellWidth = kGetScaleWidth(72);
_titleView.cellSpacing = kGetScaleWidth(75);
_titleView.defaultSelectedIndex = 0;
_titleView.listContainer = self.contentView;
JXCategoryIndicatorImageView *lineView = [[JXCategoryIndicatorImageView alloc] init];
lineView.indicatorImageViewSize = CGSizeMake(kGetScaleWidth(12), kGetScaleWidth(4));
lineView.verticalMargin = 7;
lineView.indicatorImageView.image = [UIImage imageWithColor:UIColorFromRGB(0xFF285C)];
_titleView.indicators = @[lineView];
}
return _titleView;
}
- (NSArray<NSString *> *)titles{
return @[YMLocalizedString(@"PIRoomSendRedPacketVC0"),YMLocalizedString(@"PIRoomSendRedPacketVC1")];
}
- (JXCategoryListContainerView *)contentView {
if (!_contentView) {
_contentView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
_contentView.defaultSelectedIndex = 0;
}
return _contentView;
}
@end