From 5f0d52451c458e5a6ea7a275831863a9e15a5a6c Mon Sep 17 00:00:00 2001 From: liyuhua <15626451870@163.com> Date: Thu, 22 Feb 2024 15:58:48 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5tag=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- YuMi.xcodeproj/project.pbxproj | 18 +++ .../Cell/Income/PIGuildSingleRoomIncomeCell.m | 10 +- YuMi/Modules/YMNewHome/Api/Api+Home.m | 2 +- .../Model/PIHomeCategoryTitleModel.h | 20 +++ .../Model/PIHomeCategoryTitleModel.m | 12 ++ .../Presenter/XPHomeContainerPresenter.h | 1 + .../Presenter/XPHomeContainerPresenter.m | 17 +- .../YMNewHome/Presenter/XPHomePresenter.h | 2 +- .../YMNewHome/Presenter/XPHomePresenter.m | 8 +- .../Protocol/XPHomeContainerProtocol.h | 4 +- .../YMNewHome/Protocol/XPHomeProtocol.h | 4 +- .../View/PIHoemCategoryCollectionView.h | 25 +++ .../View/PIHoemCategoryCollectionView.m | 104 ++++++++++++ .../YMNewHome/View/PIHoemCategoryTitleCell.h | 18 +++ .../YMNewHome/View/PIHoemCategoryTitleCell.m | 67 ++++++++ .../YMNewHome/View/PIHoemCategoryTitleView.h | 1 + .../YMNewHome/View/PIHoemCategoryTitleView.m | 133 +++------------ .../View/XPHomePartyViewController.h | 12 +- .../View/XPHomePartyViewController.m | 65 +++++--- .../View/XPHomeRecommendViewController.h | 2 + .../YMNewHome/View/XPNewHomeViewController.m | 152 +++++++++++------- .../PIRoomActivityWebView.h | 2 +- .../PIRoomActivityWebView.m | 2 +- .../XPRoomActivityContainerView.m | 2 + .../View/CandyTree/View/XPRoomHalfWebView.h | 5 +- .../View/CandyTree/View/XPRoomHalfWebView.m | 10 +- 26 files changed, 482 insertions(+), 216 deletions(-) create mode 100644 YuMi/Modules/YMNewHome/Model/PIHomeCategoryTitleModel.h create mode 100644 YuMi/Modules/YMNewHome/Model/PIHomeCategoryTitleModel.m create mode 100644 YuMi/Modules/YMNewHome/View/PIHoemCategoryCollectionView.h create mode 100644 YuMi/Modules/YMNewHome/View/PIHoemCategoryCollectionView.m create mode 100644 YuMi/Modules/YMNewHome/View/PIHoemCategoryTitleCell.h create mode 100644 YuMi/Modules/YMNewHome/View/PIHoemCategoryTitleCell.m diff --git a/YuMi.xcodeproj/project.pbxproj b/YuMi.xcodeproj/project.pbxproj index a7e8baf1..b14d7b51 100644 --- a/YuMi.xcodeproj/project.pbxproj +++ b/YuMi.xcodeproj/project.pbxproj @@ -307,6 +307,9 @@ 23A439742AA1CF7C002E6039 /* XPNewHomeHeadView.m in Sources */ = {isa = PBXBuildFile; fileRef = 23A439732AA1CF7C002E6039 /* XPNewHomeHeadView.m */; }; 23B2AEC12A64E9C200543D17 /* LoginForgetEditView.m in Sources */ = {isa = PBXBuildFile; fileRef = 23B2AEC02A64E9C200543D17 /* LoginForgetEditView.m */; }; 23B2AEC42A6516C200543D17 /* LoginForgetPasswordViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 23B2AEC22A6516C200543D17 /* LoginForgetPasswordViewController.m */; }; + 23B8D8D82B85F8B900CA472F /* PIHoemCategoryTitleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 23B8D8D72B85F8B900CA472F /* PIHoemCategoryTitleCell.m */; }; + 23B8D8DB2B85FDDD00CA472F /* PIHomeCategoryTitleModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 23B8D8DA2B85FDDD00CA472F /* PIHomeCategoryTitleModel.m */; }; + 23B8D8DE2B860B8800CA472F /* PIHoemCategoryCollectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = 23B8D8DD2B860B8800CA472F /* PIHoemCategoryCollectionView.m */; }; 23BA165B2A5D2ACF0030C5A3 /* PIBaseAnimationViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 23BA165A2A5D2ACF0030C5A3 /* PIBaseAnimationViewModel.m */; }; 23C7C0B72A7CD7B000802205 /* XPNewMineGuildItemView.m in Sources */ = {isa = PBXBuildFile; fileRef = 23C7C0B62A7CD7B000802205 /* XPNewMineGuildItemView.m */; }; 23C9DFC32B84807A00B51558 /* PIRoomActivityClickView.m in Sources */ = {isa = PBXBuildFile; fileRef = 23C9DFC22B84807A00B51558 /* PIRoomActivityClickView.m */; }; @@ -2077,6 +2080,12 @@ 23B2AEC02A64E9C200543D17 /* LoginForgetEditView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LoginForgetEditView.m; sourceTree = ""; }; 23B2AEC22A6516C200543D17 /* LoginForgetPasswordViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LoginForgetPasswordViewController.m; sourceTree = ""; }; 23B2AEC32A6516C200543D17 /* LoginForgetPasswordViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoginForgetPasswordViewController.h; sourceTree = ""; }; + 23B8D8D62B85F8B900CA472F /* PIHoemCategoryTitleCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PIHoemCategoryTitleCell.h; sourceTree = ""; }; + 23B8D8D72B85F8B900CA472F /* PIHoemCategoryTitleCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PIHoemCategoryTitleCell.m; sourceTree = ""; }; + 23B8D8D92B85FDDD00CA472F /* PIHomeCategoryTitleModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PIHomeCategoryTitleModel.h; sourceTree = ""; }; + 23B8D8DA2B85FDDD00CA472F /* PIHomeCategoryTitleModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PIHomeCategoryTitleModel.m; sourceTree = ""; }; + 23B8D8DC2B860B8800CA472F /* PIHoemCategoryCollectionView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PIHoemCategoryCollectionView.h; sourceTree = ""; }; + 23B8D8DD2B860B8800CA472F /* PIHoemCategoryCollectionView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PIHoemCategoryCollectionView.m; sourceTree = ""; }; 23BA16592A5D2ACF0030C5A3 /* PIBaseAnimationViewModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PIBaseAnimationViewModel.h; sourceTree = ""; }; 23BA165A2A5D2ACF0030C5A3 /* PIBaseAnimationViewModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PIBaseAnimationViewModel.m; sourceTree = ""; }; 23C7C0B52A7CD7B000802205 /* XPNewMineGuildItemView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPNewMineGuildItemView.h; sourceTree = ""; }; @@ -8967,6 +8976,10 @@ E87E625C2A3F5622002F68C9 /* XPNewHomeViewController.m */, 239BEED92AA1E058005CDA94 /* PIHoemCategoryTitleView.h */, 239BEEDA2AA1E058005CDA94 /* PIHoemCategoryTitleView.m */, + 23B8D8DC2B860B8800CA472F /* PIHoemCategoryCollectionView.h */, + 23B8D8DD2B860B8800CA472F /* PIHoemCategoryCollectionView.m */, + 23B8D8D62B85F8B900CA472F /* PIHoemCategoryTitleCell.h */, + 23B8D8D72B85F8B900CA472F /* PIHoemCategoryTitleCell.m */, ); path = View; sourceTree = ""; @@ -9001,6 +9014,8 @@ E87DF4BE2A42C8C1009C1185 /* HomeTagModel.m */, 23FF42712AA6CC480055733C /* PIHomeItemModel.h */, 23FF42722AA6CC480055733C /* PIHomeItemModel.m */, + 23B8D8D92B85FDDD00CA472F /* PIHomeCategoryTitleModel.h */, + 23B8D8DA2B85FDDD00CA472F /* PIHomeCategoryTitleModel.m */, ); path = Model; sourceTree = ""; @@ -11142,6 +11157,7 @@ E81C27AB26EF2D920031E639 /* ThirdUserInfo.m in Sources */, 23FF25682ABC3BC00064E904 /* XPHomeGameCell.m in Sources */, E8788950273A699900BF1D57 /* ThemeColor+SendGift.m in Sources */, + 23B8D8D82B85F8B900CA472F /* PIHoemCategoryTitleCell.m in Sources */, E81C279D26EEEC620031E639 /* YUMIConstant.m in Sources */, 238B37AF2AC55A2C00BFC9D5 /* XPTreasureFairyViewController.m in Sources */, 238B37DB2AC55A2C00BFC9D5 /* PITreasureFairyBuyElfShardSuccessView.m in Sources */, @@ -11418,6 +11434,7 @@ 18F403EE2758CF2F00A6C548 /* MessageContentImage.m in Sources */, 238B37A32AC55A2C00BFC9D5 /* XPTreasureFailyPresenter.m in Sources */, 18E7B31E26F0984C0064BC9B /* UserLevelVo.m in Sources */, + 23B8D8DB2B85FDDD00CA472F /* PIHomeCategoryTitleModel.m in Sources */, 2331C1762A5EB71000E1D940 /* ThemeColor+NobleCenter.m in Sources */, 1427218C29A75F6F00C7C423 /* HTTPAsyncFileResponse.m in Sources */, E8DD25DA295583920043C7D5 /* XPAnchorRandomPKRuleView.m in Sources */, @@ -11653,6 +11670,7 @@ E81A6546283519CA00F55894 /* MonentsTopicModel.m in Sources */, E86E79D028A4E0B2006DAF48 /* ContentRistAlertModel.m in Sources */, 9BFE0D922899042600F53C24 /* XPTaskCompleteTipView.m in Sources */, + 23B8D8DE2B860B8800CA472F /* PIHoemCategoryCollectionView.m in Sources */, 9BE01AE728938AB600B50299 /* XPDressUpShopCardTableViewCell.m in Sources */, E82E75062828E76400C25EF7 /* XPCoreDataManager.m in Sources */, 9B8DE0E4289CF7AA00FB6EC2 /* XPRoomGiftCompoundView.m in Sources */, diff --git a/YuMi/Modules/YMMine/View/Guild/View/Cell/Income/PIGuildSingleRoomIncomeCell.m b/YuMi/Modules/YMMine/View/Guild/View/Cell/Income/PIGuildSingleRoomIncomeCell.m index 951d9713..665df3fb 100644 --- a/YuMi/Modules/YMMine/View/Guild/View/Cell/Income/PIGuildSingleRoomIncomeCell.m +++ b/YuMi/Modules/YMMine/View/Guild/View/Cell/Income/PIGuildSingleRoomIncomeCell.m @@ -82,13 +82,13 @@ self.numberView.text = [NSString stringWithFormat:@"ID:%@",_userInfo.erbanNo]; self.anchorNumView.text = _userInfo.anchorDiamondNum; self.roomNumView.text = _userInfo.roomDiamondNum; - if(_userInfo.timeDuration < 60){ + NSInteger h = _userInfo.timeDuration / 60; + NSInteger min = _userInfo.timeDuration % 60; + if(h <= 0){ self.timeView.text = [NSString stringWithFormat:@"%ldmin",_userInfo.timeDuration]; - }else if(_userInfo.timeDuration == 60){ - self.timeView.text = [NSString stringWithFormat:@"1h"]; + }else if(min <= 0 && h > 0){ + self.timeView.text = [NSString stringWithFormat:@"%ldh",h]; }else{ - NSInteger h = _userInfo.timeDuration / 60; - NSInteger min = _userInfo.timeDuration % 60; self.timeView.text = [NSString stringWithFormat:@"%ldh%ldmin",h,min]; } diff --git a/YuMi/Modules/YMNewHome/Api/Api+Home.m b/YuMi/Modules/YMNewHome/Api/Api+Home.m index ca210a76..9d699268 100644 --- a/YuMi/Modules/YMNewHome/Api/Api+Home.m +++ b/YuMi/Modules/YMNewHome/Api/Api+Home.m @@ -15,7 +15,7 @@ /// @param complection 完成 /// @param uid 用户的uid + (void)homeTagComplection:(HttpRequestHelperCompletion)complection uid:(NSString *)uid { - [self makeRequest:@"home/tagV2" method:HttpRequestHelperMethodGET completion:complection, __FUNCTION__, uid, nil]; + [self makeRequest:@"home/tag" method:HttpRequestHelperMethodGET completion:complection, __FUNCTION__, uid, nil]; } /// 获取首页所有的直播tag diff --git a/YuMi/Modules/YMNewHome/Model/PIHomeCategoryTitleModel.h b/YuMi/Modules/YMNewHome/Model/PIHomeCategoryTitleModel.h new file mode 100644 index 00000000..0ec9ac77 --- /dev/null +++ b/YuMi/Modules/YMNewHome/Model/PIHomeCategoryTitleModel.h @@ -0,0 +1,20 @@ +// +// PIHomeCategoryTitleModel.h +// YuMi +// +// Created by duoban on 2024/2/21. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface PIHomeCategoryTitleModel : NSObject +@property(nonatomic,assign) BOOL isChecked; +@property(nonatomic,assign) CGFloat checkedWidth; +@property(nonatomic,assign) CGFloat noCheckedWidth; +@property(nonatomic,copy) NSString *name; +@property(nonatomic,copy) NSString *id; +@end + +NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMNewHome/Model/PIHomeCategoryTitleModel.m b/YuMi/Modules/YMNewHome/Model/PIHomeCategoryTitleModel.m new file mode 100644 index 00000000..6b2c97d9 --- /dev/null +++ b/YuMi/Modules/YMNewHome/Model/PIHomeCategoryTitleModel.m @@ -0,0 +1,12 @@ +// +// PIHomeCategoryTitleModel.m +// YuMi +// +// Created by duoban on 2024/2/21. +// + +#import "PIHomeCategoryTitleModel.h" + +@implementation PIHomeCategoryTitleModel + +@end diff --git a/YuMi/Modules/YMNewHome/Presenter/XPHomeContainerPresenter.h b/YuMi/Modules/YMNewHome/Presenter/XPHomeContainerPresenter.h index 1076dc5f..41fd099d 100644 --- a/YuMi/Modules/YMNewHome/Presenter/XPHomeContainerPresenter.h +++ b/YuMi/Modules/YMNewHome/Presenter/XPHomeContainerPresenter.h @@ -19,6 +19,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)homeChatPick; ///ip检测 -(void)checkIpRegionAction; + @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMNewHome/Presenter/XPHomeContainerPresenter.m b/YuMi/Modules/YMNewHome/Presenter/XPHomeContainerPresenter.m index 66d4bc02..2145adbb 100644 --- a/YuMi/Modules/YMNewHome/Presenter/XPHomeContainerPresenter.m +++ b/YuMi/Modules/YMNewHome/Presenter/XPHomeContainerPresenter.m @@ -13,6 +13,7 @@ #import "AccountInfoStorage.h" #import "HomeBannerInfoModel.h" #import "PIHomeItemModel.h" +#import "PIHomeCategoryTitleModel.h" @implementation XPHomeContainerPresenter ///得到首页轮播图 - (void)getHomeTopBannerList{ @@ -27,17 +28,15 @@ /// 获取所有的房间的tag - (void)getHomeTagList { - NSString * uid = [[AccountInfoStorage instance] getUid]; - NSArray *list = [[AccountInfoStorage instance]getCurrentTagList]; - if(list.count > 0){ - [[self getView] getHomeTagListSuccess:list]; - } + NSString * uid = [AccountInfoStorage instance].getUid; [Api homeTagComplection:[self createHttpCompletion:^(BaseModel * _Nonnull data) { - NSArray * array = [HomeTagModel modelsWithArray:data.data]; - [[AccountInfoStorage instance]saveTagList:array]; - if(list.count == 0 || list.count != array.count){ - [[self getView] getHomeTagListSuccess:array]; + NSArray * array = [PIHomeCategoryTitleModel modelsWithArray:data.data]; + for (PIHomeCategoryTitleModel *model in array) { + model.checkedWidth = [UILabel getWidthWithText:model.name height:kGetScaleWidth(44) font:kFontSemibold(16)]; + model.noCheckedWidth = [UILabel getWidthWithText:model.name height:kGetScaleWidth(44) font:kFontRegular(14)]; } + [[self getView] getHomeTagListSuccess:array]; + }] uid:uid]; } ///首页改版资源位 diff --git a/YuMi/Modules/YMNewHome/Presenter/XPHomePresenter.h b/YuMi/Modules/YMNewHome/Presenter/XPHomePresenter.h index 24be6cbb..615c5afc 100644 --- a/YuMi/Modules/YMNewHome/Presenter/XPHomePresenter.h +++ b/YuMi/Modules/YMNewHome/Presenter/XPHomePresenter.h @@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN /// @param tabId id /// @param page 当前的页数 /// @param pageSize 一页有多少个 -- (void)getRecommendRoomList:(NSString *)tabId page:(int)page pageSize:(int)pageSize state:(BOOL)state; +- (void)getRecommendRoomList:(NSString *)tabId page:(int)page pageSize:(int)pageSize ; /// 获取更多的个播房间 diff --git a/YuMi/Modules/YMNewHome/Presenter/XPHomePresenter.m b/YuMi/Modules/YMNewHome/Presenter/XPHomePresenter.m index a5a93c83..fcc630ce 100644 --- a/YuMi/Modules/YMNewHome/Presenter/XPHomePresenter.m +++ b/YuMi/Modules/YMNewHome/Presenter/XPHomePresenter.m @@ -20,15 +20,15 @@ /// @param tabId id /// @param page 当前的页数 /// @param pageSize 一页有多少个 -- (void)getRecommendRoomList:(NSString *)tabId page:(int)page pageSize:(int)pageSize state:(BOOL)state { +- (void)getRecommendRoomList:(NSString *)tabId page:(int)page pageSize:(int)pageSize { NSString * uid = [AccountInfoStorage instance].getUid; NSString * pageStr = [NSString stringWithFormat:@"%d", page]; NSString * pageSizeStr = [NSString stringWithFormat:@"%d", pageSize]; [Api getRecommendListComplection:[self createHttpCompletion:^(BaseModel * _Nonnull data) { - NSArray * array = [HomeRecommendRoomModel modelsWithArray:data.data]; - [[self getView] getHomeRecommendRoomListSuccess:array state:state]; + NSArray * array = [HomePlayRoomModel modelsWithArray:data.data]; + [[self getView] getHomeRecommendRoomListSuccess:array ]; }fail:^(NSInteger code, NSString * _Nullable msg) { - [[self getView] getHomeRecommendRoomListFail:msg state:state]; + [[self getView] getHomeRecommendRoomListFail:msg ]; }] uid:uid tabId:tabId pageNum:pageStr pageSize:pageSizeStr]; } diff --git a/YuMi/Modules/YMNewHome/Protocol/XPHomeContainerProtocol.h b/YuMi/Modules/YMNewHome/Protocol/XPHomeContainerProtocol.h index 517edd6d..bf6ee35e 100644 --- a/YuMi/Modules/YMNewHome/Protocol/XPHomeContainerProtocol.h +++ b/YuMi/Modules/YMNewHome/Protocol/XPHomeContainerProtocol.h @@ -8,11 +8,11 @@ #import NS_ASSUME_NONNULL_BEGIN -@class HomeTagModel; +@class PIHomeCategoryTitleModel; @protocol XPHomeContainerProtocol @optional ///获取所有的tag成功 -- (void)getHomeTagListSuccess:(NSArray *)array; +- (void)getHomeTagListSuccess:(NSArray *)array; ///获取首页轮播图列表成功 - (void)getHomeTopBannerListSuccess:(NSArray*)list; ////首页改版资源位 diff --git a/YuMi/Modules/YMNewHome/Protocol/XPHomeProtocol.h b/YuMi/Modules/YMNewHome/Protocol/XPHomeProtocol.h index 7f9130cc..309c6e28 100644 --- a/YuMi/Modules/YMNewHome/Protocol/XPHomeProtocol.h +++ b/YuMi/Modules/YMNewHome/Protocol/XPHomeProtocol.h @@ -12,9 +12,9 @@ NS_ASSUME_NONNULL_BEGIN @protocol XPHomeProtocol @optional ///首页推荐房间的 -- (void)getHomeRecommendRoomListSuccess:(NSArray *)list state:(BOOL)state; +- (void)getHomeRecommendRoomListSuccess:(NSArray *)list; ///首页推荐房间失败 -- (void)getHomeRecommendRoomListFail:(NSString *)message state:(BOOL)state; +- (void)getHomeRecommendRoomListFail:(NSString *)message; ///请求更多个播房成功 - (void)getHomeMoreAnchorRoomListSuccess:(NSArray *)list; ///请求更多个播房失败 diff --git a/YuMi/Modules/YMNewHome/View/PIHoemCategoryCollectionView.h b/YuMi/Modules/YMNewHome/View/PIHoemCategoryCollectionView.h new file mode 100644 index 00000000..5f9c1f8f --- /dev/null +++ b/YuMi/Modules/YMNewHome/View/PIHoemCategoryCollectionView.h @@ -0,0 +1,25 @@ +// +// PIHoemCategoryCollectionView.h +// YuMi +// +// Created by duoban on 2024/2/21. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol PIHoemCategoryCollectionViewDelegate + +-(void)didSelectItemAtIndex:(NSInteger)index; + +@end + + +@interface PIHoemCategoryCollectionView : UIView +@property(nonatomic,strong) NSMutableArray *titleList; +@property(nonatomic,assign) NSInteger index; +@property(nonatomic,weak) iddelegate; +@end + +NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMNewHome/View/PIHoemCategoryCollectionView.m b/YuMi/Modules/YMNewHome/View/PIHoemCategoryCollectionView.m new file mode 100644 index 00000000..d69fc431 --- /dev/null +++ b/YuMi/Modules/YMNewHome/View/PIHoemCategoryCollectionView.m @@ -0,0 +1,104 @@ +// +// PIHoemCategoryCollectionView.m +// YuMi +// +// Created by duoban on 2024/2/21. +// + +#import "PIHoemCategoryCollectionView.h" +#import "PIHomeCategoryTitleModel.h" +#import "PIHoemCategoryTitleCell.h" +@interface PIHoemCategoryCollectionView() +@property(nonatomic,strong) UICollectionView *pi_collectionView; +@end +@implementation PIHoemCategoryCollectionView +-(instancetype)initWithFrame:(CGRect)frame{ + self = [super initWithFrame:frame]; + if(self){ + [self installUI]; + [self installConstraints]; + } + return self; +} +-(void)installUI{ + [self addSubview:self.pi_collectionView]; +} +-(void)installConstraints{ + [self.pi_collectionView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.equalTo(self); + }]; +} +-(void)setTitleList:(NSMutableArray *)titleList{ + _titleList = titleList; + [self.pi_collectionView reloadData]; + +} +#pragma mark- UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ + return self.titleList.count; +} +- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{ + PIHomeCategoryTitleModel *model = [self.titleList safeObjectAtIndex1:indexPath.row]; + CGFloat width = model.isChecked ? model.checkedWidth : model.noCheckedWidth; + return CGSizeMake(width + kGetScaleWidth(10), kGetScaleWidth(44)); +} +- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ + PIHoemCategoryTitleCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([PIHoemCategoryTitleCell class]) forIndexPath:indexPath]; + PIHomeCategoryTitleModel *model = [self.titleList safeObjectAtIndex1:indexPath.row]; + cell.tagModel = model; + return cell; +} +- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ + for (PIHomeCategoryTitleModel *model in self.titleList) { + model.isChecked = NO; + } + PIHomeCategoryTitleModel *selectModel = [self.titleList safeObjectAtIndex1:indexPath.row]; + selectModel.isChecked = YES; + [self.pi_collectionView reloadData]; + + if(self.delegate && [self.delegate respondsToSelector:@selector(didSelectItemAtIndex:)]){ + [self.delegate didSelectItemAtIndex:indexPath.row]; + } + +// int i = [selectModel.id isEqualToString:@"-1"] ? 0 : 1; +// if(self.scrolledHandle){ +// self.scrolledHandle(i); +// } +} + +- (void)setIndex:(NSInteger)index{ + _index = index; + for (int i = 0; i < self.titleList.count; i++) { + PIHomeCategoryTitleModel *model = [self.titleList safeObjectAtIndex1:i]; + model.isChecked = NO; + } + PIHomeCategoryTitleModel *curModel = [self.titleList safeObjectAtIndex1:_index]; + curModel.isChecked = YES; + [self.pi_collectionView reloadData]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [self.pi_collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0] atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES]; + }); +} +#pragma mark - 懒加载 +- (UICollectionView *)pi_collectionView{ + if (!_pi_collectionView) { + UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; + layout.minimumLineSpacing = kGetScaleWidth(10); + layout.minimumInteritemSpacing = kGetScaleWidth(10); + layout.scrollDirection = UICollectionViewScrollDirectionHorizontal; + layout.sectionInset = UIEdgeInsetsMake(0, kGetScaleWidth(10), 0, kGetScaleWidth(10)); + + _pi_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; + _pi_collectionView.dataSource = self; + _pi_collectionView.delegate = self; + _pi_collectionView.tag = 98777; + _pi_collectionView.showsVerticalScrollIndicator = NO; + _pi_collectionView.showsHorizontalScrollIndicator = NO; + _pi_collectionView.backgroundColor = [UIColor clearColor]; + [_pi_collectionView registerClass:[PIHoemCategoryTitleCell class] forCellWithReuseIdentifier:NSStringFromClass([PIHoemCategoryTitleCell class])]; + + } + return _pi_collectionView; +} + +@end diff --git a/YuMi/Modules/YMNewHome/View/PIHoemCategoryTitleCell.h b/YuMi/Modules/YMNewHome/View/PIHoemCategoryTitleCell.h new file mode 100644 index 00000000..328c3d41 --- /dev/null +++ b/YuMi/Modules/YMNewHome/View/PIHoemCategoryTitleCell.h @@ -0,0 +1,18 @@ +// +// PIHoemCategoryTitleCell.h +// YuMi +// +// Created by duoban on 2024/2/21. +// + +#import +#import "PIHomeCategoryTitleModel.h" +NS_ASSUME_NONNULL_BEGIN + +@interface PIHoemCategoryTitleCell : UICollectionViewCell + + +@property(nonatomic,strong) PIHomeCategoryTitleModel *tagModel; +@end + +NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMNewHome/View/PIHoemCategoryTitleCell.m b/YuMi/Modules/YMNewHome/View/PIHoemCategoryTitleCell.m new file mode 100644 index 00000000..377667ba --- /dev/null +++ b/YuMi/Modules/YMNewHome/View/PIHoemCategoryTitleCell.m @@ -0,0 +1,67 @@ +// +// PIHoemCategoryTitleCell.m +// YuMi +// +// Created by duoban on 2024/2/21. +// + +#import "PIHoemCategoryTitleCell.h" +@interface PIHoemCategoryTitleCell() +@property(nonatomic,strong) UIButton *titleView; +@property(nonatomic,strong) UIImageView *lineVeiw; +@end +@implementation PIHoemCategoryTitleCell +-(instancetype)initWithFrame:(CGRect)frame{ + self = [super initWithFrame:frame]; + if(self){ + [self installUI]; + [self installConstraints]; + } + return self; +} +-(void)installUI{ + [self.contentView addSubview:self.lineVeiw]; + [self.contentView addSubview:self.titleView]; +} +-(void)installConstraints{ + [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) { + make.leading.centerY.trailing.equalTo(self.contentView); + make.height.mas_equalTo(kGetScaleWidth(22)); + }]; + [self.lineVeiw mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.mas_equalTo(kGetScaleWidth(36)); + make.height.mas_equalTo(kGetScaleWidth(8)); + make.bottom.equalTo(self.titleView.mas_bottom).mas_offset(-kGetScaleWidth(4)); + make.trailing.equalTo(self.titleView.mas_trailing).mas_offset(-kGetScaleWidth(5)); + }]; +} + +-(void)setTagModel:(PIHomeCategoryTitleModel *)tagModel{ + _tagModel = tagModel; + [_titleView setTitle:_tagModel.name forState:UIControlStateNormal]; + _titleView.selected = _tagModel.isChecked; + _titleView.titleLabel.font = _tagModel.isChecked ? kFontSemibold(16):kFontRegular(14); + _lineVeiw.hidden = !_tagModel.isChecked; +} + +#pragma mark - 懒加载 +- (UIImageView *)lineVeiw{ + if(!_lineVeiw){ + _lineVeiw = [UIImageView new]; + _lineVeiw.image = kImage(@"home_slider_bg"); + } + return _lineVeiw; +} +- (UIButton *)titleView{ + if(!_titleView){ + _titleView = [UIButton new]; + [_titleView setTitle:YMLocalizedString(@"XPNewHomeViewController1") forState:UIControlStateNormal]; + [_titleView setTitleColor:UIColorFromRGB(0x1F1B4F) forState:UIControlStateSelected]; + [_titleView setTitleColor:UIColorFromRGB(0x767585) forState:UIControlStateNormal]; + _titleView.titleLabel.font = kFontRegular(14); + _titleView.userInteractionEnabled = NO; + + } + return _titleView; +} +@end diff --git a/YuMi/Modules/YMNewHome/View/PIHoemCategoryTitleView.h b/YuMi/Modules/YMNewHome/View/PIHoemCategoryTitleView.h index b6cfe34d..34029ccb 100644 --- a/YuMi/Modules/YMNewHome/View/PIHoemCategoryTitleView.h +++ b/YuMi/Modules/YMNewHome/View/PIHoemCategoryTitleView.h @@ -15,6 +15,7 @@ typedef void(^ScrolledHandle)(NSInteger type); @interface PIHoemCategoryTitleView : JXCategoryTitleView @property(nonatomic,assign) NSInteger index; @property(nonatomic,copy) ScrolledHandle scrolledHandle; +@property(nonatomic,strong) NSMutableArray *titleList; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMNewHome/View/PIHoemCategoryTitleView.m b/YuMi/Modules/YMNewHome/View/PIHoemCategoryTitleView.m index 3d0130ce..5d15c6aa 100644 --- a/YuMi/Modules/YMNewHome/View/PIHoemCategoryTitleView.m +++ b/YuMi/Modules/YMNewHome/View/PIHoemCategoryTitleView.m @@ -6,10 +6,11 @@ // #import "PIHoemCategoryTitleView.h" -@interface PIHoemCategoryTitleView() -@property(nonatomic,strong) UIButton *fristBnt; -@property(nonatomic,strong) UIButton *secondBnt; -@property(nonatomic,strong) UIImageView *lineImage; +#import "PIHoemCategoryTitleCell.h" +#import "PIHoemCategoryCollectionView.h" +@interface PIHoemCategoryTitleView() + +@property(nonatomic,strong) PIHoemCategoryCollectionView *pi_collectionView; @end @implementation PIHoemCategoryTitleView -(instancetype)initWithFrame:(CGRect)frame{ @@ -21,122 +22,40 @@ return self; } -(void)installUI{ - UIButton *b = [UIButton new]; - [self addSubview:b]; - [b mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.equalTo(self); - }]; - [self addSubview:self.lineImage]; - [self addSubview:self.fristBnt]; - [self addSubview:self.secondBnt]; + [self addSubview:self.pi_collectionView]; } -(void)installConstraints{ - [self.fristBnt mas_makeConstraints:^(MASConstraintMaker *make) { - make.leading.mas_equalTo(kGetScaleWidth(15)); - make.centerY.equalTo(self); - make.height.mas_equalTo(kGetScaleWidth(22)); - }]; - [self.secondBnt mas_makeConstraints:^(MASConstraintMaker *make) { - make.leading.equalTo(self.fristBnt.mas_trailing).mas_offset(kGetScaleWidth(24)); - make.centerY.equalTo(self); - make.height.mas_equalTo(kGetScaleWidth(22)); - }]; - [self.lineImage mas_makeConstraints:^(MASConstraintMaker *make) { - make.width.mas_equalTo(kGetScaleWidth(36)); - make.height.mas_equalTo(kGetScaleWidth(8)); - make.bottom.equalTo(self.fristBnt.mas_bottom).mas_offset(-kGetScaleWidth(4)); - make.trailing.equalTo(self.fristBnt.mas_trailing); + [self.pi_collectionView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.equalTo(self); }]; } --(void)chooseItem:(UIButton *)sender{ - self.fristBnt.titleLabel.font = sender == self.fristBnt ? kFontSemibold(16):kFontRegular(14); - self.secondBnt.titleLabel.font = sender != self.fristBnt ? kFontSemibold(16):kFontRegular(14); - self.fristBnt.selected = sender == self.fristBnt; - self.secondBnt.selected = sender != self.fristBnt; - if(self.fristBnt == sender){ - - if(self.scrolledHandle){ - self.scrolledHandle(0); - } - [self.lineImage mas_remakeConstraints:^(MASConstraintMaker *make) { - make.width.mas_equalTo(kGetScaleWidth(36)); - make.height.mas_equalTo(kGetScaleWidth(8)); - make.bottom.equalTo(self.fristBnt.mas_bottom).mas_offset(-kGetScaleWidth(4)); - make.trailing.equalTo(self.fristBnt.mas_trailing); - }]; - return; - } - - if(self.scrolledHandle){ - self.scrolledHandle(1); - } - [self.lineImage mas_remakeConstraints:^(MASConstraintMaker *make) { - make.width.mas_equalTo(kGetScaleWidth(36)); - make.height.mas_equalTo(kGetScaleWidth(8)); - make.bottom.equalTo(self.secondBnt.mas_bottom).mas_offset(-kGetScaleWidth(4)); - make.trailing.equalTo(self.secondBnt.mas_trailing); - - }]; +-(void)setTitleList:(NSMutableArray *)titleList{ + _titleList = titleList; + self.pi_collectionView.titleList = titleList; } + + - (void)setIndex:(NSInteger)index{ _index = index; - self.fristBnt.titleLabel.font = _index == 0 ? kFontSemibold(16):kFontRegular(14); - self.secondBnt.titleLabel.font = _index == 1 ? kFontSemibold(16):kFontRegular(14); - self.fristBnt.selected = _index == 0; - self.secondBnt.selected = _index == 1; - if(_index == 0){ - [self.lineImage mas_remakeConstraints:^(MASConstraintMaker *make) { - make.width.mas_equalTo(kGetScaleWidth(36)); - make.height.mas_equalTo(kGetScaleWidth(8)); - make.bottom.equalTo(self.fristBnt.mas_bottom).mas_offset(-kGetScaleWidth(4)); - make.trailing.equalTo(self.fristBnt.mas_trailing); - }]; - return; + self.pi_collectionView.index = _index; +} +#pragma mark - PIHoemCategoryCollectionViewDelegate +- (void)didSelectItemAtIndex:(NSInteger)index{ + if(self.scrolledHandle){ + self.scrolledHandle(index); } - [self.lineImage mas_remakeConstraints:^(MASConstraintMaker *make) { - make.width.mas_equalTo(kGetScaleWidth(36)); - make.height.mas_equalTo(kGetScaleWidth(8)); - make.bottom.equalTo(self.secondBnt.mas_bottom).mas_offset(-kGetScaleWidth(4)); - make.trailing.equalTo(self.secondBnt.mas_trailing); - - }]; } #pragma mark - 懒加载 -- (UIButton *)fristBnt{ - if(!_fristBnt){ - _fristBnt = [UIButton new]; - [_fristBnt setTitle:YMLocalizedString(@"XPNewHomeViewController0") forState:UIControlStateNormal]; - [_fristBnt setTitleColor:UIColorFromRGB(0x1F1B4F) forState:UIControlStateSelected]; - [_fristBnt setTitleColor:UIColorFromRGB(0x767585) forState:UIControlStateNormal]; - _fristBnt.selected = YES; - _fristBnt.titleLabel.font = kFontSemibold(16); - [_fristBnt addTarget:self action:@selector(chooseItem:) forControlEvents:UIControlEventTouchUpInside]; - [_fristBnt setEnlargeEdgeWithTop:10 right:10 bottom:10 left:10]; - } - return _fristBnt; -} +- (PIHoemCategoryCollectionView *)pi_collectionView{ + if (!_pi_collectionView) { + + _pi_collectionView = [[PIHoemCategoryCollectionView alloc] initWithFrame:CGRectZero ]; + _pi_collectionView.delegate = self; -- (UIButton *)secondBnt{ - if(!_secondBnt){ - _secondBnt = [UIButton new]; - [_secondBnt setTitle:YMLocalizedString(@"XPNewHomeViewController1") forState:UIControlStateNormal]; - [_secondBnt setTitleColor:UIColorFromRGB(0x1F1B4F) forState:UIControlStateSelected]; - [_secondBnt setTitleColor:UIColorFromRGB(0x767585) forState:UIControlStateNormal]; - _secondBnt.titleLabel.font = kFontRegular(14); - [_secondBnt addTarget:self action:@selector(chooseItem:) forControlEvents:UIControlEventTouchUpInside]; - [_secondBnt setEnlargeEdgeWithTop:10 right:10 bottom:10 left:10]; - } - return _secondBnt; -} -- (UIImageView *)lineImage{ - if(!_lineImage){ - _lineImage = [UIImageView new]; - _lineImage.image = kImage(@"home_slider_bg"); - } - return _lineImage; + return _pi_collectionView; } //- (void)layoutSubviews{ // [super layoutSubviews]; @@ -145,7 +64,7 @@ // //如果向下取整导致了你的页面异常,请自己重新设置JXCategoryView的高度,保证为整数即可。 // // CGRect targetFrame = CGRectMake(0, 0, self.bounds.size.width - kGetScaleWidth(159), floor(self.bounds.size.height)); -// self.collectionView.frame = targetFrame; +// self.pi_collectionView.frame = targetFrame; // // //} diff --git a/YuMi/Modules/YMNewHome/View/XPHomePartyViewController.h b/YuMi/Modules/YMNewHome/View/XPHomePartyViewController.h index 7bc4ccab..0be0428b 100644 --- a/YuMi/Modules/YMNewHome/View/XPHomePartyViewController.h +++ b/YuMi/Modules/YMNewHome/View/XPHomePartyViewController.h @@ -7,6 +7,7 @@ #import "MvpViewController.h" #import +#import "PIHomeCategoryTitleModel.h" NS_ASSUME_NONNULL_BEGIN @@ -14,13 +15,12 @@ NS_ASSUME_NONNULL_BEGIN @interface XPHomePartyViewController : MvpViewController @property (nonatomic, copy) void(^scrollCallback)(UIScrollView *scrollView); -///模块的 ID -@property (nonatomic,copy) NSString *pi_tabId; -///是否是个播 -@property (nonatomic,assign) BOOL isAnchor; -@property(nonatomic,copy) HeaderRefreshComplete refreshComplete; -- (void)headerRefresh; +@property(nonatomic,strong) PIHomeCategoryTitleModel *tagModel; + + + + @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMNewHome/View/XPHomePartyViewController.m b/YuMi/Modules/YMNewHome/View/XPHomePartyViewController.m index 805737d2..30436ae0 100644 --- a/YuMi/Modules/YMNewHome/View/XPHomePartyViewController.m +++ b/YuMi/Modules/YMNewHome/View/XPHomePartyViewController.m @@ -54,6 +54,7 @@ } + #pragma mark - Private Method - (void)initSubViews { self.view.backgroundColor = [UIColor clearColor]; @@ -64,6 +65,11 @@ [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(self.view); }]; + MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(fooderRefresh)]; + footer.stateLabel.textColor = [DJDKMIMOMColor secondTextColor]; + footer.stateLabel.font = [UIFont systemFontOfSize:10.0]; + self.collectionView.mj_footer = footer; + } @@ -71,12 +77,23 @@ #pragma mark - 刷新的fangfa - (void)headerRefresh { - - [self.presenter getHomePersonalRoomList]; - + if([self.tagModel.id isEqualToString:@"-1"]){ + [self.presenter getHomePersonalRoomList]; + }else{ + self.page = 1; + [self.presenter getRecommendRoomList:self.tagModel.id page:self.page pageSize:20]; + } } - +-(void)fooderRefresh{ + if([self.tagModel.id isEqualToString:@"-1"]){ + [self.collectionView.mj_footer endRefreshing]; + + }else{ + self.page++; + [self.presenter getRecommendRoomList:self.tagModel.id page:self.page pageSize:20]; + } +} #pragma mark - UICollectionViewDelegate And UICollectionViewDataSource - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ @@ -116,9 +133,7 @@ #pragma mark - XPHomeProtocol - (void)getHomePersonalRoomListSuccess:(NSArray *)list{ - if(self.refreshComplete){ - self.refreshComplete(); - } + [[NSNotificationCenter defaultCenter]postNotificationName:@"khomeVCRefreshComplete" object:nil]; for (HomePlayRoomModel *model in list) { model.width = [UILabel getWidthWithText:@(model.onlineNum).stringValue height:kGetScaleWidth(12) font:kFontBold(10)]+1; } @@ -126,11 +141,27 @@ [self.collectionView reloadData]; } - (void)getHomePersonalRoomListFail{ - if(self.refreshComplete){ - self.refreshComplete(); - } + [[NSNotificationCenter defaultCenter]postNotificationName:@"khomeVCRefreshComplete" object:nil]; } +- (void)getHomeRecommendRoomListSuccess:(NSArray *)list{ + [self.collectionView.mj_footer endRefreshing]; + for (HomePlayRoomModel *model in list) { + model.width = [UILabel getWidthWithText:@(model.onlineNum).stringValue height:kGetScaleWidth(12) font:kFontBold(10)]+1; + } + if(self.page == 1){ + self.datasource = [NSMutableArray arrayWithArray:list]; + }else{ + [self.datasource addObjectsFromArray:list]; + } + [self.collectionView reloadData]; + [[NSNotificationCenter defaultCenter]postNotificationName:@"khomeVCRefreshComplete" object:nil]; +} + +- (void)getHomeRecommendRoomListFail:(NSString *)message{ + [self.collectionView.mj_footer endRefreshing]; + [[NSNotificationCenter defaultCenter]postNotificationName:@"khomeVCRefreshComplete" object:nil]; +} #pragma mark - JXPagingViewListViewDelegate - (UIScrollView *)listScrollView { return self.collectionView; @@ -152,16 +183,8 @@ #pragma mark - Getters And Setters -- (void)setIsAnchor:(BOOL)isAnchor { - _isAnchor = isAnchor; - if (_isAnchor) { - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - [self headerRefresh]; - }); - } -} -- (void)setPi_tabId:(NSString *)pi_tabId{ - _pi_tabId = pi_tabId; +-(void)setTagModel:(PIHomeCategoryTitleModel *)tagModel{ + _tagModel = tagModel; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self headerRefresh]; }); @@ -169,6 +192,7 @@ + - (UICollectionView *)collectionView{ if (!_collectionView) { UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; @@ -179,6 +203,7 @@ _collectionView.backgroundColor = [UIColor clearColor]; _collectionView.dataSource = self; _collectionView.delegate = self; + _collectionView.tag = 78574; [_collectionView registerClass:[XPNewHomePartyCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPNewHomePartyCollectionViewCell class])]; [_collectionView registerClass:[XPGuildEmptyCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPGuildEmptyCollectionViewCell class])]; } diff --git a/YuMi/Modules/YMNewHome/View/XPHomeRecommendViewController.h b/YuMi/Modules/YMNewHome/View/XPHomeRecommendViewController.h index aff9a8dd..22be221c 100644 --- a/YuMi/Modules/YMNewHome/View/XPHomeRecommendViewController.h +++ b/YuMi/Modules/YMNewHome/View/XPHomeRecommendViewController.h @@ -7,6 +7,7 @@ #import "MvpViewController.h" #import +#import "PIHomeCategoryTitleModel.h" NS_ASSUME_NONNULL_BEGIN @protocol XPHomeRecommendViewControllerDelegate @@ -19,6 +20,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, copy) void(^scrollCallback)(UIScrollView *scrollView); @property(nonatomic,weak) iddelegate; @property(nonatomic,copy) HeaderRefreshComplete refreshComplete; +@property(nonatomic,strong) PIHomeCategoryTitleModel *tagModel; - (void)headerRefresh; @end diff --git a/YuMi/Modules/YMNewHome/View/XPNewHomeViewController.m b/YuMi/Modules/YMNewHome/View/XPNewHomeViewController.m index 2f7e561e..be796d17 100644 --- a/YuMi/Modules/YMNewHome/View/XPNewHomeViewController.m +++ b/YuMi/Modules/YMNewHome/View/XPNewHomeViewController.m @@ -51,7 +51,7 @@ #import "XPLoginViewController.h" #import "BaseNavigationController.h" #import "XPAdImageTool.h" - +#import "PIHomeCategoryTitleModel.h" UIKIT_EXTERN NSString * kHomeMoreScrollPageKey; UIKIT_EXTERN NSString * const kOpenRoomNotification; @@ -66,20 +66,19 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification; ///头视图 @property(nonatomic,strong) XPNewHomeHeadView *headView; ///分页标题 -@property (nonatomic, strong) NSArray *titles; +@property (nonatomic, strong) NSMutableArray *tagModelList; ///分页控件 @property (nonatomic, strong) PIHoemCategoryTitleView *titleView; ///分页lineView @property (nonatomic, strong) JXPagerView *pagingView; -///tag的列表 -@property (nonatomic,copy) NSMutableArray *tagList; + @property (nonatomic,strong) HomeTagModel *recommendItem; ///解决弱网时首页底部出现一片空白bug @property (nonatomic,assign) BOOL isEmpty; -@property(nonatomic,strong) XPHomePartyViewController * homeVC; @property(nonatomic,strong) XPHomeRecommendViewController * recommendVC; -@property(nonatomic,assign) NSInteger type; @property(nonatomic,assign) BOOL isCheckIp; +@property(nonatomic,assign) NSInteger type; +@property(nonatomic,strong) NSMutableDictionary *validListDict; @end @implementation XPNewHomeViewController @@ -106,6 +105,7 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification; - (void)viewDidLoad { [super viewDidLoad]; if(self.isEmpty == NO){ + [self.presenter getHomeTagList]; [self initHttp]; [self initSubViews]; [self initSubViewConstraints]; @@ -148,8 +148,10 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification; @kWeakify(self); timer = [XPWeakTimer scheduledTimerWithTimeInterval:15 block:^(id userInfo) { @kStrongify(self); - [self.homeVC headerRefresh]; - [self.recommendVC headerRefresh]; + 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 { @@ -181,45 +183,52 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification; 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.homeVC.refreshComplete = ^{ - @kStrongify(self); - if(self.type == 0){ - [self.pagingView.mainTableView.mj_header endRefreshing]; - } - }; + self.recommendVC.refreshComplete = ^{ @kStrongify(self); - if(self.type == 1){ [self.pagingView.mainTableView.mj_header endRefreshing]; - } + }; self.titleView.scrolledHandle = ^(NSInteger type) { @kStrongify(self); [self.titleView.listContainer didClickSelectedItemAtIndex:type]; - [UIView animateWithDuration:0.3 animations:^{ - self.pagingView.listContainerView.scrollView.contentOffset = CGPointMake(type * KScreenWidth, 0); - } ]; + 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.type == 0){ - [self.homeVC headerRefresh]; - }else{ + 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; @@ -266,6 +275,7 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification; } - (void)initHttp { + [self.presenter getHomeTopBannerList]; [self.presenter getCurrentResourceList]; [self requestCheckIp]; @@ -341,22 +351,25 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification; } - (NSInteger)numberOfListsInPagerView:(JXPagerView *)pagerView { - return self.titles.count; + return self.tagModelList.count; } - (id)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index { - XPHomeRecommendViewController * homeV = (XPHomeRecommendViewController *)[self.pagingView.validListDict objectForKey:[NSNumber numberWithInteger:index]]; - if (homeV) { - return homeV; - } - if (index == 0) { - - return self.homeVC; - - } else { - + + + 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; } } @@ -379,6 +392,10 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification; if(otherGestureRecognizer.view.tag == 9000002){ return NO; } + if(otherGestureRecognizer.view.tag == 98777){ + return NO; + } + return [gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]; } @@ -391,7 +408,21 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification; - (void)getCurrentResourceListSuccess:(NSArray *)list{ self.headView.itemList = list; } - +///获取所有的tag成功 +- (void)getHomeTagListSuccess:(NSArray *)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; @@ -405,8 +436,9 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification; } - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index{ - self.type = index; + self.titleView.index = index; + self.type = index; } @@ -489,7 +521,8 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification; if (!_titleView) { _titleView = [[PIHoemCategoryTitleView alloc] initWithFrame:CGRectZero]; _titleView.delegate = self; - _titleView.titles = self.titles; + _titleView.titles = @[YMLocalizedString(@"XPNewHomeViewController0"),YMLocalizedString(@"XPNewHomeViewController1")]; + _titleView.titleList = self.tagModelList; _titleView.backgroundColor = [UIColor clearColor]; _titleView.titleColor = [UIColor clearColor]; _titleView.titleSelectedColor = [UIColor clearColor]; @@ -512,11 +545,26 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification; } return _titleView; } -- (NSArray *)titles{ - if(!_titles){ - _titles = @[YMLocalizedString(@"XPNewHomeViewController0"),YMLocalizedString(@"XPNewHomeViewController1")]; + +- (NSMutableArray *)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 _titles; + return _tagModelList; } - (JXPagerView *)pagingView { if (!_pagingView) { @@ -537,12 +585,7 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification; return _recommendItem; } -- (NSMutableArray *)tagList { - if (!_tagList) { - _tagList = [NSMutableArray array]; - } - return _tagList; -} + - (XPNewHomeNavView *)navView { if (!_navView) { @@ -568,12 +611,7 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification; } return _headView; } -- (XPHomePartyViewController *)homeVC{ - if(!_homeVC){ - _homeVC = [[XPHomePartyViewController alloc] init]; - } - return _homeVC; -} + - (XPHomeRecommendViewController *)recommendVC{ if(!_recommendVC){ _recommendVC = [[XPHomeRecommendViewController alloc] init]; @@ -581,4 +619,10 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification; } return _recommendVC; } +- (NSMutableDictionary *)validListDict{ + if(!_validListDict){ + _validListDict = [NSMutableDictionary dictionary]; + } + return _validListDict; +} @end diff --git a/YuMi/Modules/YMRoom/View/ActivityContainerView/PIRoomActivityWebView.h b/YuMi/Modules/YMRoom/View/ActivityContainerView/PIRoomActivityWebView.h index 303d3c78..71325ee4 100644 --- a/YuMi/Modules/YMRoom/View/ActivityContainerView/PIRoomActivityWebView.h +++ b/YuMi/Modules/YMRoom/View/ActivityContainerView/PIRoomActivityWebView.h @@ -8,7 +8,7 @@ #import NS_ASSUME_NONNULL_BEGIN - +#define kWebViewScale ((CGFloat)KScreenHeight / (CGFloat)812) @interface PIRoomActivityWebView : UIView @property(nonatomic,strong) NSMutableArray *infoList; ///地址 diff --git a/YuMi/Modules/YMRoom/View/ActivityContainerView/PIRoomActivityWebView.m b/YuMi/Modules/YMRoom/View/ActivityContainerView/PIRoomActivityWebView.m index 510365d4..e836e0e9 100644 --- a/YuMi/Modules/YMRoom/View/ActivityContainerView/PIRoomActivityWebView.m +++ b/YuMi/Modules/YMRoom/View/ActivityContainerView/PIRoomActivityWebView.m @@ -8,7 +8,7 @@ #import "PIRoomActivityWebView.h" #import "PIRoomActivityWebCell.h" #import "XPWebViewController.h" -#define kWebViewScale ((CGFloat)KScreenHeight / (CGFloat)812) + @interface PIRoomActivityWebView () @property(nonatomic,strong) UIButton *pi_backBtn; @property(nonatomic,strong) UIView *bgView; diff --git a/YuMi/Modules/YMRoom/View/ActivityContainerView/XPRoomActivityContainerView.m b/YuMi/Modules/YMRoom/View/ActivityContainerView/XPRoomActivityContainerView.m index 7a57ef9a..b1535482 100644 --- a/YuMi/Modules/YMRoom/View/ActivityContainerView/XPRoomActivityContainerView.m +++ b/YuMi/Modules/YMRoom/View/ActivityContainerView/XPRoomActivityContainerView.m @@ -455,6 +455,7 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView; if(info.showType == ActivityShowType_Half){ XPRoomHalfWebView * webView = [[XPRoomHalfWebView alloc] init]; + webView.isPlayView = YES; webView.roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid]; webView.url = info.skipContent; [TTPopup popupView:webView style:TTPopupStyleActionSheet]; @@ -585,6 +586,7 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView; } else if(model.skipType == ActivitySkipType_Web) { if(model.showType == ActivityShowType_Half){ XPRoomHalfWebView * webView = [[XPRoomHalfWebView alloc] init]; + webView.isPlayView = YES; webView.roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid]; webView.url = model.skipContent; [TTPopup popupView:webView style:TTPopupStyleActionSheet]; diff --git a/YuMi/Modules/YMRoom/View/CandyTree/View/XPRoomHalfWebView.h b/YuMi/Modules/YMRoom/View/CandyTree/View/XPRoomHalfWebView.h index f755634d..12d0d0ec 100644 --- a/YuMi/Modules/YMRoom/View/CandyTree/View/XPRoomHalfWebView.h +++ b/YuMi/Modules/YMRoom/View/CandyTree/View/XPRoomHalfWebView.h @@ -18,8 +18,9 @@ NS_ASSUME_NONNULL_BEGIN ///房间uid @property (nonatomic,copy) NSString *roomUid; -///是否是航海 -@property (nonatomic,assign) BOOL isSailing; +///资源位玩法 +@property (nonatomic,assign) BOOL isPlayView; +@property(nonatomic,assign) BOOL isSailing; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/CandyTree/View/XPRoomHalfWebView.m b/YuMi/Modules/YMRoom/View/CandyTree/View/XPRoomHalfWebView.m index 66632cda..1e818c40 100644 --- a/YuMi/Modules/YMRoom/View/CandyTree/View/XPRoomHalfWebView.m +++ b/YuMi/Modules/YMRoom/View/CandyTree/View/XPRoomHalfWebView.m @@ -11,7 +11,7 @@ #import "XPWebViewController.h" #import "XPSkillCardPlayerManager.h" ///Tool - +#import "PIRoomActivityWebView.h" #import "TTPopup.h" @@ -102,6 +102,14 @@ make.top.bottom.mas_equalTo(self.toolView); }]; } +-(void)setIsPlayView:(BOOL)isPlayView{ + _isPlayView = isPlayView; + + [self.stackView mas_remakeConstraints:^(MASConstraintMaker *make) { + make.leading.trailing.bottom.mas_equalTo(self); + make.height.mas_equalTo(643 * kWebViewScale); + }]; +} #pragma mark - Event Response - (void)didClickCloseButton:(UIButton *)sender { [TTPopup dismiss];