2023-07-14 18:50:55 +08:00
|
|
|
|
//
|
|
|
|
|
// XPNewHomeViewController.m
|
|
|
|
|
// YuMi
|
|
|
|
|
//
|
|
|
|
|
// Created by YuMi on 2023/6/18.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "XPNewHomeViewController.h"
|
|
|
|
|
///Third
|
|
|
|
|
#import <Masonry/Masonry.h>
|
2023-09-01 18:58:41 +08:00
|
|
|
|
#import <JXPagingView/JXPagerView.h>
|
|
|
|
|
#import <JXPagingView/JXPagerListRefreshView.h>
|
2023-07-14 18:50:55 +08:00
|
|
|
|
#import <JXCategoryView/JXCategoryView.h>
|
2023-09-05 15:37:02 +08:00
|
|
|
|
#import <MJRefresh/MJRefresh.h>
|
2023-07-14 18:50:55 +08:00
|
|
|
|
///Tool
|
2023-09-05 15:37:02 +08:00
|
|
|
|
#import "Api+Home.h"
|
2023-07-14 18:50:55 +08:00
|
|
|
|
#import "YUMIMacroUitls.h"
|
|
|
|
|
#import "DJDKMIMOMColor.h"
|
|
|
|
|
#import "YUMIHtmlUrl.h"
|
|
|
|
|
#import "UIImage+Utils.h"
|
|
|
|
|
#import "AccountInfoStorage.h"
|
|
|
|
|
#import "Api+Room.h"
|
|
|
|
|
#import "TTPopup.h"
|
|
|
|
|
#import "NSArray+Safe.h"
|
2023-09-07 19:01:31 +08:00
|
|
|
|
#import "XPWeakTimer.h"
|
2023-07-14 18:50:55 +08:00
|
|
|
|
///Model
|
|
|
|
|
#import "HomeTagModel.h"
|
2023-11-20 14:25:47 +08:00
|
|
|
|
#import "AccountModel.h"
|
2023-09-01 14:29:14 +08:00
|
|
|
|
#import "XPLittleGameRoomOpenView.h"
|
2023-09-05 11:45:21 +08:00
|
|
|
|
|
|
|
|
|
#import "PIHomeItemModel.h"
|
|
|
|
|
|
2023-09-05 15:37:02 +08:00
|
|
|
|
#import "HomeMenuSourceModel.h"
|
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
///View
|
|
|
|
|
#import "XPRoomSearchContainerViewController.h"
|
|
|
|
|
#import "XPHomePartyViewController.h"
|
|
|
|
|
#import "XPWebViewController.h"
|
|
|
|
|
#import "XPHomeRecommendViewController.h"
|
|
|
|
|
#import "XPNewHomeNavView.h"
|
|
|
|
|
#import "XPRoomViewController.h"
|
2023-09-01 18:58:41 +08:00
|
|
|
|
#import "XPNewHomeHeadView.h"
|
|
|
|
|
#import "PIHoemCategoryTitleView.h"
|
2023-09-05 15:37:02 +08:00
|
|
|
|
#import "XPHomeRecommendOtherRoomView.h"
|
2023-07-14 18:50:55 +08:00
|
|
|
|
///P
|
|
|
|
|
#import "XPHomeContainerPresenter.h"
|
|
|
|
|
#import "XPHomeContainerProtocol.h"
|
2023-08-11 14:46:56 +08:00
|
|
|
|
#import "ClientConfig.h"
|
2023-08-18 10:41:30 +08:00
|
|
|
|
#import "SessionViewController.h"
|
2023-11-20 14:25:47 +08:00
|
|
|
|
#import "Api+Main.h"
|
|
|
|
|
#import "XPLoginViewController.h"
|
|
|
|
|
#import "BaseNavigationController.h"
|
|
|
|
|
#import "XPAdImageTool.h"
|
2024-02-22 15:58:48 +08:00
|
|
|
|
#import "PIHomeCategoryTitleModel.h"
|
2023-07-14 18:50:55 +08:00
|
|
|
|
UIKIT_EXTERN NSString * kHomeMoreScrollPageKey;
|
|
|
|
|
UIKIT_EXTERN NSString * const kOpenRoomNotification;
|
|
|
|
|
|
2023-09-25 16:02:57 +08:00
|
|
|
|
@interface XPNewHomeViewController ()<JXPagerViewDelegate,JXPagerMainTableViewGestureDelegate,JXCategoryViewDelegate, XPHomeContainerProtocol, XPNewHomeNavViewDelegate,XPNewHomeHeadViewDelegate,XPHomeRecommendOtherRoomViewDelegate,XPHomeRecommendViewControllerDelegate>
|
2024-05-30 19:25:03 +08:00
|
|
|
|
|
2023-09-01 15:52:10 +08:00
|
|
|
|
///背景
|
2024-06-18 17:38:13 +08:00
|
|
|
|
//@property (nonatomic,strong) UIImageView *backImageView;
|
2023-09-01 15:52:10 +08:00
|
|
|
|
///导航
|
2024-06-21 01:37:38 +08:00
|
|
|
|
//@property (nonatomic,strong) XPNewHomeNavView *navView;
|
2023-09-01 18:58:41 +08:00
|
|
|
|
///头视图
|
|
|
|
|
@property(nonatomic,strong) XPNewHomeHeadView *headView;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
///分页标题
|
2024-02-22 15:58:48 +08:00
|
|
|
|
@property (nonatomic, strong) NSMutableArray<PIHomeCategoryTitleModel *> *tagModelList;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
///分页控件
|
2024-04-17 16:02:42 +08:00
|
|
|
|
@property (nonatomic, strong) JXCategoryTitleView *titleView;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
///分页lineView
|
2023-09-01 18:58:41 +08:00
|
|
|
|
@property (nonatomic, strong) JXPagerView *pagingView;
|
2024-02-22 15:58:48 +08:00
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
@property (nonatomic,strong) HomeTagModel *recommendItem;
|
|
|
|
|
///解决弱网时首页底部出现一片空白bug
|
|
|
|
|
@property (nonatomic,assign) BOOL isEmpty;
|
2023-09-05 15:37:02 +08:00
|
|
|
|
@property(nonatomic,strong) XPHomeRecommendViewController * recommendVC;
|
2023-11-23 10:56:01 +08:00
|
|
|
|
@property(nonatomic,assign) BOOL isCheckIp;
|
2024-02-22 15:58:48 +08:00
|
|
|
|
@property(nonatomic,assign) NSInteger type;
|
|
|
|
|
@property(nonatomic,strong) NSMutableDictionary *validListDict;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation XPNewHomeViewController
|
|
|
|
|
-(instancetype)initWithIsEmpty:(BOOL)isEmpty{
|
2023-09-01 18:58:41 +08:00
|
|
|
|
self = [super init];
|
|
|
|
|
if(self){
|
|
|
|
|
self.isEmpty = isEmpty;
|
|
|
|
|
}
|
|
|
|
|
return self;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
2024-05-30 19:25:03 +08:00
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
-(void)dealloc{
|
2024-06-18 17:38:13 +08:00
|
|
|
|
[[NSNotificationCenter defaultCenter]removeObserver:self];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
2024-05-30 19:25:03 +08:00
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
- (BOOL)isHiddenNavBar {
|
2023-09-01 18:58:41 +08:00
|
|
|
|
return YES;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (XPHomeContainerPresenter *)createPresenter {
|
2023-09-01 18:58:41 +08:00
|
|
|
|
return [[XPHomeContainerPresenter alloc] init];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
2024-05-30 19:25:03 +08:00
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
- (void)viewDidLoad {
|
2023-09-01 18:58:41 +08:00
|
|
|
|
[super viewDidLoad];
|
|
|
|
|
if(self.isEmpty == NO){
|
|
|
|
|
[self initSubViews];
|
|
|
|
|
[self initSubViewConstraints];
|
2024-06-21 01:37:38 +08:00
|
|
|
|
|
|
|
|
|
[self requestCheckIp];
|
|
|
|
|
// [self.presenter getHomeAllTopsData];
|
|
|
|
|
[self.presenter getHomeTopData];
|
|
|
|
|
[self.presenter getHomeTagList];
|
2023-09-01 18:58:41 +08:00
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
2024-05-30 19:25:03 +08:00
|
|
|
|
|
2023-09-07 19:01:31 +08:00
|
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
|
|
|
[super viewWillAppear:animated];
|
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
|
2024-06-21 01:37:38 +08:00
|
|
|
|
- (void)viewDidAppear:(BOOL)animated {
|
|
|
|
|
[super viewDidAppear:animated];
|
|
|
|
|
[self.pagingView.mainTableView.mj_header beginRefreshing];
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-07 19:01:31 +08:00
|
|
|
|
- (void)viewWillDisappear:(BOOL)animated {
|
|
|
|
|
[super viewWillDisappear:animated];
|
|
|
|
|
}
|
2023-11-20 14:25:47 +08:00
|
|
|
|
|
|
|
|
|
- (void)tokenInvalid {
|
|
|
|
|
[[AccountInfoStorage instance] saveAccountInfo:nil];
|
|
|
|
|
[[AccountInfoStorage instance] saveTicket:nil];
|
|
|
|
|
if ([NIMSDK sharedSDK].loginManager.isLogined) {
|
|
|
|
|
[[NIMSDK sharedSDK].loginManager logout:nil];
|
|
|
|
|
}
|
|
|
|
|
XPLoginViewController *lvc = [[XPLoginViewController alloc] init];
|
|
|
|
|
BaseNavigationController * nav = [[BaseNavigationController alloc] initWithRootViewController:lvc];
|
|
|
|
|
nav.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
|
|
|
kWindow.rootViewController = nav;
|
|
|
|
|
XPAdImageTool.shareImageTool.isImLogin = NO;
|
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
#pragma mark - Private Method
|
2023-09-07 19:01:31 +08:00
|
|
|
|
- (void)addTimer {
|
2024-05-30 19:25:03 +08:00
|
|
|
|
// PIHomeCategoryTitleModel *tagModel = [self.tagModelList safeObjectAtIndex1:self.type];
|
|
|
|
|
// XPHomePartyViewController *homeVC = [self.validListDict objectForKey:[NSNumber numberWithInteger:self.type]];
|
|
|
|
|
// homeVC.tagModel = tagModel;
|
2023-09-07 19:01:31 +08:00
|
|
|
|
}
|
2024-05-30 19:25:03 +08:00
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
- (void)initSubViews {
|
2023-09-05 15:37:02 +08:00
|
|
|
|
self.type = 0;
|
2024-06-18 17:38:13 +08:00
|
|
|
|
self.view.backgroundColor = [UIColor clearColor];
|
|
|
|
|
// [self.view addSubview:self.backImageView];
|
|
|
|
|
// [self.view addSubview:self.navView];
|
2023-09-01 18:58:41 +08:00
|
|
|
|
[self.view addSubview:self.pagingView];
|
2023-08-11 14:46:56 +08:00
|
|
|
|
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(openRoomNotification:) name:kOpenRoomNotification object:nil];
|
2023-08-18 10:43:10 +08:00
|
|
|
|
if([[AccountInfoStorage instance] getUid].length == 0){
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-08-17 18:26:13 +08:00
|
|
|
|
if([ClientConfig shareConfig].roomId != nil){
|
|
|
|
|
[self opRoom:[ClientConfig shareConfig].roomId];
|
|
|
|
|
[ClientConfig shareConfig].roomId = nil;
|
|
|
|
|
}
|
2023-08-18 10:41:30 +08:00
|
|
|
|
if([ClientConfig shareConfig].chatId != nil){
|
|
|
|
|
NIMSession * session = [NIMSession session:[ClientConfig shareConfig].chatId type:NIMSessionTypeP2P];
|
|
|
|
|
SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:session];
|
2023-09-01 15:06:49 +08:00
|
|
|
|
sessionVC.isAttention = YES;
|
2023-08-18 10:41:30 +08:00
|
|
|
|
[self.navigationController pushViewController:sessionVC animated:YES];
|
|
|
|
|
[ClientConfig shareConfig].chatId = nil;
|
|
|
|
|
}
|
2023-09-05 15:37:02 +08:00
|
|
|
|
|
2024-02-26 17:18:21 +08:00
|
|
|
|
if([ClientConfig shareConfig].pushChatId != nil){
|
|
|
|
|
NIMSession * session = [NIMSession session:[ClientConfig shareConfig].pushChatId type:NIMSessionTypeP2P];
|
|
|
|
|
SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:session];
|
|
|
|
|
[self.navigationController pushViewController:sessionVC animated:YES];
|
|
|
|
|
[ClientConfig shareConfig].pushChatId = nil;
|
|
|
|
|
}
|
2023-09-05 15:37:02 +08:00
|
|
|
|
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 = [DJDKMIMOMColor secondTextColor];
|
|
|
|
|
header.lastUpdatedTimeLabel.textColor = [DJDKMIMOMColor secondTextColor];
|
|
|
|
|
self.pagingView.mainTableView.mj_header = header;
|
2024-03-20 19:55:26 +08:00
|
|
|
|
[ClientConfig shareConfig].inviteCode = @"";
|
2024-05-30 19:25:03 +08:00
|
|
|
|
|
2024-06-21 01:37:38 +08:00
|
|
|
|
// [self.pagingView.mainTableView.mj_header beginRefreshing];
|
2023-09-05 15:37:02 +08:00
|
|
|
|
@kWeakify(self);
|
|
|
|
|
self.recommendVC.refreshComplete = ^{
|
|
|
|
|
@kStrongify(self);
|
2024-05-30 19:25:03 +08:00
|
|
|
|
[self.pagingView.mainTableView.mj_header endRefreshing];
|
2023-09-05 15:37:02 +08:00
|
|
|
|
};
|
2024-05-30 19:25:03 +08:00
|
|
|
|
|
2024-02-22 15:58:48 +08:00
|
|
|
|
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(homeVCRefreshComplete) name:@"khomeVCRefreshComplete" object:nil];
|
2023-11-23 10:56:01 +08:00
|
|
|
|
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(logOut) name:@"kInLoginVC" object:nil];
|
2024-02-22 15:58:48 +08:00
|
|
|
|
}
|
|
|
|
|
-(void)homeVCRefreshComplete{
|
|
|
|
|
[self.pagingView.mainTableView.mj_header endRefreshing];
|
|
|
|
|
[self.pagingView.mainTableView.mj_footer endRefreshing];
|
2023-11-23 10:56:01 +08:00
|
|
|
|
}
|
|
|
|
|
-(void)logOut{
|
|
|
|
|
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(requestCheckIp) object:nil];
|
2023-09-05 15:37:02 +08:00
|
|
|
|
}
|
|
|
|
|
-(void)headerRefresh{
|
2024-06-21 01:37:38 +08:00
|
|
|
|
[self.presenter getHomeTopData];
|
|
|
|
|
[self.presenter getHomeRanks];
|
2024-05-30 19:25:03 +08:00
|
|
|
|
|
2024-06-16 16:18:06 +08:00
|
|
|
|
PIHomeCategoryTitleModel *tagModel = [self.tagModelList xpSafeObjectAtIndex:self.type];
|
2024-05-30 19:25:03 +08:00
|
|
|
|
XPHomePartyViewController *homeVC = [self.validListDict objectForKey:[NSNumber numberWithInteger:self.type]];
|
|
|
|
|
homeVC.tagModel = tagModel;
|
2023-08-11 14:46:56 +08:00
|
|
|
|
}
|
2024-02-22 15:58:48 +08:00
|
|
|
|
|
2023-08-11 14:46:56 +08:00
|
|
|
|
-(void)openRoomNotification:(NSNotification *)notification{
|
2023-08-18 10:43:10 +08:00
|
|
|
|
if([[AccountInfoStorage instance] getUid].length == 0){
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-08-11 14:46:56 +08:00
|
|
|
|
NSString *uid = notification.userInfo[@"uid"];
|
2023-08-18 10:41:30 +08:00
|
|
|
|
NSString *type = notification.userInfo[@"type"];
|
2024-02-21 10:18:59 +08:00
|
|
|
|
BOOL isNoAttention = [notification.userInfo[@"isNoAttention"] boolValue];
|
2023-08-18 10:41:30 +08:00
|
|
|
|
if([type isEqualToString:@"kOpenChat"]){
|
|
|
|
|
if (uid.length > 0) {
|
|
|
|
|
NIMSession * session = [NIMSession session:uid type:NIMSessionTypeP2P];
|
|
|
|
|
SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:session];
|
2024-02-21 10:18:59 +08:00
|
|
|
|
sessionVC.isAttention = !isNoAttention;
|
2023-08-18 10:41:30 +08:00
|
|
|
|
[self.navigationController pushViewController:sessionVC animated:YES];
|
2024-02-27 10:40:48 +08:00
|
|
|
|
if(isNoAttention == YES){
|
|
|
|
|
[ClientConfig shareConfig].pushChatId = nil;
|
|
|
|
|
}else{
|
|
|
|
|
[ClientConfig shareConfig].chatId = nil;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-18 10:41:30 +08:00
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClientConfig *config = [ClientConfig shareConfig];
|
|
|
|
|
config.chatId = uid;
|
2023-08-11 14:46:56 +08:00
|
|
|
|
if(uid != nil){
|
|
|
|
|
[self opRoom:uid];
|
2023-08-18 10:41:30 +08:00
|
|
|
|
[ClientConfig shareConfig].roomId = nil;
|
2023-08-11 14:46:56 +08:00
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
- (void)initSubViewConstraints {
|
2024-06-18 17:38:13 +08:00
|
|
|
|
// [self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
// make.leading.trailing.top.mas_equalTo(self.view);
|
|
|
|
|
// make.height.mas_equalTo(kGetScaleWidth(223));
|
|
|
|
|
// }];
|
|
|
|
|
//
|
|
|
|
|
// [self.navView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
// make.leading.trailing.top.mas_equalTo(self.view);
|
|
|
|
|
// make.height.mas_equalTo(kNavigationHeight);
|
|
|
|
|
// }];
|
2024-05-30 19:25:03 +08:00
|
|
|
|
|
2023-09-01 18:58:41 +08:00
|
|
|
|
[self.pagingView mas_makeConstraints:^(MASConstraintMaker *make) {
|
2024-06-18 17:38:13 +08:00
|
|
|
|
make.top.equalTo(self.view).mas_offset(kGetScaleWidth(10));
|
2023-09-01 18:58:41 +08:00
|
|
|
|
make.leading.bottom.trailing.mas_equalTo(0);
|
|
|
|
|
}];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - XPNewHomeNavViewDelegate
|
|
|
|
|
- (void)xPNewHomeNavView:(XPNewHomeNavView *)view didClickRank:(UIButton *)sender {
|
2023-09-01 18:58:41 +08:00
|
|
|
|
XPWebViewController * webVC =[[XPWebViewController alloc] init];
|
|
|
|
|
webVC.url = URLWithType(kHomeRankURL);
|
|
|
|
|
[self.navigationController pushViewController:webVC animated:YES];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)xPNewHomeNavView:(XPNewHomeNavView *)view didClickOpenRoom:(UIButton *)sender {
|
2023-09-01 18:58:41 +08:00
|
|
|
|
NSString* roomUid = [AccountInfoStorage instance].getUid;
|
|
|
|
|
[self opRoom:roomUid];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
2024-05-30 19:25:03 +08:00
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
-(void)opRoom:(NSString *)roomUid{
|
2023-09-01 18:58:41 +08:00
|
|
|
|
|
2023-09-01 14:29:14 +08:00
|
|
|
|
[Api getRoomInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
2023-11-20 14:25:47 +08:00
|
|
|
|
if(code == 401){
|
|
|
|
|
[self tokenInvalid];
|
|
|
|
|
[self showErrorToast:msg];
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-09-01 14:29:14 +08:00
|
|
|
|
if (code == 200) {
|
|
|
|
|
RoomInfoModel * roomInfo = [RoomInfoModel modelWithJSON:data.data];
|
|
|
|
|
if (roomInfo.isReselect) {
|
|
|
|
|
XPLittleGameRoomOpenView * roomOpenView = [[XPLittleGameRoomOpenView alloc] init];
|
|
|
|
|
roomOpenView.roomInfo = roomInfo;
|
|
|
|
|
roomOpenView.currentVC = self;
|
|
|
|
|
[TTPopup popupView:roomOpenView style:TTPopupStyleActionSheet];
|
|
|
|
|
} else {
|
|
|
|
|
[XPRoomViewController openRoom:roomUid viewController:self];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2023-11-20 14:25:47 +08:00
|
|
|
|
|
2023-09-01 14:29:14 +08:00
|
|
|
|
[self showErrorToast:msg];
|
|
|
|
|
}
|
|
|
|
|
} uid:roomUid intoUid:roomUid];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)xPNewHomeNavView:(XPNewHomeNavView *)view didClickSearch:(UIView *)sender {
|
2023-09-01 18:58:41 +08:00
|
|
|
|
XPRoomSearchContainerViewController * searchVC = [[XPRoomSearchContainerViewController alloc] init];
|
|
|
|
|
searchVC.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
|
|
|
[self.navigationController presentViewController:searchVC animated:YES completion:nil];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
2023-09-25 16:02:57 +08:00
|
|
|
|
#pragma mark - XPHomeRecommendViewControllerDelegate
|
|
|
|
|
-(void)openRoom{
|
|
|
|
|
NSString* roomUid = [AccountInfoStorage instance].getUid;
|
|
|
|
|
[self opRoom:roomUid];
|
|
|
|
|
}
|
2023-09-01 18:58:41 +08:00
|
|
|
|
#pragma mark - JXCategoryViewDelegate
|
|
|
|
|
- (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
|
2024-06-21 01:37:38 +08:00
|
|
|
|
|
2024-04-24 20:08:24 +08:00
|
|
|
|
if (self.headView.itemList.count == 0 && self.headView.bannerList.count == 0){
|
|
|
|
|
return 0;
|
|
|
|
|
}else if (self.headView.itemList.count > 0 && self.headView.bannerList.count == 0){
|
|
|
|
|
return kGetScaleWidth(80);
|
|
|
|
|
}else if (self.headView.itemList.count == 0 && self.headView.bannerList.count > 0){
|
|
|
|
|
return kGetScaleWidth(90);
|
|
|
|
|
}
|
2023-09-21 17:44:59 +08:00
|
|
|
|
return kGetScaleWidth(170);
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-01 18:58:41 +08:00
|
|
|
|
- (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
|
|
|
|
|
return self.headView;
|
|
|
|
|
}
|
|
|
|
|
- (NSUInteger)heightForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
|
2024-04-17 16:02:42 +08:00
|
|
|
|
return kGetScaleWidth(50);
|
2023-09-01 18:58:41 +08:00
|
|
|
|
}
|
|
|
|
|
- (UIView *)viewForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
|
|
|
|
|
return self.titleView;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-01 18:58:41 +08:00
|
|
|
|
- (NSInteger)numberOfListsInPagerView:(JXPagerView *)pagerView {
|
2024-02-22 15:58:48 +08:00
|
|
|
|
return self.tagModelList.count;
|
2023-09-01 18:58:41 +08:00
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
|
2023-09-01 18:58:41 +08:00
|
|
|
|
- (id<JXPagerViewListViewDelegate>)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index {
|
2024-05-30 19:25:03 +08:00
|
|
|
|
id homeV = [self.validListDict objectForKey:[NSNumber numberWithInteger:index]];
|
|
|
|
|
if (homeV) {
|
|
|
|
|
return homeV;
|
|
|
|
|
}
|
|
|
|
|
XPHomePartyViewController *homeVC = [[XPHomePartyViewController alloc] init];
|
2024-06-16 16:18:06 +08:00
|
|
|
|
homeVC.tagModel = [self.tagModelList xpSafeObjectAtIndex:index];
|
2024-05-30 19:25:03 +08:00
|
|
|
|
[self.validListDict setObject:homeVC forKey:@(index)];
|
|
|
|
|
return homeVC;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - JXCategoryListContentViewDelegate
|
|
|
|
|
- (UIView *)listView {
|
2023-09-01 18:58:41 +08:00
|
|
|
|
return self.view;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-01 18:58:41 +08:00
|
|
|
|
|
|
|
|
|
#pragma mark - JXPagerMainTableViewGestureDelegate
|
|
|
|
|
- (BOOL)mainTableViewGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
|
|
|
|
|
//禁止categoryView左右滑动的时候,上下和左右都可以滚动
|
|
|
|
|
if (otherGestureRecognizer.view == self.pagingView.listContainerView) {
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
if(otherGestureRecognizer.view.tag == 9000001){
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
if(otherGestureRecognizer.view.tag == 9000002){
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
2024-04-17 16:02:42 +08:00
|
|
|
|
|
2024-02-22 15:58:48 +08:00
|
|
|
|
if(otherGestureRecognizer.view.tag == 98777){
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
2024-05-30 19:25:03 +08:00
|
|
|
|
|
2023-09-01 18:58:41 +08:00
|
|
|
|
return [gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]];
|
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
#pragma mark - XPHomeContainerProtocol
|
2024-04-24 20:08:24 +08:00
|
|
|
|
- (void)getHomeTopDataSuccess:(NSArray*)list menuList:(NSArray *)memuList{
|
|
|
|
|
self.headView.itemList = memuList;
|
2023-09-01 18:58:41 +08:00
|
|
|
|
self.headView.bannerList = list;
|
|
|
|
|
[self.pagingView reloadData];
|
2023-09-04 10:29:16 +08:00
|
|
|
|
[self.pagingView resizeTableHeaderViewHeightWithAnimatable:NO duration:0 curve:0];
|
2023-09-01 18:58:41 +08:00
|
|
|
|
}
|
2024-04-24 20:08:24 +08:00
|
|
|
|
|
2024-06-21 01:37:38 +08:00
|
|
|
|
- (void)getHomeTopDataSuccess:(NSArray *)resourceList
|
|
|
|
|
banners:(NSArray *)banners
|
|
|
|
|
rankAvatars:(NSArray *)rankAvatars {
|
|
|
|
|
self.headView.itemList = resourceList;
|
|
|
|
|
self.headView.bannerList = banners;
|
|
|
|
|
self.headView.rankAvatars = rankAvatars;
|
|
|
|
|
[self.pagingView reloadData];
|
|
|
|
|
[self.pagingView resizeTableHeaderViewHeightWithAnimatable:NO duration:0 curve:0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)getHomeRanksSuccess:(NSArray *)resourceList
|
|
|
|
|
{
|
|
|
|
|
self.headView.rankAvatars = resourceList;
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-22 15:58:48 +08:00
|
|
|
|
///获取所有的tag成功
|
|
|
|
|
- (void)getHomeTagListSuccess:(NSArray<PIHomeCategoryTitleModel *> *)array{
|
2024-06-21 01:37:38 +08:00
|
|
|
|
if(array.count == 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-04-10 17:39:37 +08:00
|
|
|
|
NSMutableArray *list = [NSMutableArray new];
|
2024-02-22 15:58:48 +08:00
|
|
|
|
NSMutableArray *titleArray = [NSMutableArray array];
|
2024-04-10 17:39:37 +08:00
|
|
|
|
for (PIHomeCategoryTitleModel *model in array) {
|
2024-05-30 19:25:03 +08:00
|
|
|
|
if (model.isHomeRecommend == YES){
|
2024-04-10 17:39:37 +08:00
|
|
|
|
[list insertObject:model atIndex:0];
|
|
|
|
|
[titleArray insertObject:model.name atIndex:0];
|
|
|
|
|
}else{
|
|
|
|
|
[list addObject:model];
|
|
|
|
|
[titleArray addObject:model.name];
|
|
|
|
|
}
|
2024-02-22 15:58:48 +08:00
|
|
|
|
}
|
2024-04-10 17:39:37 +08:00
|
|
|
|
self.tagModelList = list;
|
2024-04-17 16:02:42 +08:00
|
|
|
|
|
2024-02-22 15:58:48 +08:00
|
|
|
|
self.titleView.titles = titleArray;
|
|
|
|
|
[self.titleView reloadData];
|
2024-04-17 16:02:42 +08:00
|
|
|
|
|
2024-02-22 15:58:48 +08:00
|
|
|
|
}
|
2023-09-05 15:37:02 +08:00
|
|
|
|
- (void)homeChatPickSuccess:(NSString *)uid {
|
|
|
|
|
/// 跳聊天
|
|
|
|
|
NSString *sessionId = uid;
|
|
|
|
|
NIMSession *session = [NIMSession session:sessionId type:NIMSessionTypeP2P];
|
|
|
|
|
SessionViewController *sessionVC = [[SessionViewController alloc] initWithSession:session];
|
|
|
|
|
[self.navigationController pushViewController:sessionVC animated:YES];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)homeChatPickFail:(NSString *)msg {
|
|
|
|
|
|
2023-09-01 18:58:41 +08:00
|
|
|
|
}
|
2023-09-25 16:02:57 +08:00
|
|
|
|
|
2023-09-01 18:58:41 +08:00
|
|
|
|
- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index{
|
2024-02-22 15:58:48 +08:00
|
|
|
|
self.type = index;
|
2023-09-05 11:45:21 +08:00
|
|
|
|
}
|
2023-09-25 16:02:57 +08:00
|
|
|
|
|
2023-09-05 11:45:21 +08:00
|
|
|
|
#pragma mark - XPNewHomeHeadViewDelegate
|
2023-11-23 10:56:01 +08:00
|
|
|
|
///
|
|
|
|
|
-(void)checkIpRegionSuccess:(NSInteger)seconds{
|
|
|
|
|
if(seconds <= 0)return;
|
|
|
|
|
[self performSelector:@selector(requestCheckIp) withObject:nil afterDelay:seconds];
|
|
|
|
|
}
|
|
|
|
|
- (void)checkIpRegionFailWithMsg:(NSString *)msg{
|
|
|
|
|
[self tokenInvalid];
|
|
|
|
|
[self showErrorToast:msg];
|
|
|
|
|
}
|
|
|
|
|
-(void)requestCheckIp{
|
2024-06-21 01:37:38 +08:00
|
|
|
|
if([AccountInfoStorage instance].getTicket.length > 0 &&
|
|
|
|
|
[AccountInfoStorage instance].name.length > 0){
|
2023-11-23 10:56:01 +08:00
|
|
|
|
[self.presenter checkIpRegionAction];
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-09-05 11:45:21 +08:00
|
|
|
|
///选择
|
|
|
|
|
-(void)selectItemWithModel:(PIHomeItemModel *)model{
|
|
|
|
|
if (model.resourceType == HomeMenuResourceType_H5) {
|
|
|
|
|
XPWebViewController * webVC = [[ XPWebViewController alloc] init];
|
|
|
|
|
webVC.url = model.resourceContent;
|
|
|
|
|
[self.navigationController pushViewController:webVC animated:YES];
|
2023-09-05 15:37:02 +08:00
|
|
|
|
}else if (model.resourceType == HomeMenuResourceType_Match) { // 一键匹配的
|
|
|
|
|
[self.presenter homeChatPick];
|
|
|
|
|
}else {
|
|
|
|
|
NSString * uid = [AccountInfoStorage instance].getUid;
|
|
|
|
|
if (model.ID.length > 0 && uid.length > 0) {
|
|
|
|
|
[Api homePickResource:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
|
|
|
|
if (code == 200) {
|
|
|
|
|
HomeMenuSourceModel * sourceModel = [HomeMenuSourceModel modelWithDictionary:data.data];
|
|
|
|
|
if (sourceModel.isPick) {
|
|
|
|
|
if (sourceModel.uid.integerValue > 0) {
|
|
|
|
|
[XPRoomViewController openRoom:sourceModel.uid fromNick:nil fromType:UserEnterRoomFromType_Home_Recommend fromUid:nil viewController:self];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
XPHomeRecommendOtherRoomView * recommendView = [[XPHomeRecommendOtherRoomView alloc] init];
|
|
|
|
|
recommendView.delegate = self;
|
|
|
|
|
recommendView.roomInfo = sourceModel;
|
|
|
|
|
[TTPopup popupView:recommendView style:TTPopupStyleAlert];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
[XNDJTDDLoadingTool showErrorWithMessage:msg];
|
|
|
|
|
}
|
|
|
|
|
} uid:uid rid:model.ID];
|
|
|
|
|
}
|
2023-09-05 11:45:21 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
-(void)selectBannerListWithModel:(HomeBannerInfoModel *)model{
|
|
|
|
|
switch (model.skipType) {
|
|
|
|
|
case HomeBannerInfoSkipType_Room:
|
|
|
|
|
{
|
|
|
|
|
if (model.skipUri.length > 0) {
|
|
|
|
|
[XPRoomViewController openRoom:model.skipUri viewController:self];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case HomeBannerInfoSkipType_Web:
|
|
|
|
|
{
|
|
|
|
|
XPWebViewController *vc = [[XPWebViewController alloc]init];
|
|
|
|
|
vc.url = model.skipUri;
|
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
2023-09-05 15:37:02 +08:00
|
|
|
|
///点击了进入房间
|
|
|
|
|
- (void)xPHomeRecommendOtherRoomView:(XPHomeRecommendOtherRoomView *)view didClickEnterRoom:(HomeMenuSourceModel *)model{
|
|
|
|
|
if (model.uid.integerValue > 0) {
|
|
|
|
|
[XPRoomViewController openRoom:model.uid fromNick:nil fromType:UserEnterRoomFromType_Home_Recommend fromUid:nil viewController:self];
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-09-25 16:02:57 +08:00
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
#pragma mark - Getters And Setters
|
2024-04-17 16:02:42 +08:00
|
|
|
|
- (JXCategoryTitleView *)titleView {
|
2023-09-01 18:58:41 +08:00
|
|
|
|
if (!_titleView) {
|
2024-04-17 16:02:42 +08:00
|
|
|
|
_titleView = [[JXCategoryTitleView alloc] initWithFrame:CGRectZero];
|
2023-09-01 18:58:41 +08:00
|
|
|
|
_titleView.delegate = self;
|
2024-04-10 17:39:37 +08:00
|
|
|
|
_titleView.titles = @[];
|
2023-09-01 18:58:41 +08:00
|
|
|
|
_titleView.backgroundColor = [UIColor clearColor];
|
2024-04-17 16:02:42 +08:00
|
|
|
|
_titleView.titleColor = UIColorFromRGB(0x767585);
|
2024-06-21 01:37:38 +08:00
|
|
|
|
_titleView.titleSelectedColor = UIColorFromRGB(0x1E1E1E);
|
|
|
|
|
_titleView.titleFont = kFontBold(14);
|
|
|
|
|
_titleView.titleSelectedFont = kFontBold(14);
|
2023-09-05 11:45:21 +08:00
|
|
|
|
_titleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyleCenter;
|
2023-09-01 18:58:41 +08:00
|
|
|
|
_titleView.contentScrollViewClickTransitionAnimationEnabled = NO;
|
|
|
|
|
_titleView.defaultSelectedIndex = 0;
|
2024-06-21 01:37:38 +08:00
|
|
|
|
|
2024-04-17 16:02:42 +08:00
|
|
|
|
_titleView.cellSpacing = kGetScaleWidth(20);
|
|
|
|
|
|
2023-09-01 18:58:41 +08:00
|
|
|
|
_titleView.listContainer = (id<JXCategoryViewListContainer>)self.pagingView.listContainerView;
|
|
|
|
|
|
2024-06-21 01:37:38 +08:00
|
|
|
|
JXCategoryIndicatorImageView * indicator = [[JXCategoryIndicatorImageView alloc] init];
|
2024-07-02 18:54:42 +08:00
|
|
|
|
indicator.indicatorImageView.image = kImage(@"ms_login_choose_phone_icon");
|
2024-06-21 01:37:38 +08:00
|
|
|
|
indicator.indicatorImageViewSize = CGSizeMake(kGetScaleWidth(24), kGetScaleWidth(24));
|
|
|
|
|
indicator.verticalMargin = -kGetScaleWidth(4);
|
|
|
|
|
indicator.contentMode = UIViewContentModeScaleAspectFit;
|
|
|
|
|
_titleView.indicators = @[indicator];
|
2023-09-01 18:58:41 +08:00
|
|
|
|
}
|
|
|
|
|
return _titleView;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
2024-02-22 15:58:48 +08:00
|
|
|
|
|
|
|
|
|
- (NSMutableArray<PIHomeCategoryTitleModel *> *)tagModelList{
|
|
|
|
|
if(!_tagModelList){
|
|
|
|
|
_tagModelList = [NSMutableArray array];
|
2023-09-01 18:58:41 +08:00
|
|
|
|
}
|
2024-02-22 15:58:48 +08:00
|
|
|
|
return _tagModelList;
|
2023-09-01 18:58:41 +08:00
|
|
|
|
}
|
|
|
|
|
- (JXPagerView *)pagingView {
|
|
|
|
|
if (!_pagingView) {
|
|
|
|
|
_pagingView = [[JXPagerView alloc] initWithDelegate:self listContainerType:0];
|
|
|
|
|
_pagingView.mainTableView.gestureDelegate = self;
|
|
|
|
|
_pagingView.backgroundColor = [UIColor clearColor];
|
|
|
|
|
_pagingView.listContainerView.backgroundColor = [UIColor clearColor];
|
|
|
|
|
_pagingView.listContainerView.listCellBackgroundColor = [UIColor clearColor];
|
|
|
|
|
_pagingView.mainTableView.backgroundColor = [UIColor clearColor];
|
|
|
|
|
}
|
|
|
|
|
return _pagingView;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
- (HomeTagModel *)recommendItem {
|
2023-09-01 18:58:41 +08:00
|
|
|
|
if (!_recommendItem) {
|
|
|
|
|
_recommendItem = [[HomeTagModel alloc] init];
|
|
|
|
|
_recommendItem.name = YMLocalizedString(@"XPNewHomeViewController3");
|
|
|
|
|
}
|
|
|
|
|
return _recommendItem;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-22 15:58:48 +08:00
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
|
2024-06-21 01:37:38 +08:00
|
|
|
|
//- (XPNewHomeNavView *)navView {
|
|
|
|
|
// if (!_navView) {
|
|
|
|
|
// _navView = [[XPNewHomeNavView alloc] init];
|
|
|
|
|
// _navView.delegate = self;
|
|
|
|
|
// }
|
|
|
|
|
// return _navView;
|
|
|
|
|
//}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
|
2024-06-18 17:38:13 +08:00
|
|
|
|
//- (UIImageView *)backImageView {
|
|
|
|
|
// if (!_backImageView) {
|
|
|
|
|
// _backImageView = [[UIImageView alloc] init];
|
|
|
|
|
// _backImageView.image = [UIImage imageNamed:@"home_top_bg"];
|
|
|
|
|
// _backImageView.layer.masksToBounds = YES;
|
|
|
|
|
// _backImageView.contentMode = UIViewContentModeScaleAspectFill;
|
|
|
|
|
// }
|
|
|
|
|
// return _backImageView;
|
|
|
|
|
//}
|
|
|
|
|
|
2023-09-01 18:58:41 +08:00
|
|
|
|
- (XPNewHomeHeadView *)headView{
|
|
|
|
|
if(!_headView){
|
|
|
|
|
_headView = [[XPNewHomeHeadView alloc]initWithFrame:CGRectZero];
|
2023-09-05 11:45:21 +08:00
|
|
|
|
_headView.delegate = self;
|
2023-09-01 18:58:41 +08:00
|
|
|
|
}
|
|
|
|
|
return _headView;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
2024-02-22 15:58:48 +08:00
|
|
|
|
|
2023-09-05 15:37:02 +08:00
|
|
|
|
- (XPHomeRecommendViewController *)recommendVC{
|
|
|
|
|
if(!_recommendVC){
|
|
|
|
|
_recommendVC = [[XPHomeRecommendViewController alloc] init];
|
2023-09-25 16:02:57 +08:00
|
|
|
|
_recommendVC.delegate = self;
|
2023-09-05 15:37:02 +08:00
|
|
|
|
}
|
|
|
|
|
return _recommendVC;
|
|
|
|
|
}
|
2024-02-22 15:58:48 +08:00
|
|
|
|
- (NSMutableDictionary *)validListDict{
|
|
|
|
|
if(!_validListDict){
|
|
|
|
|
_validListDict = [NSMutableDictionary dictionary];
|
|
|
|
|
}
|
|
|
|
|
return _validListDict;
|
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
@end
|