2022-02-21 20:06:09 +08:00
|
|
|
|
//
|
|
|
|
|
// XPHomeRecommendViewController.m
|
|
|
|
|
// xplan-ios
|
|
|
|
|
//
|
|
|
|
|
// Created by 冯硕 on 2022/2/21.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "XPHomeRecommendViewController.h"
|
|
|
|
|
///Third
|
|
|
|
|
#import <Masonry/Masonry.h>
|
2022-02-25 21:18:01 +08:00
|
|
|
|
#import <JXPagingView/JXPagerView.h>
|
|
|
|
|
#import <JXPagingView/JXPagerListRefreshView.h>
|
|
|
|
|
#import <JXCategoryView/JXCategoryView.h>
|
|
|
|
|
#import <MJRefresh/MJRefresh.h>
|
2022-02-21 20:06:09 +08:00
|
|
|
|
///Tool
|
|
|
|
|
#import "XPMacro.h"
|
2022-02-25 21:18:01 +08:00
|
|
|
|
#import "ThemeColor.h"
|
2022-03-03 20:41:03 +08:00
|
|
|
|
#import "XPWeakTimer.h"
|
2022-02-25 21:18:01 +08:00
|
|
|
|
#import "UIImage+Utils.h"
|
2022-02-21 20:06:09 +08:00
|
|
|
|
///View
|
2022-02-25 21:18:01 +08:00
|
|
|
|
#import "XPHomeRecommendHeaderView.h"
|
2022-02-21 20:06:09 +08:00
|
|
|
|
///P
|
|
|
|
|
#import "XPHomeRecommendPresenter.h"
|
|
|
|
|
#import "XPHomeRecommendProtocol.h"
|
|
|
|
|
///VC
|
2022-02-25 21:18:01 +08:00
|
|
|
|
#import "XPHomeHappyViewController.h"
|
|
|
|
|
#import "XPHomeHotRoomViewController.h"
|
|
|
|
|
@class HomeMenuInfoModel,HomeBannerInfoModel,HomeRecommendRoomModel, HomePlayRoomModel;
|
|
|
|
|
@interface XPHomeRecommendViewController ()<JXCategoryViewDelegate,JXPagerViewDelegate, XPHomeRecommendProtocol,JXPagerMainTableViewGestureDelegate>
|
2022-03-03 20:41:03 +08:00
|
|
|
|
{
|
|
|
|
|
NSTimer * timer;
|
|
|
|
|
}
|
2022-02-25 21:18:01 +08:00
|
|
|
|
@property (nonatomic, strong) JXCategoryTitleView *titleView;
|
|
|
|
|
@property (nonatomic, strong) JXCategoryIndicatorLineView *lineView;
|
|
|
|
|
@property (nonatomic, strong) JXPagerView *pagingView;
|
|
|
|
|
@property (nonatomic, strong) NSArray<NSString *> *titles;
|
|
|
|
|
///
|
|
|
|
|
@property (nonatomic,strong) XPHomeRecommendHeaderView *headerView;
|
2022-02-21 20:06:09 +08:00
|
|
|
|
///菜单列表
|
|
|
|
|
@property (nonatomic,strong) NSArray<HomeMenuInfoModel *> *menuList;
|
|
|
|
|
///轮播图
|
|
|
|
|
@property (nonatomic,strong) NSArray<HomeBannerInfoModel *> *bannerList;
|
|
|
|
|
///推荐房
|
|
|
|
|
@property (nonatomic,strong) NSArray<HomeRecommendRoomModel *> *recommendList;
|
|
|
|
|
///热门房
|
|
|
|
|
@property (nonatomic,strong) NSArray<HomeRecommendRoomModel *> *hotRoomList;
|
2022-02-25 21:18:01 +08:00
|
|
|
|
///组队开黑
|
|
|
|
|
@property (nonatomic,strong) NSArray<HomePlayRoomModel *> *playTeamList;
|
|
|
|
|
///个人房列表数据
|
|
|
|
|
@property (nonatomic,strong) NSArray<HomePlayRoomModel *> *personalRoomList;
|
|
|
|
|
///个人房
|
|
|
|
|
@property (nonatomic,strong) XPHomeHappyViewController *personalRoomVC;
|
|
|
|
|
///热门房
|
|
|
|
|
@property (nonatomic,strong) XPHomeHotRoomViewController *hotRoomVC;
|
2022-02-21 20:06:09 +08:00
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation XPHomeRecommendViewController
|
|
|
|
|
- (XPHomeRecommendPresenter *)createPresenter {
|
|
|
|
|
return [[XPHomeRecommendPresenter alloc] init];
|
|
|
|
|
}
|
|
|
|
|
- (BOOL)isHiddenNavBar {
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
|
[super viewDidLoad];
|
2022-02-25 21:18:01 +08:00
|
|
|
|
[self initHeaderAndFooterRrfresh];
|
2022-02-21 20:06:09 +08:00
|
|
|
|
[self initSubViews];
|
2022-03-03 20:41:03 +08:00
|
|
|
|
[self addTimer];
|
2022-02-21 20:06:09 +08:00
|
|
|
|
}
|
2022-02-25 21:18:01 +08:00
|
|
|
|
|
|
|
|
|
- (void)viewDidLayoutSubviews {
|
|
|
|
|
[super viewDidLayoutSubviews];
|
|
|
|
|
self.pagingView.frame = self.view.bounds;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-03 20:41:03 +08:00
|
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
|
|
|
[super viewWillAppear:animated];
|
|
|
|
|
if (timer) {
|
|
|
|
|
[timer setFireDate:[NSDate distantPast]]; //很远的过去
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)viewWillDisappear:(BOOL)animated {
|
|
|
|
|
[super viewWillDisappear:animated];
|
|
|
|
|
if (timer) {
|
|
|
|
|
//关闭定时器
|
|
|
|
|
[timer setFireDate:[NSDate distantFuture]]; //很远的将来
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-21 20:06:09 +08:00
|
|
|
|
#pragma mark - InitHttp
|
2022-03-03 20:41:03 +08:00
|
|
|
|
- (void)addTimer {
|
|
|
|
|
timer = [XPWeakTimer scheduledTimerWithTimeInterval:15 block:^(id userInfo) {
|
|
|
|
|
[self headerRefresh];
|
|
|
|
|
} userInfo:nil repeats:YES];
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-25 21:18:01 +08:00
|
|
|
|
- (void)headerRefresh {
|
2022-02-21 20:06:09 +08:00
|
|
|
|
[self.presenter getHomeTopBannerList];
|
|
|
|
|
[self.presenter getHomeRecommendRoomList];
|
|
|
|
|
[self.presenter getHomeHotRoomList];
|
2022-02-25 21:18:01 +08:00
|
|
|
|
[self.presenter getPlayGameWithTeam:1];
|
|
|
|
|
[self.presenter getHomePersonalRoomList];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)initHeaderAndFooterRrfresh {
|
|
|
|
|
MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)];
|
|
|
|
|
header.stateLabel.font = [UIFont systemFontOfSize:10.0];
|
|
|
|
|
header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:10.0];
|
|
|
|
|
header.stateLabel.textColor = [ThemeColor secondTextColor];
|
|
|
|
|
header.lastUpdatedTimeLabel.textColor = [ThemeColor secondTextColor];
|
|
|
|
|
self.pagingView.mainTableView.mj_header = header;
|
|
|
|
|
[self headerRefresh];
|
2022-02-21 20:06:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - Private Method
|
|
|
|
|
- (void)initSubViews {
|
|
|
|
|
self.view.backgroundColor = [UIColor clearColor];
|
2022-02-25 21:18:01 +08:00
|
|
|
|
[self.view addSubview:self.pagingView];
|
|
|
|
|
}
|
|
|
|
|
#pragma mark - XPHomeRecommendProtocol
|
|
|
|
|
- (void)getHomeTopBannerListSuccess:(NSArray *)list menuList:(NSArray *)list1{
|
|
|
|
|
[self.pagingView.mainTableView.mj_header endRefreshing];
|
|
|
|
|
self.bannerList = list;
|
|
|
|
|
self.menuList = list1;
|
|
|
|
|
self.headerView.bannerList = list;
|
|
|
|
|
self.headerView.menuList = list1;
|
|
|
|
|
[self.pagingView reloadData];
|
2022-02-21 20:06:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-02-25 21:18:01 +08:00
|
|
|
|
- (void)getHomeRecommendRoomListSuccess:(NSArray *)list {
|
|
|
|
|
[self.pagingView.mainTableView.mj_header endRefreshing];
|
|
|
|
|
self.recommendList= list;
|
|
|
|
|
self.headerView.recommendList = list;
|
|
|
|
|
[self.pagingView reloadData];
|
2022-02-21 20:06:09 +08:00
|
|
|
|
}
|
2022-02-25 21:18:01 +08:00
|
|
|
|
|
|
|
|
|
- (void)getHomeHotRoomListSuccess:(NSArray *)list {
|
|
|
|
|
[self.pagingView.mainTableView.mj_header endRefreshing];
|
|
|
|
|
self.hotRoomList = list;
|
|
|
|
|
self.headerView.hotRoomList = list;
|
|
|
|
|
[self.pagingView reloadData];
|
2022-02-21 20:06:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-02-25 21:18:01 +08:00
|
|
|
|
- (void)getHomePersonalRoomListSuccess:(NSArray *)list {
|
|
|
|
|
[self.pagingView.mainTableView.mj_header endRefreshing];
|
|
|
|
|
self.personalRoomList = list;
|
|
|
|
|
self.hotRoomVC.roomList = list;
|
2022-02-21 20:06:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-02-25 21:18:01 +08:00
|
|
|
|
- (void)getPlayGameWithTeamSuccess:(NSArray *)list {
|
|
|
|
|
[self.pagingView.mainTableView.mj_header endRefreshing];
|
|
|
|
|
self.playTeamList = list;
|
|
|
|
|
[self.personalRoomVC configPlayGameRoomList:list];
|
2022-02-21 20:06:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-03 20:41:03 +08:00
|
|
|
|
- (void)getHomeRecommendDataFail {
|
|
|
|
|
[self.pagingView.mainTableView.mj_header endRefreshing];
|
|
|
|
|
[self.pagingView.mainTableView.mj_footer endRefreshing];
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-25 21:18:01 +08:00
|
|
|
|
#pragma mark - JXCategoryListContentViewDelegate
|
|
|
|
|
- (UIView *)listView {
|
|
|
|
|
return self.view;
|
2022-02-21 20:06:09 +08:00
|
|
|
|
}
|
2022-02-25 21:18:01 +08:00
|
|
|
|
|
|
|
|
|
#pragma mark - JXCategoryViewDelegate
|
|
|
|
|
- (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
|
|
|
|
|
return [XPHomeRecommendHeaderView getHomeRecommendHeaderViewHeight:self.bannerList menuList:self.menuList recommendList:self.recommendList hotRoomList:self.hotRoomList];
|
2022-02-21 20:06:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-02-25 21:18:01 +08:00
|
|
|
|
- (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
|
|
|
|
|
return self.headerView;
|
2022-02-21 20:06:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-02-25 21:18:01 +08:00
|
|
|
|
- (NSUInteger)heightForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
|
|
|
|
|
return 50;
|
2022-02-21 20:06:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-02-25 21:18:01 +08:00
|
|
|
|
- (UIView *)viewForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
|
|
|
|
|
return self.titleView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSInteger)numberOfListsInPagerView:(JXPagerView *)pagerView {
|
|
|
|
|
return self.titles.count;
|
2022-02-21 20:06:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-02-25 21:18:01 +08:00
|
|
|
|
- (id<JXPagerViewListViewDelegate>)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index {
|
|
|
|
|
UIViewController *viewController;
|
|
|
|
|
switch (index) {
|
|
|
|
|
case 0:
|
2022-02-21 20:06:09 +08:00
|
|
|
|
{
|
2022-02-25 21:18:01 +08:00
|
|
|
|
viewController = self.personalRoomVC;
|
2022-02-21 20:06:09 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
2022-02-25 21:18:01 +08:00
|
|
|
|
case 1:
|
2022-02-21 20:06:09 +08:00
|
|
|
|
{
|
2022-02-25 21:18:01 +08:00
|
|
|
|
viewController = self.hotRoomVC;
|
2022-02-21 20:06:09 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
2022-02-25 21:18:01 +08:00
|
|
|
|
|
2022-02-21 20:06:09 +08:00
|
|
|
|
}
|
2022-02-25 21:18:01 +08:00
|
|
|
|
return (id <JXPagerViewListViewDelegate>)viewController;
|
2022-02-21 20:06:09 +08:00
|
|
|
|
}
|
2022-03-01 19:28:16 +08:00
|
|
|
|
|
2022-03-03 20:41:03 +08:00
|
|
|
|
- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
|
|
|
|
|
if (index == 0) {
|
|
|
|
|
[self.presenter getPlayGameWithTeam:1];
|
|
|
|
|
} else {
|
|
|
|
|
[self.presenter getHomePersonalRoomList];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-25 21:18:01 +08:00
|
|
|
|
#pragma mark - JXPagerMainTableViewGestureDelegate
|
2022-02-21 20:06:09 +08:00
|
|
|
|
|
2022-02-25 21:18:01 +08:00
|
|
|
|
- (BOOL)mainTableViewGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
|
|
|
|
|
//禁止categoryView左右滑动的时候,上下和左右都可以滚动
|
|
|
|
|
if (otherGestureRecognizer == self.titleView.collectionView.panGestureRecognizer) {
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
return [gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]];
|
2022-02-21 20:06:09 +08:00
|
|
|
|
}
|
|
|
|
|
#pragma mark - Getters And Setters
|
2022-02-25 21:18:01 +08:00
|
|
|
|
- (JXCategoryTitleView *)titleView {
|
|
|
|
|
if (!_titleView) {
|
|
|
|
|
_titleView = [[JXCategoryTitleView alloc] init];
|
|
|
|
|
_titleView.delegate = self;
|
|
|
|
|
_titleView.backgroundColor = [UIColor clearColor];
|
|
|
|
|
_titleView.titleColor = [ThemeColor textThirdColor];
|
|
|
|
|
_titleView.titleSelectedColor = [ThemeColor mainTextColor];
|
|
|
|
|
_titleView.titleFont = [UIFont fontWithName:@"PingFang-SC-Medium" size:12];
|
|
|
|
|
_titleView.titleSelectedFont = [UIFont fontWithName:@"PingFang-SC-Medium" size:16];
|
|
|
|
|
_titleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyleCenter;
|
|
|
|
|
_titleView.contentScrollViewClickTransitionAnimationEnabled = NO;
|
|
|
|
|
_titleView.defaultSelectedIndex = 0;
|
|
|
|
|
_titleView.averageCellSpacingEnabled = NO;
|
|
|
|
|
_titleView.titles = self.titles;
|
|
|
|
|
_titleView.cellSpacing = 20;
|
|
|
|
|
_titleView.titles = self.titles;
|
|
|
|
|
_titleView.listContainer = (id<JXCategoryViewListContainer>)self.pagingView.listContainerView;
|
|
|
|
|
|
|
|
|
|
JXCategoryIndicatorImageView *lineView = [[JXCategoryIndicatorImageView alloc] init];
|
|
|
|
|
lineView.indicatorWidth = 41;
|
|
|
|
|
lineView.indicatorHeight = 10;
|
|
|
|
|
lineView.indicatorCornerRadius = 5;
|
|
|
|
|
lineView.verticalMargin = 10;
|
|
|
|
|
lineView.indicatorImageView.image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xFFD15A), UIColorFromRGB(0xFFC000)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(41, 10)];
|
|
|
|
|
_titleView.indicators = @[lineView];
|
|
|
|
|
}
|
|
|
|
|
return _titleView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (JXPagerView *)pagingView {
|
|
|
|
|
if (!_pagingView) {
|
|
|
|
|
_pagingView = [[JXPagerView alloc] initWithDelegate:self];
|
|
|
|
|
_pagingView.backgroundColor = [UIColor clearColor];
|
|
|
|
|
_pagingView.listContainerView.backgroundColor = [UIColor clearColor];
|
|
|
|
|
_pagingView.mainTableView.backgroundColor = [UIColor clearColor];
|
2022-03-04 11:22:31 +08:00
|
|
|
|
_pagingView.mainTableView.gestureDelegate = self;
|
2022-02-25 21:18:01 +08:00
|
|
|
|
_pagingView.listContainerView.listCellBackgroundColor = UIColor.clearColor;
|
|
|
|
|
}
|
|
|
|
|
return _pagingView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSArray<NSString *> *)titles {
|
|
|
|
|
if (!_titles) {
|
|
|
|
|
_titles = @[@"开黑畅聊", @"热门房间"];
|
|
|
|
|
}
|
|
|
|
|
return _titles;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (XPHomeRecommendHeaderView *)headerView {
|
|
|
|
|
if (!_headerView) {
|
|
|
|
|
_headerView = [[XPHomeRecommendHeaderView alloc] init];
|
|
|
|
|
_headerView.backgroundColor = [UIColor clearColor];
|
|
|
|
|
_headerView.currenViewController = self;
|
|
|
|
|
}
|
|
|
|
|
return _headerView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (XPHomeHotRoomViewController *)hotRoomVC {
|
|
|
|
|
if (!_hotRoomVC) {
|
|
|
|
|
_hotRoomVC = [[XPHomeHotRoomViewController alloc] init];
|
|
|
|
|
}
|
|
|
|
|
return _hotRoomVC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (XPHomeHappyViewController *)personalRoomVC {
|
|
|
|
|
if (!_personalRoomVC) {
|
|
|
|
|
_personalRoomVC = [[XPHomeHappyViewController alloc] init];
|
2022-02-21 20:06:09 +08:00
|
|
|
|
}
|
2022-02-25 21:18:01 +08:00
|
|
|
|
return _personalRoomVC;
|
2022-02-21 20:06:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|