311 lines
12 KiB
Objective-C
311 lines
12 KiB
Objective-C
|
||
//
|
||
// PIRoomSendRedPacketVC.m
|
||
// YuMi
|
||
//
|
||
// Created by duoban on 2023/10/18.
|
||
//
|
||
|
||
#import "PIRoomSendRedPacketVC.h"
|
||
#import <JXPagingView/JXPagerView.h>
|
||
#import <JXPagingView/JXPagerListRefreshView.h>
|
||
#import <JXCategoryView/JXCategoryView.h>
|
||
#import "PIRoomSendRedPacketItemVC.h"
|
||
#import "XPRoomRedPacketPresenter.h"
|
||
#import "WalletInfoModel.h"
|
||
#import "RoomInfoModel.h"
|
||
@interface PIRoomSendRedPacketVC ()<JXPagerViewDelegate,JXPagerMainTableViewGestureDelegate,JXCategoryViewDelegate,JXPagerMainTableViewGestureDelegate>
|
||
///host代理
|
||
@property (nonatomic,weak) id<RoomHostDelegate>hostDelegate;
|
||
///分页标题
|
||
@property (nonatomic, strong) NSArray<NSString *> *titles;
|
||
///分页控件
|
||
@property (nonatomic, strong) JXCategoryTitleView *titleView;
|
||
///分页lineView
|
||
@property (nonatomic, strong) JXPagerView *contentView;
|
||
///返回
|
||
@property(nonatomic,strong) UIButton *pi_backBtn;
|
||
///背景
|
||
@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;
|
||
///钻石icom
|
||
@property(nonatomic,strong) UIImageView *diamondIconView;
|
||
//加号
|
||
@property(nonatomic,strong) UIImageView *addIconView;
|
||
@end
|
||
|
||
@implementation PIRoomSendRedPacketVC
|
||
- (XPRoomRedPacketPresenter *)createPresenter {
|
||
return [[XPRoomRedPacketPresenter alloc] init];
|
||
}
|
||
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate {
|
||
if (self = [super init]) {
|
||
self.hostDelegate = delegate;
|
||
}
|
||
return self;
|
||
}
|
||
- (BOOL)isHiddenNavBar {
|
||
return YES;
|
||
}
|
||
- (void)viewWillAppear:(BOOL)animated {
|
||
[super viewWillAppear:animated];
|
||
[self.presenter getUserWalletInfo];
|
||
}
|
||
- (void)viewDidLoad {
|
||
[super viewDidLoad];
|
||
self.view.backgroundColor = [UIColor clearColor];
|
||
self.navigationController.view.backgroundColor = [UIColor clearColor];
|
||
[self.navigationController setNavigationBarHidden:YES];
|
||
RoomInfoModel *roomInfo = self.hostDelegate.getRoomInfo;
|
||
if(roomInfo.redEnvelopeType == 1){
|
||
self.titles = @[YMLocalizedString(@"PIRoomSendRedPacketVC0")];
|
||
}else if(roomInfo.redEnvelopeType == 2){
|
||
self.titles = @[YMLocalizedString(@"PIRoomSendRedPacketVC1")];
|
||
}else{
|
||
self.titles = @[YMLocalizedString(@"PIRoomSendRedPacketVC0"),YMLocalizedString(@"PIRoomSendRedPacketVC1")];
|
||
}
|
||
[self installUI];
|
||
[self installConstraints];
|
||
}
|
||
-(void)installUI{
|
||
[self.view addSubview:self.pi_backBtn];
|
||
[self.view addSubview:self.bgView];
|
||
[self.view addSubview:self.topImageView];
|
||
[self.view addSubview:self.tipsBtn];
|
||
[self.view addSubview:self.diamondNumView];
|
||
[self.diamondNumView addSubview:self.diamondIconView];
|
||
[self.diamondNumView addSubview:self.diamondNumTextView];
|
||
[self.diamondNumView addSubview:self.addIconView];
|
||
[self.view addSubview:self.contentView];
|
||
}
|
||
-(void)installConstraints{
|
||
[self.pi_backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.edges.equalTo(self.view);
|
||
}];
|
||
[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_top).mas_offset(-kGetScaleWidth(120));
|
||
make.leading.trailing.equalTo(self.view);
|
||
make.height.mas_equalTo(kGetScaleWidth(243));
|
||
}];
|
||
|
||
|
||
[self.tipsBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.width.height.mas_equalTo(kGetScaleWidth(24));
|
||
make.trailing.mas_equalTo(-kGetScaleWidth(12));
|
||
make.top.equalTo(self.topImageView.mas_top).mas_offset(kGetScaleWidth(71));
|
||
}];
|
||
[self.diamondNumView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.top.equalTo(self.bgView.mas_top).mas_offset(kGetScaleWidth(13));
|
||
make.trailing.mas_equalTo(-kGetScaleWidth(0));
|
||
make.width.mas_greaterThanOrEqualTo(kGetScaleWidth(10));
|
||
make.height.mas_equalTo(kGetScaleWidth(30));
|
||
}];
|
||
[self.diamondIconView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.width.height.mas_equalTo(kGetScaleWidth(20));
|
||
make.centerY.equalTo(self.diamondNumView);
|
||
make.leading.mas_equalTo(kGetScaleWidth(6));
|
||
}];
|
||
[self.addIconView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.centerY.equalTo(self.diamondNumView);
|
||
make.width.height.mas_equalTo(kGetScaleWidth(16));
|
||
make.trailing.mas_equalTo(-kGetScaleWidth(6));
|
||
}];
|
||
[self.diamondNumTextView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.centerY.equalTo(self.diamondNumView);
|
||
make.leading.mas_equalTo(kGetScaleWidth(25));
|
||
make.trailing.mas_equalTo(-kGetScaleWidth(23));
|
||
}];
|
||
|
||
[self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.top.equalTo(self.bgView.mas_top).mas_offset(kGetScaleWidth(52));
|
||
make.left.right.bottom.mas_equalTo(self.view);
|
||
}];
|
||
}
|
||
///获取用户钱包信息成功
|
||
- (void)getUserWalletInfo:(WalletInfoModel *)balanceInfo {
|
||
self.diamondNumTextView.text = balanceInfo.diamonds;
|
||
}
|
||
|
||
#pragma mark - JXCategoryViewDelegate
|
||
- (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
|
||
return 0;
|
||
}
|
||
|
||
- (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
|
||
return [UIView new];
|
||
}
|
||
- (NSUInteger)heightForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
|
||
return kGetScaleWidth(44);
|
||
}
|
||
- (UIView *)viewForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
|
||
return self.titleView;
|
||
}
|
||
|
||
- (NSInteger)numberOfListsInPagerView:(JXPagerView *)pagerView {
|
||
return self.titles.count;
|
||
}
|
||
|
||
- (id<JXPagerViewListViewDelegate>)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index {
|
||
|
||
UIViewController<JXPagerViewListViewDelegate> * list = (UIViewController<JXPagerViewListViewDelegate> *)[self.contentView.validListDict objectForKey:[NSNumber numberWithInteger:index]];
|
||
if (list) {
|
||
return list;
|
||
} else {
|
||
PIRoomSendRedPacketItemVC *vc = [[PIRoomSendRedPacketItemVC alloc]initWithDelegate:self.hostDelegate type:index];
|
||
|
||
return vc;
|
||
}
|
||
|
||
}
|
||
|
||
#pragma mark - JXPagerMainTableViewGestureDelegate
|
||
- (BOOL)mainTableViewGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
|
||
//禁止categoryView左右滑动的时候,上下和左右都可以滚动
|
||
if (otherGestureRecognizer.view == self.contentView.listContainerView) {
|
||
return NO;
|
||
}
|
||
if(otherGestureRecognizer.view.tag == 3000000001){
|
||
return YES;
|
||
}
|
||
|
||
|
||
return [gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]];
|
||
}
|
||
-(void)tipsAction{
|
||
|
||
}
|
||
-(void)hiddenViewAction{
|
||
[self dismissViewControllerAnimated:YES completion:nil];
|
||
}
|
||
-(NSTextAttachment *)getDiamondNumAtt:(NSString *)image{
|
||
NSTextAttachment * diamondAttachment = [[NSTextAttachment alloc] init];
|
||
UIImage *diamondIconImage = [UIImage imageNamed:image];;
|
||
diamondAttachment.bounds = CGRectMake(0, roundf(kFontMedium(13).capHeight - diamondIconImage.size.height)/2.f, diamondIconImage.size.width, diamondIconImage.size.height);
|
||
diamondAttachment.image = diamondIconImage;
|
||
return diamondAttachment;
|
||
}
|
||
- (UIImage*)resizableImage:(UIImage *)image {
|
||
//图片拉伸区域
|
||
CGFloat top = (image.size.height - 1) / 2;
|
||
CGFloat left = (image.size.width - 1) / 2;
|
||
CGFloat right = (image.size.width - 1) / 2;
|
||
CGFloat bottom = (image.size.height - 1) / 2;
|
||
return [image resizableImageWithCapInsets:UIEdgeInsetsMake(top, left, bottom, right) resizingMode:UIImageResizingModeStretch];
|
||
}
|
||
#pragma mark - 懒加载
|
||
- (UIView *)bgView{
|
||
if(!_bgView){
|
||
_bgView = [UIView new];
|
||
_bgView.backgroundColor = [UIColor whiteColor];
|
||
}
|
||
return _bgView;
|
||
}
|
||
- (UIButton *)pi_backBtn{
|
||
if(!_pi_backBtn){
|
||
_pi_backBtn = [UIButton new];
|
||
[_pi_backBtn addTarget:self action:@selector(hiddenViewAction) forControlEvents:UIControlEventTouchUpInside];
|
||
}
|
||
return _pi_backBtn;
|
||
}
|
||
- (UIImageView *)topImageView{
|
||
if(!_topImageView){
|
||
_topImageView = [UIImageView new];
|
||
_topImageView.image = kImage(@"pi_red_packet_top_icon_logo");
|
||
}
|
||
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 = [self resizableImage:kImage(@"pi_red_packet_top_diamond_bg")];
|
||
}
|
||
return _diamondNumView;
|
||
}
|
||
- (UILabel *)diamondNumTextView{
|
||
if(!_diamondNumTextView){
|
||
_diamondNumTextView = [UILabel labelInitWithText:@"0" font:kFontMedium(13) textColor:[UIColor whiteColor]];
|
||
_diamondNumTextView.textAlignment = NSTextAlignmentCenter;
|
||
}
|
||
return _diamondNumTextView;
|
||
}
|
||
- (UIImageView *)diamondIconView{
|
||
if(!_diamondIconView){
|
||
_diamondIconView = [UIImageView new];
|
||
_diamondIconView.image = kImage(@"pi_red_packet_top_diamond_icon");
|
||
}
|
||
return _diamondIconView;
|
||
}
|
||
-(UIImageView *)addIconView{
|
||
if(!_addIconView){
|
||
_addIconView = [UIImageView new];
|
||
_addIconView.image = kImage(@"pi_red_packet_top_diamond_add");
|
||
}
|
||
return _addIconView;
|
||
}
|
||
- (JXCategoryTitleView *)titleView {
|
||
if (!_titleView) {
|
||
_titleView = [[JXCategoryTitleView alloc] init];
|
||
_titleView.delegate = self;
|
||
_titleView.titles = self.titles;
|
||
_titleView.backgroundColor = [UIColor whiteColor];
|
||
_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 = (id<JXCategoryViewListContainer>)self.contentView.listContainerView;
|
||
|
||
|
||
JXCategoryIndicatorImageView *lineView = [[JXCategoryIndicatorImageView alloc] init];
|
||
lineView.indicatorImageViewSize = CGSizeMake(kGetScaleWidth(12), kGetScaleWidth(4));
|
||
lineView.verticalMargin = kGetScaleWidth(5);
|
||
lineView.backgroundColor = UIColorFromRGB(0xFF285C);
|
||
lineView.layer.cornerRadius = kGetScaleWidth(4)/2;
|
||
lineView.layer.masksToBounds = YES;
|
||
_titleView.indicators = @[lineView];
|
||
}
|
||
return _titleView;
|
||
}
|
||
|
||
|
||
- (JXPagerView *)contentView {
|
||
if (!_contentView) {
|
||
_contentView = [[JXPagerView alloc] initWithDelegate:self listContainerType:0];
|
||
_contentView.mainTableView.gestureDelegate = self;
|
||
_contentView.backgroundColor = [UIColor whiteColor];
|
||
_contentView.listContainerView.backgroundColor = [UIColor whiteColor];
|
||
_contentView.listContainerView.listCellBackgroundColor = [UIColor whiteColor];
|
||
_contentView.mainTableView.backgroundColor = [UIColor whiteColor];
|
||
}
|
||
return _contentView;
|
||
}
|
||
@end
|