255 lines
8.6 KiB
Objective-C
255 lines
8.6 KiB
Objective-C
//
|
|
// YMMineDressUpViewController.m
|
|
// YUMI
|
|
//
|
|
// Created by YUMI on 2021/12/15.
|
|
//
|
|
|
|
#import "XPMineDressUpViewController.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
#import <JXCategoryView/JXCategoryView.h>
|
|
#import <JXCategoryView/JXCategoryListContainerView.h>
|
|
#import <SDCycleScrollView/SDCycleScrollView.h>
|
|
///Tool
|
|
#import "DJDKMIMOMColor.h"
|
|
#import "Api+DressUp.h"
|
|
#import "NSArray+Safe.h"
|
|
///Model
|
|
#import "ActivityInfoModel.h"
|
|
///View
|
|
#import "XPMineDressUpListViewController.h"
|
|
#import "XPRoomViewController.h"
|
|
#import "XPWebViewController.h"
|
|
#import "XPMineDressUpBubbleViewController.h"
|
|
|
|
@interface XPMineDressUpViewController ()<JXCategoryViewDelegate, JXCategoryListContainerViewDelegate, SDCycleScrollViewDelegate>
|
|
///分页标题
|
|
@property (nonatomic, strong) NSArray<NSString *> *titles;
|
|
///分页控件
|
|
@property (nonatomic, strong) JXCategoryTitleView *titleView;
|
|
///分页lineView
|
|
@property (nonatomic, strong) JXCategoryListContainerView *contentView;
|
|
///头饰
|
|
@property (nonatomic,strong) XPMineDressUpListViewController *headwearView;
|
|
///座驾
|
|
@property (nonatomic,strong) XPMineDressUpListViewController *carView;
|
|
///铭牌
|
|
@property (nonatomic,strong) XPMineDressUpListViewController *nameplateView;
|
|
///VIP资料卡
|
|
@property (nonatomic, strong) XPMineDressUpListViewController *nobleView;
|
|
///公屏气泡
|
|
@property (nonatomic, strong) XPMineDressUpBubbleViewController *bubbleView;
|
|
///轮播图
|
|
@property (nonatomic,strong) SDCycleScrollView *pi_BannerView;
|
|
///房间活动的列表
|
|
@property (nonatomic,copy) NSArray<ActivityInfoModel *> *activityList;
|
|
@end
|
|
|
|
@implementation XPMineDressUpViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
[self requestActivityList];
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
self.title = YMLocalizedString(@"XPMineDressUpViewController0");
|
|
[self.view addSubview:self.pi_BannerView];
|
|
[self.view addSubview:self.titleView];
|
|
[self.view addSubview:self.contentView];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.pi_BannerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(self.view);
|
|
make.left.mas_equalTo(15);
|
|
make.right.mas_equalTo(-15);
|
|
make.height.mas_equalTo(100);
|
|
}];
|
|
|
|
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.right.mas_equalTo(self.view);
|
|
make.height.mas_equalTo(50);
|
|
make.top.mas_equalTo(self.pi_BannerView.mas_bottom);
|
|
}];
|
|
|
|
[self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.right.bottom.mas_equalTo(self.view);
|
|
make.top.mas_equalTo(self.titleView.mas_bottom);
|
|
}];
|
|
}
|
|
|
|
- (void)requestActivityList {
|
|
[Api dressupBannerList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
|
if (code == 200) {
|
|
NSArray <ActivityInfoModel *>* array = [ActivityInfoModel modelsWithArray:data.data];
|
|
if (array.count <= 0) {
|
|
[self.pi_BannerView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
make.height.mas_equalTo(0);
|
|
}];
|
|
return;
|
|
}
|
|
self.activityList = array;
|
|
NSMutableArray * picList = [NSMutableArray array];
|
|
[array enumerateObjectsUsingBlock:^(ActivityInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
if (obj.bannerPic.length > 0) {
|
|
[picList addObject:obj.bannerPic];
|
|
}
|
|
}];
|
|
self.pi_BannerView.imageURLStringsGroup = picList;
|
|
if (array.count > 1) {
|
|
[self.pi_BannerView setAutoScroll:YES];
|
|
self.pi_BannerView.autoScrollTimeInterval = 3;
|
|
} else {
|
|
[self.pi_BannerView setAutoScroll:NO];
|
|
}
|
|
} else {
|
|
[self.pi_BannerView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
make.height.mas_equalTo(0);
|
|
}];
|
|
}
|
|
} type:@"3"];
|
|
}
|
|
|
|
#pragma mark - JXCategoryViewDelegate
|
|
- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
|
|
return self.titles.count;
|
|
}
|
|
|
|
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
|
|
if (index == 0) {
|
|
return self.headwearView;
|
|
} else if(index == 1) {
|
|
return self.carView;
|
|
} else if (index == 2) {
|
|
return self.nameplateView;
|
|
} else if (index == 3) {
|
|
return self.nobleView;
|
|
}
|
|
return self.bubbleView;
|
|
}
|
|
|
|
// 点击选中或者滚动选中都会调用该方法。适用于只关心选中事件,不关心具体是点击还是滚动选中的。
|
|
- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
|
|
// 侧滑手势处理
|
|
self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0);
|
|
}
|
|
|
|
#pragma mark - SDCycleScrollViewDelegate
|
|
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
|
|
if (self.activityList.count > index) {
|
|
ActivityInfoModel * info = [self.activityList safeObjectAtIndex1:index];
|
|
if (info.skipType == ActivitySkipType_Room) {
|
|
[XPRoomViewController openRoom:info.skipUri viewController:self.navigationController];
|
|
} else if(info.skipType == ActivitySkipType_Web) {
|
|
XPWebViewController * webVC = [[XPWebViewController alloc] init];
|
|
webVC.url = info.skipUri;
|
|
[self.navigationController pushViewController:webVC animated:YES];
|
|
}
|
|
}
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
- (void)setCurrentIndex:(NSInteger)currentIndex {
|
|
if (currentIndex < self.titles.count) {
|
|
[self.titleView setDefaultSelectedIndex:currentIndex];
|
|
}
|
|
}
|
|
|
|
- (JXCategoryTitleView *)titleView {
|
|
if (!_titleView) {
|
|
_titleView = [[JXCategoryTitleView alloc] init];
|
|
_titleView.delegate = self;
|
|
_titleView.titles = self.titles;
|
|
_titleView.titleColor = [DJDKMIMOMColor secondTextColor];
|
|
_titleView.titleSelectedColor = [DJDKMIMOMColor mainTextColor];
|
|
_titleView.titleFont = [UIFont fontWithName:@"PingFang-SC-Medium" size:16];
|
|
_titleView.titleSelectedFont = [UIFont fontWithName:@"PingFang-SC-Medium" size:16];
|
|
_titleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyleCenter;
|
|
_titleView.contentScrollViewClickTransitionAnimationEnabled = NO;
|
|
_titleView.defaultSelectedIndex = 0;
|
|
_titleView.listContainer = self.contentView;
|
|
|
|
JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
|
|
lineView.indicatorColor = [DJDKMIMOMColor appMainColor];
|
|
lineView.indicatorWidth = 8.f;
|
|
lineView.indicatorHeight = 4.f;
|
|
lineView.indicatorCornerRadius = 2.f;
|
|
_titleView.indicators = @[lineView];
|
|
}
|
|
return _titleView;
|
|
}
|
|
|
|
- (JXCategoryListContainerView *)contentView {
|
|
if (!_contentView) {
|
|
_contentView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
|
|
_contentView.scrollView.backgroundColor = [UIColor clearColor];
|
|
_contentView.defaultSelectedIndex = 0;
|
|
}
|
|
return _contentView;
|
|
}
|
|
|
|
- (NSArray<NSString *> *)titles {
|
|
return @[YMLocalizedString(@"XPMineDressUpViewController1"), YMLocalizedString(@"XPMineDressUpViewController2"), YMLocalizedString(@"XPMineDressUpViewController3"), YMLocalizedString(@"XPMineDressUpViewController4"), YMLocalizedString(@"XPMineDressUpViewController5")];
|
|
}
|
|
|
|
- (XPMineDressUpListViewController *)headwearView {
|
|
if (!_headwearView) {
|
|
_headwearView = [[XPMineDressUpListViewController alloc] init];
|
|
_headwearView.type = DressUpListType_HeadWear;
|
|
}
|
|
return _headwearView;
|
|
}
|
|
|
|
- (XPMineDressUpListViewController *)carView {
|
|
if (!_carView) {
|
|
_carView = [[XPMineDressUpListViewController alloc] init];
|
|
_carView.type = DressUpListType_Car;
|
|
}
|
|
return _carView;
|
|
}
|
|
|
|
- (XPMineDressUpListViewController *)nameplateView {
|
|
if (!_nameplateView) {
|
|
_nameplateView = [[XPMineDressUpListViewController alloc] init];
|
|
_nameplateView.type = DressUpListType_Nameplate;
|
|
}
|
|
return _nameplateView;
|
|
}
|
|
|
|
- (XPMineDressUpListViewController *)nobleView {
|
|
if (!_nobleView) {
|
|
_nobleView = [[XPMineDressUpListViewController alloc] init];
|
|
_nobleView.type = DressUpListType_Noble;
|
|
}
|
|
return _nobleView;
|
|
}
|
|
|
|
- (XPMineDressUpBubbleViewController *)bubbleView {
|
|
if (!_bubbleView) {
|
|
_bubbleView = [[XPMineDressUpBubbleViewController alloc] init];
|
|
}
|
|
return _bubbleView;
|
|
}
|
|
|
|
- (SDCycleScrollView *)pi_BannerView {
|
|
if (!_pi_BannerView) {
|
|
_pi_BannerView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero delegate:self placeholderImage:nil];
|
|
_pi_BannerView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter;
|
|
_pi_BannerView.currentPageDotColor = [UIColor whiteColor];
|
|
_pi_BannerView.pageDotColor = [UIColor colorWithWhite:1 alpha:0.15];
|
|
_pi_BannerView.backgroundColor = [UIColor colorWithWhite:1 alpha:0.00];
|
|
_pi_BannerView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
|
|
_pi_BannerView.layer.masksToBounds = YES;
|
|
_pi_BannerView.layer.cornerRadius = 12;
|
|
}
|
|
return _pi_BannerView;
|
|
}
|
|
|
|
|
|
@end
|