634 lines
23 KiB
Objective-C
634 lines
23 KiB
Objective-C
//
|
||
// XPNewHomeViewController.m
|
||
// YuMi
|
||
//
|
||
// Created by YuMi on 2023/6/18.
|
||
//
|
||
|
||
#import "XPNewHomeViewController.h"
|
||
///Third
|
||
#import <Masonry/Masonry.h>
|
||
#import <JXPagingView/JXPagerView.h>
|
||
#import <JXPagingView/JXPagerListRefreshView.h>
|
||
#import <JXCategoryView/JXCategoryView.h>
|
||
#import <MJRefresh/MJRefresh.h>
|
||
///Tool
|
||
#import "Api+Home.h"
|
||
#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"
|
||
#import "XPWeakTimer.h"
|
||
///Model
|
||
#import "HomeTagModel.h"
|
||
#import "AccountModel.h"
|
||
#import "XPLittleGameRoomOpenView.h"
|
||
|
||
#import "PIHomeItemModel.h"
|
||
|
||
#import "HomeMenuSourceModel.h"
|
||
|
||
///View
|
||
#import "XPRoomSearchContainerViewController.h"
|
||
#import "XPHomePartyViewController.h"
|
||
#import "XPWebViewController.h"
|
||
#import "XPHomeRecommendViewController.h"
|
||
#import "XPNewHomeNavView.h"
|
||
#import "XPRoomViewController.h"
|
||
#import "XPNewHomeHeadView.h"
|
||
#import "PIHoemCategoryTitleView.h"
|
||
#import "XPHomeRecommendOtherRoomView.h"
|
||
///P
|
||
#import "XPHomeContainerPresenter.h"
|
||
#import "XPHomeContainerProtocol.h"
|
||
#import "ClientConfig.h"
|
||
#import "SessionViewController.h"
|
||
#import "Api+Main.h"
|
||
#import "XPLoginViewController.h"
|
||
#import "BaseNavigationController.h"
|
||
#import "XPAdImageTool.h"
|
||
#import "PIHomeCategoryTitleModel.h"
|
||
UIKIT_EXTERN NSString * kHomeMoreScrollPageKey;
|
||
UIKIT_EXTERN NSString * const kOpenRoomNotification;
|
||
|
||
@interface XPNewHomeViewController ()<JXPagerViewDelegate,JXPagerMainTableViewGestureDelegate,JXCategoryViewDelegate, XPHomeContainerProtocol, XPNewHomeNavViewDelegate,XPNewHomeHeadViewDelegate,XPHomeRecommendOtherRoomViewDelegate,XPHomeRecommendViewControllerDelegate>
|
||
{
|
||
NSTimer * timer;
|
||
}
|
||
///背景
|
||
@property (nonatomic,strong) UIImageView *backImageView;
|
||
///导航
|
||
@property (nonatomic,strong) XPNewHomeNavView *navView;
|
||
///头视图
|
||
@property(nonatomic,strong) XPNewHomeHeadView *headView;
|
||
///分页标题
|
||
@property (nonatomic, strong) NSMutableArray<PIHomeCategoryTitleModel *> *tagModelList;
|
||
///分页控件
|
||
@property (nonatomic, strong) PIHoemCategoryTitleView *titleView;
|
||
///分页lineView
|
||
@property (nonatomic, strong) JXPagerView *pagingView;
|
||
|
||
@property (nonatomic,strong) HomeTagModel *recommendItem;
|
||
///解决弱网时首页底部出现一片空白bug
|
||
@property (nonatomic,assign) BOOL isEmpty;
|
||
@property(nonatomic,strong) XPHomeRecommendViewController * recommendVC;
|
||
@property(nonatomic,assign) BOOL isCheckIp;
|
||
@property(nonatomic,assign) NSInteger type;
|
||
@property(nonatomic,strong) NSMutableDictionary *validListDict;
|
||
@end
|
||
|
||
@implementation XPNewHomeViewController
|
||
-(instancetype)initWithIsEmpty:(BOOL)isEmpty{
|
||
self = [super init];
|
||
if(self){
|
||
self.isEmpty = isEmpty;
|
||
}
|
||
return self;
|
||
}
|
||
-(void)dealloc{
|
||
[[NSNotificationCenter defaultCenter]removeObserver:self];
|
||
[timer fire];
|
||
timer = nil;
|
||
|
||
}
|
||
- (BOOL)isHiddenNavBar {
|
||
return YES;
|
||
}
|
||
|
||
- (XPHomeContainerPresenter *)createPresenter {
|
||
return [[XPHomeContainerPresenter alloc] init];
|
||
}
|
||
- (void)viewDidLoad {
|
||
[super viewDidLoad];
|
||
if(self.isEmpty == NO){
|
||
[self.presenter getHomeTagList];
|
||
[self initHttp];
|
||
[self initSubViews];
|
||
[self initSubViewConstraints];
|
||
[self addTimer];
|
||
}
|
||
|
||
|
||
}
|
||
- (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]]; //很远的将来
|
||
}
|
||
}
|
||
|
||
|
||
- (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;
|
||
}
|
||
#pragma mark - Private Method
|
||
- (void)addTimer {
|
||
@kWeakify(self);
|
||
timer = [XPWeakTimer scheduledTimerWithTimeInterval:15 block:^(id userInfo) {
|
||
@kStrongify(self);
|
||
PIHomeCategoryTitleModel *tagModel = [self.tagModelList safeObjectAtIndex1:self.type];
|
||
XPHomePartyViewController *homeVC = [self.validListDict objectForKey:[NSNumber numberWithInteger:self.type]];
|
||
homeVC.tagModel = tagModel;
|
||
[self.recommendVC headerRefresh];
|
||
} userInfo:nil repeats:YES];
|
||
}
|
||
- (void)initSubViews {
|
||
self.type = 0;
|
||
self.view.backgroundColor = [DJDKMIMOMColor colorWithHexString:@"#F3F5FA"];
|
||
[self.view addSubview:self.backImageView];
|
||
[self.view addSubview:self.navView];
|
||
[self.view addSubview:self.pagingView];
|
||
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(openRoomNotification:) name:kOpenRoomNotification object:nil];
|
||
if([[AccountInfoStorage instance] getUid].length == 0){
|
||
return;
|
||
}
|
||
if([ClientConfig shareConfig].roomId != nil){
|
||
[self opRoom:[ClientConfig shareConfig].roomId];
|
||
[ClientConfig shareConfig].roomId = nil;
|
||
}
|
||
if([ClientConfig shareConfig].chatId != nil){
|
||
NIMSession * session = [NIMSession session:[ClientConfig shareConfig].chatId type:NIMSessionTypeP2P];
|
||
SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:session];
|
||
sessionVC.isAttention = YES;
|
||
[self.navigationController pushViewController:sessionVC animated:YES];
|
||
[ClientConfig shareConfig].chatId = nil;
|
||
}
|
||
|
||
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;
|
||
}
|
||
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;
|
||
|
||
|
||
|
||
|
||
|
||
|
||
[self.pagingView.mainTableView.mj_header beginRefreshing];
|
||
@kWeakify(self);
|
||
|
||
self.recommendVC.refreshComplete = ^{
|
||
@kStrongify(self);
|
||
[self.pagingView.mainTableView.mj_header endRefreshing];
|
||
|
||
};
|
||
self.titleView.scrolledHandle = ^(NSInteger type) {
|
||
@kStrongify(self);
|
||
[self.titleView.listContainer didClickSelectedItemAtIndex:type];
|
||
self.pagingView.listContainerView.scrollView.contentOffset = CGPointMake(type * KScreenWidth, 0);
|
||
self.type = type;
|
||
};
|
||
|
||
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(homeVCRefreshComplete) name:@"khomeVCRefreshComplete" object:nil];
|
||
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(logOut) name:@"kInLoginVC" object:nil];
|
||
|
||
|
||
}
|
||
-(void)homeVCRefreshComplete{
|
||
[self.pagingView.mainTableView.mj_header endRefreshing];
|
||
[self.pagingView.mainTableView.mj_footer endRefreshing];
|
||
}
|
||
-(void)logOut{
|
||
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(requestCheckIp) object:nil];
|
||
}
|
||
-(void)headerRefresh{
|
||
[self initHttp];
|
||
if(self.titleView.index == self.tagModelList.count - 1){
|
||
[self.recommendVC headerRefresh];
|
||
}else{
|
||
PIHomeCategoryTitleModel *tagModel = [self.tagModelList safeObjectAtIndex1:self.type];
|
||
XPHomePartyViewController *homeVC = [self.validListDict objectForKey:[NSNumber numberWithInteger:self.type]];
|
||
homeVC.tagModel = tagModel;
|
||
|
||
|
||
}
|
||
}
|
||
|
||
-(void)openRoomNotification:(NSNotification *)notification{
|
||
if([[AccountInfoStorage instance] getUid].length == 0){
|
||
return;
|
||
}
|
||
NSString *uid = notification.userInfo[@"uid"];
|
||
NSString *type = notification.userInfo[@"type"];
|
||
BOOL isNoAttention = [notification.userInfo[@"isNoAttention"] boolValue];
|
||
if([type isEqualToString:@"kOpenChat"]){
|
||
if (uid.length > 0) {
|
||
NIMSession * session = [NIMSession session:uid type:NIMSessionTypeP2P];
|
||
SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:session];
|
||
sessionVC.isAttention = !isNoAttention;
|
||
[self.navigationController pushViewController:sessionVC animated:YES];
|
||
[ClientConfig shareConfig].chatId = nil;
|
||
}
|
||
return;
|
||
}
|
||
|
||
ClientConfig *config = [ClientConfig shareConfig];
|
||
config.chatId = uid;
|
||
if(uid != nil){
|
||
[self opRoom:uid];
|
||
[ClientConfig shareConfig].roomId = nil;
|
||
}
|
||
}
|
||
- (void)initSubViewConstraints {
|
||
|
||
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.right.top.mas_equalTo(self.view);
|
||
make.height.mas_equalTo(170 + kSafeAreaTopHeight);
|
||
}];
|
||
|
||
[self.navView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.right.top.mas_equalTo(self.view);
|
||
make.height.mas_equalTo(kNavigationHeight);
|
||
}];
|
||
|
||
|
||
[self.pagingView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.top.equalTo(self.navView.mas_bottom).mas_offset(kGetScaleWidth(10));
|
||
make.leading.bottom.trailing.mas_equalTo(0);
|
||
}];
|
||
|
||
}
|
||
|
||
- (void)initHttp {
|
||
|
||
[self.presenter getHomeTopBannerList];
|
||
[self.presenter getCurrentResourceList];
|
||
[self requestCheckIp];
|
||
|
||
|
||
}
|
||
|
||
|
||
#pragma mark - XPNewHomeNavViewDelegate
|
||
- (void)xPNewHomeNavView:(XPNewHomeNavView *)view didClickRank:(UIButton *)sender {
|
||
XPWebViewController * webVC =[[XPWebViewController alloc] init];
|
||
webVC.url = URLWithType(kHomeRankURL);
|
||
[self.navigationController pushViewController:webVC animated:YES];
|
||
}
|
||
|
||
- (void)xPNewHomeNavView:(XPNewHomeNavView *)view didClickOpenRoom:(UIButton *)sender {
|
||
NSString* roomUid = [AccountInfoStorage instance].getUid;
|
||
[self opRoom:roomUid];
|
||
|
||
}
|
||
-(void)opRoom:(NSString *)roomUid{
|
||
|
||
[Api getRoomInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||
if(code == 401){
|
||
|
||
[self tokenInvalid];
|
||
[self showErrorToast:msg];
|
||
return;
|
||
}
|
||
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 {
|
||
|
||
[self showErrorToast:msg];
|
||
}
|
||
} uid:roomUid intoUid:roomUid];
|
||
|
||
|
||
}
|
||
|
||
- (void)xPNewHomeNavView:(XPNewHomeNavView *)view didClickSearch:(UIView *)sender {
|
||
XPRoomSearchContainerViewController * searchVC = [[XPRoomSearchContainerViewController alloc] init];
|
||
searchVC.modalPresentationStyle = UIModalPresentationFullScreen;
|
||
[self.navigationController presentViewController:searchVC animated:YES completion:nil];
|
||
}
|
||
#pragma mark - XPHomeRecommendViewControllerDelegate
|
||
-(void)openRoom{
|
||
NSString* roomUid = [AccountInfoStorage instance].getUid;
|
||
[self opRoom:roomUid];
|
||
}
|
||
#pragma mark - JXCategoryViewDelegate
|
||
- (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
|
||
if(self.headView.bannerList.count == 0)return kGetScaleWidth(80);
|
||
return kGetScaleWidth(170);
|
||
}
|
||
|
||
- (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
|
||
return self.headView;
|
||
}
|
||
- (NSUInteger)heightForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
|
||
return kGetScaleWidth(44);
|
||
}
|
||
- (UIView *)viewForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
|
||
return self.titleView;
|
||
}
|
||
|
||
- (NSInteger)numberOfListsInPagerView:(JXPagerView *)pagerView {
|
||
return self.tagModelList.count;
|
||
}
|
||
|
||
- (id<JXPagerViewListViewDelegate>)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index {
|
||
|
||
|
||
|
||
if (index == self.tagModelList.count - 1) {
|
||
self.recommendVC.tagModel = [self.tagModelList safeObjectAtIndex1:index];
|
||
return self.recommendVC;
|
||
} else {
|
||
id homeV = [self.validListDict objectForKey:[NSNumber numberWithInteger:index]];
|
||
if (homeV) {
|
||
return homeV;
|
||
}
|
||
XPHomePartyViewController *homeVC = [[XPHomePartyViewController alloc] init];
|
||
homeVC.tagModel = [self.tagModelList safeObjectAtIndex1:index];
|
||
[self.validListDict setObject:homeVC forKey:@(index)];
|
||
return homeVC;
|
||
}
|
||
|
||
}
|
||
|
||
#pragma mark - JXCategoryListContentViewDelegate
|
||
- (UIView *)listView {
|
||
return self.view;
|
||
}
|
||
|
||
|
||
#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;
|
||
}
|
||
if(otherGestureRecognizer.view.tag == 98777){
|
||
return NO;
|
||
}
|
||
|
||
|
||
return [gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]];
|
||
}
|
||
#pragma mark - XPHomeContainerProtocol
|
||
-(void)getHomeTopBannerListSuccess:(NSArray *)list{
|
||
self.headView.bannerList = list;
|
||
[self.pagingView reloadData];
|
||
[self.pagingView resizeTableHeaderViewHeightWithAnimatable:NO duration:0 curve:0];
|
||
}
|
||
- (void)getCurrentResourceListSuccess:(NSArray *)list{
|
||
self.headView.itemList = list;
|
||
}
|
||
///获取所有的tag成功
|
||
- (void)getHomeTagListSuccess:(NSArray<PIHomeCategoryTitleModel *> *)array{
|
||
if(array.count == 0)return;
|
||
NSMutableArray *list = [NSMutableArray arrayWithArray:array];
|
||
[list addObject:self.tagModelList.lastObject];
|
||
[list insertObject:self.tagModelList.firstObject atIndex:0];
|
||
self.tagModelList = list;
|
||
self.titleView.titleList = self.tagModelList;
|
||
NSMutableArray *titleArray = [NSMutableArray array];
|
||
for (PIHomeCategoryTitleModel *model in self.tagModelList) {
|
||
[titleArray addObject:model.name];
|
||
}
|
||
self.titleView.titles = titleArray;
|
||
[self.titleView reloadData];
|
||
}
|
||
- (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 {
|
||
|
||
}
|
||
|
||
- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index{
|
||
|
||
self.titleView.index = index;
|
||
self.type = index;
|
||
|
||
}
|
||
|
||
#pragma mark - XPNewHomeHeadViewDelegate
|
||
///
|
||
-(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{
|
||
if([AccountInfoStorage instance].getTicket.length > 0 && [AccountInfoStorage instance].name.length > 0){
|
||
[self.presenter checkIpRegionAction];
|
||
}
|
||
|
||
}
|
||
///选择
|
||
-(void)selectItemWithModel:(PIHomeItemModel *)model{
|
||
if (model.resourceType == HomeMenuResourceType_H5) {
|
||
XPWebViewController * webVC = [[ XPWebViewController alloc] init];
|
||
webVC.url = model.resourceContent;
|
||
[self.navigationController pushViewController:webVC animated:YES];
|
||
}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];
|
||
}
|
||
}
|
||
}
|
||
-(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;
|
||
}
|
||
}
|
||
///点击了进入房间
|
||
- (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];
|
||
}
|
||
}
|
||
|
||
#pragma mark - Getters And Setters
|
||
- (PIHoemCategoryTitleView *)titleView {
|
||
if (!_titleView) {
|
||
_titleView = [[PIHoemCategoryTitleView alloc] initWithFrame:CGRectZero];
|
||
_titleView.delegate = self;
|
||
_titleView.titles = @[YMLocalizedString(@"XPNewHomeViewController0"),YMLocalizedString(@"XPNewHomeViewController1")];
|
||
_titleView.titleList = self.tagModelList;
|
||
_titleView.backgroundColor = [UIColor clearColor];
|
||
_titleView.titleColor = [UIColor clearColor];
|
||
_titleView.titleSelectedColor = [UIColor clearColor];
|
||
_titleView.titleFont = kFontSemibold(16);
|
||
_titleView.titleSelectedFont = kFontRegular(14);
|
||
_titleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyleCenter;
|
||
_titleView.contentScrollViewClickTransitionAnimationEnabled = NO;
|
||
_titleView.defaultSelectedIndex = 0;
|
||
|
||
_titleView.cellSpacing = kGetScaleWidth(2);
|
||
_titleView.cellWidth = kGetScaleWidth(20);
|
||
_titleView.listContainer = (id<JXCategoryViewListContainer>)self.pagingView.listContainerView;
|
||
|
||
// JXCategoryIndicatorImageView * indocator = [[JXCategoryIndicatorImageView alloc] init];
|
||
// indocator.indicatorImageView.image = [UIImage imageNamed:@"home_slider_bg"];
|
||
// indocator.indicatorImageViewSize = CGSizeMake(kGetScaleWidth(36), kGetScaleWidth(8));
|
||
// indocator.verticalMargin = 4;
|
||
// indocator.contentMode = UIViewContentModeScaleAspectFit;
|
||
// _titleView.indicators = @[indocator];
|
||
}
|
||
return _titleView;
|
||
}
|
||
|
||
- (NSMutableArray<PIHomeCategoryTitleModel *> *)tagModelList{
|
||
if(!_tagModelList){
|
||
_tagModelList = [NSMutableArray array];
|
||
PIHomeCategoryTitleModel *recommendModel = [PIHomeCategoryTitleModel new];
|
||
recommendModel.id = @"-1";
|
||
recommendModel.name = YMLocalizedString(@"XPNewHomeViewController0");
|
||
recommendModel.checkedWidth = [UILabel getWidthWithText:recommendModel.name height:kGetScaleWidth(44) font:kFontSemibold(16)];
|
||
recommendModel.noCheckedWidth = [UILabel getWidthWithText:recommendModel.name height:kGetScaleWidth(44) font:kFontRegular(14)];
|
||
recommendModel.isChecked = YES;
|
||
|
||
PIHomeCategoryTitleModel *hotModel = [PIHomeCategoryTitleModel new];
|
||
hotModel.id = @"-2";
|
||
hotModel.name = YMLocalizedString(@"XPNewHomeViewController1");
|
||
hotModel.checkedWidth = [UILabel getWidthWithText:recommendModel.name height:kGetScaleWidth(44) font:kFontSemibold(16)];
|
||
hotModel.noCheckedWidth = [UILabel getWidthWithText:recommendModel.name height:kGetScaleWidth(44) font:kFontRegular(14)];
|
||
[_tagModelList addObject:recommendModel];
|
||
[_tagModelList addObject:hotModel];
|
||
}
|
||
return _tagModelList;
|
||
}
|
||
- (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;
|
||
}
|
||
- (HomeTagModel *)recommendItem {
|
||
if (!_recommendItem) {
|
||
_recommendItem = [[HomeTagModel alloc] init];
|
||
_recommendItem.name = YMLocalizedString(@"XPNewHomeViewController3");
|
||
}
|
||
return _recommendItem;
|
||
}
|
||
|
||
|
||
|
||
- (XPNewHomeNavView *)navView {
|
||
if (!_navView) {
|
||
_navView = [[XPNewHomeNavView alloc] init];
|
||
_navView.delegate = self;
|
||
}
|
||
return _navView;
|
||
}
|
||
|
||
- (UIImageView *)backImageView {
|
||
if (!_backImageView) {
|
||
_backImageView = [[UIImageView alloc] init];
|
||
_backImageView.image = [UIImage imageNamed:@"home_top_bg"];
|
||
_backImageView.layer.masksToBounds = YES;
|
||
_backImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||
}
|
||
return _backImageView;
|
||
}
|
||
- (XPNewHomeHeadView *)headView{
|
||
if(!_headView){
|
||
_headView = [[XPNewHomeHeadView alloc]initWithFrame:CGRectZero];
|
||
_headView.delegate = self;
|
||
}
|
||
return _headView;
|
||
}
|
||
|
||
- (XPHomeRecommendViewController *)recommendVC{
|
||
if(!_recommendVC){
|
||
_recommendVC = [[XPHomeRecommendViewController alloc] init];
|
||
_recommendVC.delegate = self;
|
||
}
|
||
return _recommendVC;
|
||
}
|
||
- (NSMutableDictionary *)validListDict{
|
||
if(!_validListDict){
|
||
_validListDict = [NSMutableDictionary dictionary];
|
||
}
|
||
return _validListDict;
|
||
}
|
||
@end
|