Files
peko-ios/YuMi/Modules/YMMine/View/MineInfo/XPMineUserInfoGiftWallViewController.m
2023-08-10 18:44:46 +08:00

148 lines
5.3 KiB
Objective-C

//
// XPMineGiftWallViewController.m
// xplan-ios
//
// Created by 冯硕 on 2022/4/14.
//
#import "XPMineUserInfoGiftWallViewController.h"
///Third
#import <Masonry/Masonry.h>
#import <JXCategoryView/JXCategoryView.h>
#import <JXCategoryView/JXCategoryIndicatorBackgroundView.h>
#import <JXCategoryView/JXCategoryListContainerView.h>
///Tool
#import "UIImage+Utils.h"
///View
#import "XPMineUserInfoGiftWallSubViewController.h"
@interface XPMineUserInfoGiftWallViewController ()<JXCategoryViewDelegate, JXCategoryListContainerViewDelegate>
///分页标题
@property (nonatomic, strong) NSArray<NSString *> *titles;
///分页控件
@property (nonatomic, strong) JXCategoryTitleView *titleView;
///分页lineView
@property (nonatomic, strong) JXCategoryListContainerView *pi_containerView;
///普通礼物
@property (nonatomic,strong) XPMineUserInfoGiftWallSubViewController *normalGiftVC;
///幸运礼物
@property (nonatomic,strong) XPMineUserInfoGiftWallSubViewController *luckyGiftVC;
@end
@implementation XPMineUserInfoGiftWallViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self initSubViews];
[self initSubViewConstraints];
}
#pragma mark - Private Method
- (void)initSubViews {
self.view.backgroundColor = [UIColor whiteColor];
self.title = YMLocalizedString(@"XPMineUserInfoGiftWallViewController0");
[self.view addSubview:self.titleView];
[self.view addSubview:self.pi_containerView];
}
- (void)initSubViewConstraints {
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.view);
make.width.mas_equalTo(100 * 2 + 20);
make.height.mas_equalTo(30);
make.top.mas_equalTo(self.view).offset(10);
}];
[self.pi_containerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.mas_equalTo(self.view);
make.top.mas_equalTo(self.titleView.mas_bottom).offset(10);
}];
}
#pragma mark - JXCategoryViewDelegate
- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
return self.titles.count;
}
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
if (index == 0) {
return self.normalGiftVC;
} else {
return self.luckyGiftVC;
}
}
- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
// 侧滑手势处理
self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0);
}
#pragma mark - Getters And Setters
- (void)setUserUid:(NSString *)userUid {
_userUid = userUid;
self.normalGiftVC.userUid = _userUid;
self.luckyGiftVC.userUid = _userUid;
}
- (JXCategoryTitleView *)titleView {
if (!_titleView) {
_titleView = [[JXCategoryTitleView alloc] init];
_titleView.delegate = self;
_titleView.titles = self.titles;
_titleView.backgroundColor = [UIColor clearColor];
_titleView.titleColor = UIColorFromRGB(0xB3B3C3);
_titleView.titleSelectedColor = UIColorFromRGB(0x1F1A4E);
_titleView.titleFont = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
_titleView.titleSelectedFont = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
_titleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyleCenter;
_titleView.contentScrollViewClickTransitionAnimationEnabled = NO;
_titleView.defaultSelectedIndex = 0;
_titleView.cellSpacing = 20;
_titleView.cellWidthIncrement = 5;
_titleView.cellWidth = 60;
_titleView.listContainer = self.pi_containerView;
JXCategoryIndicatorImageView *lineView = [[JXCategoryIndicatorImageView alloc] init];
lineView.indicatorImageViewSize = CGSizeMake(15, 3);
lineView.verticalMargin = 0;
lineView.indicatorImageView.image = [UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor confirmButtonGradientStartColor], [DJDKMIMOMColor confirmButtonGradientMiddleColor],[DJDKMIMOMColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(15, 3)];
lineView.indicatorImageView.layer.masksToBounds = YES;
lineView.indicatorImageView.layer.cornerRadius = 1.5;
_titleView.indicators = @[lineView];
}
return _titleView;
}
- (JXCategoryListContainerView *)pi_containerView {
if (!_pi_containerView) {
_pi_containerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
_pi_containerView.defaultSelectedIndex = 0;
}
return _pi_containerView;
}
- (NSArray<NSString *> *)titles {
if (!_titles) {
_titles = @[YMLocalizedString(@"XPMineUserInfoGiftWallViewController1"), YMLocalizedString(@"XPMineUserInfoGiftWallViewController2")];
}
return _titles;
}
- (XPMineUserInfoGiftWallSubViewController *)normalGiftVC {
if (!_normalGiftVC) {
_normalGiftVC = [[XPMineUserInfoGiftWallSubViewController alloc] init];
_normalGiftVC.type = GiftWallViewType_Normal;
}
return _normalGiftVC;
}
- (XPMineUserInfoGiftWallSubViewController *)luckyGiftVC {
if (!_luckyGiftVC) {
_luckyGiftVC = [[XPMineUserInfoGiftWallSubViewController alloc] init];
_luckyGiftVC.type = GiftWallViewType_Lucky;
}
return _luckyGiftVC;
}
@end