diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index b5d3dd8c..73b824d2 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -334,6 +334,9 @@ 9BFB10162897AAB300B3985E /* XPNewUserRechargeSucessView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BFB10152897AAB300B3985E /* XPNewUserRechargeSucessView.m */; }; 9BFB101F2897CC4300B3985E /* XPAnchorCardView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BFB101E2897CC4300B3985E /* XPAnchorCardView.m */; }; 9BFB10222897D68400B3985E /* XPTabAnchorCardModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BFB10212897D68400B3985E /* XPTabAnchorCardModel.m */; }; + 9BFC320A2924BD910002D5A4 /* XPHomeSearchRelateView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BFC32092924BD910002D5A4 /* XPHomeSearchRelateView.m */; }; + 9BFC320E2924CC650002D5A4 /* XPRoomSearchRecommendHeadView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BFC320D2924CC650002D5A4 /* XPRoomSearchRecommendHeadView.m */; }; + 9BFC32152924DACC0002D5A4 /* XPHomeSearchAwardView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BFC32142924DACC0002D5A4 /* XPHomeSearchAwardView.m */; }; 9BFE0D8E2898C8C300F53C24 /* XPAnchorCardSkillCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BFE0D8D2898C8C300F53C24 /* XPAnchorCardSkillCollectionViewCell.m */; }; 9BFE0D922899042600F53C24 /* XPTaskCompleteTipView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BFE0D912899042600F53C24 /* XPTaskCompleteTipView.m */; }; 9BFE992E288142FD009DA429 /* RoomClassifyModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BFE992D288142FD009DA429 /* RoomClassifyModel.m */; }; @@ -1888,6 +1891,12 @@ 9BFB101E2897CC4300B3985E /* XPAnchorCardView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPAnchorCardView.m; sourceTree = ""; }; 9BFB10202897D68400B3985E /* XPTabAnchorCardModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPTabAnchorCardModel.h; sourceTree = ""; }; 9BFB10212897D68400B3985E /* XPTabAnchorCardModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPTabAnchorCardModel.m; sourceTree = ""; }; + 9BFC32082924BD910002D5A4 /* XPHomeSearchRelateView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPHomeSearchRelateView.h; sourceTree = ""; }; + 9BFC32092924BD910002D5A4 /* XPHomeSearchRelateView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPHomeSearchRelateView.m; sourceTree = ""; }; + 9BFC320C2924CC650002D5A4 /* XPRoomSearchRecommendHeadView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomSearchRecommendHeadView.h; sourceTree = ""; }; + 9BFC320D2924CC650002D5A4 /* XPRoomSearchRecommendHeadView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomSearchRecommendHeadView.m; sourceTree = ""; }; + 9BFC32132924DACC0002D5A4 /* XPHomeSearchAwardView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPHomeSearchAwardView.h; sourceTree = ""; }; + 9BFC32142924DACC0002D5A4 /* XPHomeSearchAwardView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPHomeSearchAwardView.m; sourceTree = ""; }; 9BFE0D8C2898C8C300F53C24 /* XPAnchorCardSkillCollectionViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPAnchorCardSkillCollectionViewCell.h; sourceTree = ""; }; 9BFE0D8D2898C8C300F53C24 /* XPAnchorCardSkillCollectionViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPAnchorCardSkillCollectionViewCell.m; sourceTree = ""; }; 9BFE0D902899042600F53C24 /* XPTaskCompleteTipView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPTaskCompleteTipView.h; sourceTree = ""; }; @@ -5196,6 +5205,26 @@ path = AnchorCard; sourceTree = ""; }; + 9BFC320B2924C0410002D5A4 /* HomeSearchRelateView */ = { + isa = PBXGroup; + children = ( + 9BFC32082924BD910002D5A4 /* XPHomeSearchRelateView.h */, + 9BFC32092924BD910002D5A4 /* XPHomeSearchRelateView.m */, + 9BFC320C2924CC650002D5A4 /* XPRoomSearchRecommendHeadView.h */, + 9BFC320D2924CC650002D5A4 /* XPRoomSearchRecommendHeadView.m */, + ); + path = HomeSearchRelateView; + sourceTree = ""; + }; + 9BFC32122924DA930002D5A4 /* HomeSearchHijack */ = { + isa = PBXGroup; + children = ( + 9BFC32132924DACC0002D5A4 /* XPHomeSearchAwardView.h */, + 9BFC32142924DACC0002D5A4 /* XPHomeSearchAwardView.m */, + ); + path = HomeSearchHijack; + sourceTree = ""; + }; 9BFE0D8F289903F600F53C24 /* TaskTip */ = { isa = PBXGroup; children = ( @@ -8270,6 +8299,8 @@ E8C6FFD12754AA6A004DC9F0 /* SubViews */ = { isa = PBXGroup; children = ( + 9BFC32122924DA930002D5A4 /* HomeSearchHijack */, + 9BFC320B2924C0410002D5A4 /* HomeSearchRelateView */, E8C6FFD22754AA87004DC9F0 /* XPNoteView.h */, E8C6FFD32754AA87004DC9F0 /* XPNoteView.m */, E8C6FFD52754BC61004DC9F0 /* XPHomeNavView.h */, @@ -9943,6 +9974,7 @@ E8EEB90F26FC6AB8007C6EBA /* XPMineUserInfoEditPresenter.m in Sources */, E873EB09280960990071030D /* XPMineUserInfoVoiceCardView.m in Sources */, E8AC723A26F49AAE007D6E91 /* XPMineNotifyStatus.m in Sources */, + 9BFC320E2924CC650002D5A4 /* XPRoomSearchRecommendHeadView.m in Sources */, E8F6135F291E274E00E12650 /* NSArray+Safe.m in Sources */, 18E7B33226F317A20064BC9B /* XPWebViewController.m in Sources */, E8AEAEF927141CA30017FCE0 /* RoomHeaderView.m in Sources */, @@ -10076,6 +10108,7 @@ E8A03DF62763367F0098D9EA /* XPCandyTreeEmptyableViewCell.m in Sources */, E8AEAEED27141AE20017FCE0 /* XPRoomBackContainerView.m in Sources */, E88B5CC126FB407B00DA9178 /* XPMineUserInfoViewController.m in Sources */, + 9BFC32152924DACC0002D5A4 /* XPHomeSearchAwardView.m in Sources */, E81E09CF290F750800A1F410 /* AdvertiseModel.m in Sources */, E852D74428633A08001465ED /* MonentsCommentModel.m in Sources */, E8C1CD6D27D8938C00376F83 /* XPRoomFaceTitleCollectionViewCell.m in Sources */, @@ -10103,6 +10136,7 @@ E80016422804228100D6D17A /* XPGuildIncomePresenter.m in Sources */, E8E5E1A927C3850400F457D8 /* XPHomeHotRoomCollectionViewCell.m in Sources */, 9B0997A327F19DE500EB8F14 /* QGHWDShaders.metal in Sources */, + 9BFC320A2924BD910002D5A4 /* XPHomeSearchRelateView.m in Sources */, 187EEEE126E89BFB002833B2 /* AccountModel.m in Sources */, E87C54C22823CD6F0051AA11 /* XPMineResetLoginPwdViewController.m in Sources */, E8098CA7282E00920090B9F0 /* Api+Monents.m in Sources */, diff --git a/xplan-ios/Main/Home/Presenter/XPHomeSearchPresenter.h b/xplan-ios/Main/Home/Presenter/XPHomeSearchPresenter.h index 5d5f24d8..12b4d96a 100644 --- a/xplan-ios/Main/Home/Presenter/XPHomeSearchPresenter.h +++ b/xplan-ios/Main/Home/Presenter/XPHomeSearchPresenter.h @@ -16,6 +16,9 @@ NS_ASSUME_NONNULL_BEGIN /// @param type 类型 1 房间 2 用户 - (void)searchRoomList:(NSString *)key type:(NSString *)type; +/// 获取首页推荐列表 +- (void)getHomeRecommendRoomList; + @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Home/Presenter/XPHomeSearchPresenter.m b/xplan-ios/Main/Home/Presenter/XPHomeSearchPresenter.m index 04be731c..581a2005 100644 --- a/xplan-ios/Main/Home/Presenter/XPHomeSearchPresenter.m +++ b/xplan-ios/Main/Home/Presenter/XPHomeSearchPresenter.m @@ -8,7 +8,9 @@ #import "XPHomeSearchPresenter.h" #import "Api+Home.h" #import "XPHomeSearchProtocol.h" +#import "AccountInfoStorage.h" #import "HomeSearchResultModel.h" +#import "HomeRecommendRoomModel.h" @implementation XPHomeSearchPresenter @@ -19,8 +21,19 @@ - (void)searchRoomList:(NSString *)key type:(NSString *)type { [Api searchComplection:[self createHttpCompletion:^(BaseModel * _Nonnull data) { NSArray * array = [HomeSearchResultModel modelsWithArray:data.data]; - [[self getView] searchRoomSuccess:array]; + [[self getView] searchRoomSuccess:array type:type]; } showLoading:YES] key:key type:type page:@"1" pageSize:@"50"]; } +/// 获取首页推荐列表 +- (void)getHomeRecommendRoomList { + NSString * uid = [AccountInfoStorage instance].getUid; + [Api homeRecommendRoomList:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + NSArray * array = [HomeRecommendRoomModel modelsWithArray:data.data]; + [[self getView] searchRoomGetRecommendSuccess:array]; + }fail:^(NSInteger code, NSString * _Nullable msg) { + [[self getView] searchRoomGetRecommendFail]; + }] uid:uid]; +} + @end diff --git a/xplan-ios/Main/Home/Presenter/XPInRoomRecordPresenter.h b/xplan-ios/Main/Home/Presenter/XPInRoomRecordPresenter.h index 4b3f6cd7..ea9e29ce 100644 --- a/xplan-ios/Main/Home/Presenter/XPInRoomRecordPresenter.h +++ b/xplan-ios/Main/Home/Presenter/XPInRoomRecordPresenter.h @@ -17,6 +17,9 @@ NS_ASSUME_NONNULL_BEGIN /// 清除进房记录 - (void)cleanInRoomRecord; +///大家都在搜 +- (void)getEveryoneSearchList; + @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Home/Presenter/XPInRoomRecordPresenter.m b/xplan-ios/Main/Home/Presenter/XPInRoomRecordPresenter.m index ea95d9ce..834decce 100644 --- a/xplan-ios/Main/Home/Presenter/XPInRoomRecordPresenter.m +++ b/xplan-ios/Main/Home/Presenter/XPInRoomRecordPresenter.m @@ -31,4 +31,13 @@ }] uid:uid roomUid:NULL]; } +///大家都在搜 +- (void)getEveryoneSearchList { + NSString *uid = [AccountInfoStorage instance].getUid; + [Api requestEveryoneSearch:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + NSArray *array = [XPMineFootPrintModel modelsWithArray:data.data]; + [[self getView] getEveryoneSearchListSuccess:array]; + }] uid:uid]; +} + @end diff --git a/xplan-ios/Main/Home/Protocol/XPHomeSearchProtocol.h b/xplan-ios/Main/Home/Protocol/XPHomeSearchProtocol.h index 5f0144fe..86ea87b6 100644 --- a/xplan-ios/Main/Home/Protocol/XPHomeSearchProtocol.h +++ b/xplan-ios/Main/Home/Protocol/XPHomeSearchProtocol.h @@ -11,8 +11,13 @@ NS_ASSUME_NONNULL_BEGIN @protocol XPHomeSearchProtocol -///搜索房间成功 -- (void)searchRoomSuccess:(NSArray *)data; +///搜索成功 +- (void)searchRoomSuccess:(NSArray *)data type:(NSString *)type; + +///搜索页获取推荐房间成功 +- (void)searchRoomGetRecommendSuccess:(NSArray *)data; +///搜索页获取推荐房间失败 +- (void)searchRoomGetRecommendFail; @end diff --git a/xplan-ios/Main/Home/Protocol/XPInRoomRecordProtocol.h b/xplan-ios/Main/Home/Protocol/XPInRoomRecordProtocol.h index 62198747..624afec4 100644 --- a/xplan-ios/Main/Home/Protocol/XPInRoomRecordProtocol.h +++ b/xplan-ios/Main/Home/Protocol/XPInRoomRecordProtocol.h @@ -27,4 +27,7 @@ ///清除进房记录成功 - (void)cleanInRoomRecordSuccess; +///获取大家都在搜列表成功 +- (void)getEveryoneSearchListSuccess:(NSArray *)array; + @end diff --git a/xplan-ios/Main/Home/View/SubViews/HomeSearchHijack/XPHomeSearchAwardView.h b/xplan-ios/Main/Home/View/SubViews/HomeSearchHijack/XPHomeSearchAwardView.h new file mode 100644 index 00000000..aca5b23c --- /dev/null +++ b/xplan-ios/Main/Home/View/SubViews/HomeSearchHijack/XPHomeSearchAwardView.h @@ -0,0 +1,16 @@ +// +// XPHomeSearchAwardView.h +// xplan-ios +// +// Created by GreenLand on 2022/11/16. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface XPHomeSearchAwardView : UIView + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Home/View/SubViews/HomeSearchHijack/XPHomeSearchAwardView.m b/xplan-ios/Main/Home/View/SubViews/HomeSearchHijack/XPHomeSearchAwardView.m new file mode 100644 index 00000000..05039100 --- /dev/null +++ b/xplan-ios/Main/Home/View/SubViews/HomeSearchHijack/XPHomeSearchAwardView.m @@ -0,0 +1,141 @@ +// +// XPHomeSearchAwardView.m +// xplan-ios +// +// Created by GreenLand on 2022/11/16. +// + +#import "XPHomeSearchAwardView.h" +#import "Masonry/Masonry.h" +#import "ThemeColor.h" +#import "XPMacro.h" +#import "NetImageView.h" +#import "TTPopup.h" + +@interface XPHomeSearchAwardView() + +///奖励标题 +@property (nonatomic, strong) UILabel *awardTitle; +///关闭 +@property (nonatomic, strong) UIButton *closeBtn; +///奖励icon +@property (nonatomic, strong) NetImageView *awardImageView; +///礼物名称 +@property (nonatomic, strong) UILabel *giftTitle; +///描述 +@property (nonatomic, strong) UILabel *giftDes; + +@end + +@implementation XPHomeSearchAwardView + +- (instancetype)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + [self initView]; + [self initContraints]; + } + return self; +} + +- (void)initView { + self.backgroundColor = [UIColor whiteColor]; + [self addSubview:self.awardTitle]; + [self addSubview:self.closeBtn]; + [self addSubview:self.awardImageView]; + [self addSubview:self.giftTitle]; + [self addSubview:self.giftDes]; +} + +- (void)initContraints { + [self mas_makeConstraints:^(MASConstraintMaker *make) { + make.size.mas_equalTo(CGSizeMake(300, 220)); + }]; + [self.awardTitle mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(16); + make.height.mas_equalTo(22); + make.centerX.mas_equalTo(self); + make.right.mas_equalTo(self.closeBtn.mas_left).mas_offset(-5); + }]; + [self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(13); + make.right.mas_equalTo(-15); + make.width.height.mas_equalTo(20); + }]; + [self.awardImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.awardTitle.mas_bottom).mas_offset(17); + make.centerX.mas_equalTo(self); + make.size.mas_equalTo(CGSizeMake(112, 90)); + }]; + [self.giftTitle mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.awardImageView.mas_bottom).mas_offset(11); + make.centerX.mas_equalTo(self); + make.height.mas_equalTo(20); + make.left.mas_equalTo(8); + }]; + [self.giftDes mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.giftTitle.mas_bottom).mas_offset(4); + make.centerX.mas_equalTo(self); + make.height.mas_equalTo(17); + make.left.mas_equalTo(8); + }]; +} + +- (void)onCloseBtnClick:(UIButton *)sender { + [TTPopup dismiss]; +} + +#pragma mark - getter +- (UILabel *)awardTitle { + if (!_awardTitle) { + UILabel *label = [[UILabel alloc] init]; + label.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]; + label.textColor = [ThemeColor mainTextColor]; + _awardTitle = label; + } + return _awardTitle; +} + +- (UIButton *)closeBtn { + if (!_closeBtn) { + _closeBtn = [UIButton buttonWithType:UIButtonTypeCustom]; + [_closeBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal]; + [_closeBtn addTarget:self action:@selector(onCloseBtnClick:) forControlEvents:UIControlEventTouchUpInside]; + } + return _closeBtn; +} + +- (NetImageView *)awardImageView { + if (!_awardImageView) { + NetImageConfig *config = [[NetImageConfig alloc] init]; + config.placeHolder = [UIImageConstant defaultEmptyAvatarPlaceholder]; + _awardImageView = [[NetImageView alloc] initWithConfig:config]; + _awardImageView.layer.masksToBounds = YES; + _awardImageView.layer.cornerRadius = 8; + } + return _awardImageView; +} + +- (UILabel *)giftTitle { + if (!_giftTitle) { + UILabel *label = [[UILabel alloc] init]; + label.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium]; + label.textColor = [ThemeColor mainTextColor]; + _giftTitle = label; + } + return _giftTitle; +} + +- (UILabel *)giftDes { + if (!_giftDes) { + UILabel *label = [[UILabel alloc] init]; + label.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium]; + label.textColor = [ThemeColor secondTextColor]; + label.text = @"奖励已自动发放"; + _giftDes = label; + } + return _giftDes; +} + +@end diff --git a/xplan-ios/Main/Home/View/SubViews/HomeSearchRelateView/XPHomeSearchRelateView.h b/xplan-ios/Main/Home/View/SubViews/HomeSearchRelateView/XPHomeSearchRelateView.h new file mode 100644 index 00000000..0dd946f6 --- /dev/null +++ b/xplan-ios/Main/Home/View/SubViews/HomeSearchRelateView/XPHomeSearchRelateView.h @@ -0,0 +1,28 @@ +// +// XPHomeSearchRelateView.h +// xplan-ios +// +// Created by GreenLand on 2022/11/16. +// + +#import + +NS_ASSUME_NONNULL_BEGIN +@protocol XPHomeSearchRelateViewDelegate + +///进入房间 +- (void)xPHomeSearchRelateViewEnterRoom:(NSString *)roomUid; + +@end + +@interface XPHomeSearchRelateView : UIView + +@property (nonatomic, strong) NSArray *relateArray; + +@property (nonatomic, strong) NSArray *recommendArray; + +@property (nonatomic, weak) id delegate; + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Home/View/SubViews/HomeSearchRelateView/XPHomeSearchRelateView.m b/xplan-ios/Main/Home/View/SubViews/HomeSearchRelateView/XPHomeSearchRelateView.m new file mode 100644 index 00000000..2fdca0f8 --- /dev/null +++ b/xplan-ios/Main/Home/View/SubViews/HomeSearchRelateView/XPHomeSearchRelateView.m @@ -0,0 +1,175 @@ +// +// XPHomeSearchRelateView.m +// xplan-ios +// +// Created by GreenLand on 2022/11/16. +// + +#import "XPHomeSearchRelateView.h" +#import "Masonry/Masonry.h" +#import "NSArray+Safe.h" +#import "ThemeColor.h" +#import "XPMacro.h" +///view +#import "XPSearchListTableViewCell.h" +#import "XPHomeRedommendCollectionViewCell.h" +#import "XPRoomSearchRecommendHeadView.h" +///Model +#import "HomeSearchResultModel.h" +#import "HomeRecommendRoomModel.h" + +@interface XPHomeSearchRelateView() + +@property (nonatomic, strong) UILabel *relateTitle; +@property (nonatomic, strong) UITableView *tableView; +@property (nonatomic, strong) UICollectionView *collectionView; + +@end + +@implementation XPHomeSearchRelateView + +- (instancetype)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + [self initView]; + [self initContraints]; + } + return self; +} + +- (void)initView { + self.backgroundColor = [ThemeColor appBackgroundColor]; + [self addSubview:self.relateTitle]; + [self addSubview:self.tableView]; + [self addSubview:self.collectionView]; +} + +- (void)initContraints { + [self.relateTitle mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(16); + make.left.mas_equalTo(15); + make.height.mas_equalTo(20); + }]; + [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.bottom.mas_equalTo(0); + make.top.mas_equalTo(self.relateTitle.mas_bottom).mas_offset(16); + }]; + [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(0); + }]; +} +#pragma mark - tableviewDelegate +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return self.relateArray.count; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + XPSearchListTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPSearchListTableViewCell class])]; + if (cell == nil) { + cell = [[XPSearchListTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPSearchListTableViewCell class])]; + } + HomeSearchResultModel * resultModel = [self.relateArray safeObjectAtIndex1:indexPath.row]; + [cell configData:resultModel type:1]; + return cell; +} + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + HomeSearchResultModel * resultModel = [self.relateArray safeObjectAtIndex1:indexPath.row]; + if (self.delegate && [self.delegate respondsToSelector:@selector(xPHomeSearchRelateViewEnterRoom:)]) { + [self.delegate xPHomeSearchRelateViewEnterRoom:resultModel.uid]; + } +} + +#pragma mark - collectionViewDelegate +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { + return self.recommendArray.count; +} + +- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { + XPHomeRedommendCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPHomeRedommendCollectionViewCell class]) forIndexPath:indexPath]; + HomeRecommendRoomModel * info = [self.recommendArray safeObjectAtIndex1:indexPath.row]; + cell.recommendRoomInfo = info; + return cell; +} + +- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { + return CGSizeMake(100 * kScreenScale, 100 * kScreenScale); +} + +- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath { + XPRoomSearchRecommendHeadView *headView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:NSStringFromClass([XPRoomSearchRecommendHeadView class]) forIndexPath:indexPath]; + return headView; +} + +- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { + [collectionView deselectItemAtIndexPath:indexPath animated:YES]; + if (self.recommendArray.count > 0) { + HomeRecommendRoomModel * recommend = [self.recommendArray safeObjectAtIndex1:indexPath.row]; + if (self.delegate && [self.delegate respondsToSelector:@selector(xPHomeSearchRelateViewEnterRoom:)]) { + [self.delegate xPHomeSearchRelateViewEnterRoom:recommend.roomUid]; + } + } +} + +- (void)setRelateArray:(NSArray *)relateArray { + _relateArray = relateArray; + [self.tableView reloadData]; + self.collectionView.hidden = YES; + self.relateTitle.hidden = NO; + self.tableView.hidden = NO; +} + +- (void)setRecommendArray:(NSArray *)recommendArray { + _recommendArray = recommendArray; + [self.collectionView reloadData]; + self.collectionView.hidden = NO; + self.relateTitle.hidden = YES; + self.tableView.hidden = YES; +} + +- (UILabel *)relateTitle { + if (!_relateTitle) { + UILabel *label = [[UILabel alloc] init]; + label.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium]; +// label.textColor = [ThemeColor mainTextColor]; + label.text = @"相关房间"; + _relateTitle = label; + } + return _relateTitle; +} + +- (UITableView *)tableView { + if (!_tableView) { + _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; + _tableView.delegate = self; + _tableView.dataSource = self; + _tableView.tableHeaderView = [UIView new]; + _tableView.tableFooterView = [UIView new]; + _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; + _tableView.backgroundColor = [UIColor clearColor]; + _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; + [_tableView registerClass:[XPSearchListTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPSearchListTableViewCell class])]; + } + return _tableView; +} + +- (UICollectionView *)collectionView{ + if (!_collectionView) { + UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; + layout.headerReferenceSize = CGSizeMake(KScreenWidth, 200); + layout.minimumLineSpacing = 8; + layout.minimumInteritemSpacing = 0; + layout.scrollDirection = UICollectionViewScrollDirectionVertical; + layout.sectionInset = UIEdgeInsetsMake(15, 15, 0, 15); + _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; + _collectionView.dataSource = self; + _collectionView.delegate = self; + _collectionView.backgroundColor = [UIColor clearColor]; + [_collectionView registerClass:[XPHomeRedommendCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPHomeRedommendCollectionViewCell class])]; + [_collectionView registerClass:[XPRoomSearchRecommendHeadView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:NSStringFromClass([XPRoomSearchRecommendHeadView class])]; + } + return _collectionView; +} + +@end diff --git a/xplan-ios/Main/Home/View/SubViews/HomeSearchRelateView/XPRoomSearchRecommendHeadView.h b/xplan-ios/Main/Home/View/SubViews/HomeSearchRelateView/XPRoomSearchRecommendHeadView.h new file mode 100644 index 00000000..65f470ee --- /dev/null +++ b/xplan-ios/Main/Home/View/SubViews/HomeSearchRelateView/XPRoomSearchRecommendHeadView.h @@ -0,0 +1,16 @@ +// +// XPRoomSearchRecommendHeadView.h +// xplan-ios +// +// Created by GreenLand on 2022/11/16. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface XPRoomSearchRecommendHeadView : UICollectionReusableView + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Home/View/SubViews/HomeSearchRelateView/XPRoomSearchRecommendHeadView.m b/xplan-ios/Main/Home/View/SubViews/HomeSearchRelateView/XPRoomSearchRecommendHeadView.m new file mode 100644 index 00000000..d33ab18b --- /dev/null +++ b/xplan-ios/Main/Home/View/SubViews/HomeSearchRelateView/XPRoomSearchRecommendHeadView.m @@ -0,0 +1,68 @@ +// +// XPRoomSearchRecommendHeadView.m +// xplan-ios +// +// Created by GreenLand on 2022/11/16. +// + +#import "XPRoomSearchRecommendHeadView.h" +#import "Masonry/Masonry.h" +#import "ThemeColor.h" +#import "XPMacro.h" + +@interface XPRoomSearchRecommendHeadView() + +@property (nonatomic, strong) UILabel *emptyTitle; +@property (nonatomic, strong) UILabel *recommentTitle; + +@end + +@implementation XPRoomSearchRecommendHeadView + +- (instancetype)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + [self initView]; + [self initContraints]; + } + return self; +} + +- (void)initView { + [self addSubview:self.emptyTitle]; + [self addSubview:self.recommentTitle]; +} + +- (void)initContraints { + [self.emptyTitle mas_makeConstraints:^(MASConstraintMaker *make) { + make.center.mas_equalTo(self); + }]; + [self.recommentTitle mas_makeConstraints:^(MASConstraintMaker *make) { + make.bottom.mas_equalTo(self); + make.left.mas_equalTo(16); + }]; +} + +- (UILabel *)emptyTitle { + if (!_emptyTitle) { + UILabel *label = [[UILabel alloc] init]; + label.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium]; + label.textColor = [ThemeColor textThirdColor]; + label.text = @"暂无开播厅房~"; + _emptyTitle = label; + } + return _emptyTitle; +} + +- (UILabel *)recommentTitle { + if (!_recommentTitle) { + UILabel *label = [[UILabel alloc] init]; + label.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium]; + label.textColor = [ThemeColor mainTextColor]; + label.text = @"为你推荐"; + _recommentTitle = label; + } + return _recommentTitle; +} +@end diff --git a/xplan-ios/Main/Home/View/XPHomeSearchViewController.m b/xplan-ios/Main/Home/View/XPHomeSearchViewController.m index 881354f9..0633a15d 100644 --- a/xplan-ios/Main/Home/View/XPHomeSearchViewController.m +++ b/xplan-ios/Main/Home/View/XPHomeSearchViewController.m @@ -111,9 +111,11 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; } #pragma mark - XPHomeSearchProtocol -- (void)searchRoomSuccess:(NSArray *)data { - self.datasource = data; - [self.tableView reloadData]; +- (void)searchRoomSuccess:(NSArray *)data type:(nonnull NSString *)type { + if (type.integerValue == self.type) { + self.datasource = data; + [self.tableView reloadData]; + } } #pragma mark - diff --git a/xplan-ios/Main/Home/View/XPRoomSearchContainerViewController.h b/xplan-ios/Main/Home/View/XPRoomSearchContainerViewController.h index 9536ecc8..8e67eb7b 100644 --- a/xplan-ios/Main/Home/View/XPRoomSearchContainerViewController.h +++ b/xplan-ios/Main/Home/View/XPRoomSearchContainerViewController.h @@ -5,11 +5,11 @@ // Created by 冯硕 on 2021/12/2. // -#import "BaseViewController.h" +#import "MvpViewController.h" NS_ASSUME_NONNULL_BEGIN -@interface XPRoomSearchContainerViewController : BaseViewController +@interface XPRoomSearchContainerViewController : MvpViewController @end diff --git a/xplan-ios/Main/Home/View/XPRoomSearchContainerViewController.m b/xplan-ios/Main/Home/View/XPRoomSearchContainerViewController.m index 58eff304..f76d7a4a 100644 --- a/xplan-ios/Main/Home/View/XPRoomSearchContainerViewController.m +++ b/xplan-ios/Main/Home/View/XPRoomSearchContainerViewController.m @@ -17,11 +17,16 @@ ///View #import "XPHomeSearchViewController.h" #import "XPRoomSearchRecordViewController.h" +#import "XPHomeSearchRelateView.h" +#import "XPRoomViewController.h" +///P +#import "XPHomeSearchPresenter.h" +#import "XPHomeSearchProtocol.h" UIKIT_EXTERN NSString *kFromSearchToHomeViewKey; UIKIT_EXTERN NSString *kTabShowAnchorCardKey; -@interface XPRoomSearchContainerViewController () +@interface XPRoomSearchContainerViewController () ///分页标题 @property (nonatomic, strong) NSArray *titles; ///分页控件 @@ -36,11 +41,18 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; @property (nonatomic,strong) XPHomeSearchViewController *userVC; ///进房、搜索记录 @property (nonatomic, strong) XPRoomSearchRecordViewController *recordVc; +///相关房间 +@property (nonatomic, strong) XPHomeSearchRelateView *relateView; @end @implementation XPRoomSearchContainerViewController + +- (XPHomeSearchPresenter *)createPresenter { + return [[XPHomeSearchPresenter alloc] init]; +} + - (BOOL)isHiddenNavBar { return YES; } @@ -141,6 +153,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; - (void)xPHomeSearchNavViewClearTextField:(XPHomeSearchNavView *)view { self.recordVc.view.hidden = NO; [self.recordVc updateSearchRecord]; + [self.relateView removeFromSuperview]; } #pragma mark - XPRoomSearchRecordViewControllerDelegate @@ -155,6 +168,57 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; } } +///大家都在搜 +- (void)xPRoomSearchRecordViewControllerEveryoneSearch:(NSString *)word { + self.searchView.searchTextField.text = word; + [self.recordVc storeSearchRecord:word]; + [self.presenter searchRoomList:word type:@"3"]; +} + +#pragma mark - XPHomeSearchProtocol +- (void)searchRoomSuccess:(NSArray *)data type:(nonnull NSString *)type { + if (type.integerValue == 3) { + if (data.count) {//有值,显示列表 + [self.view addSubview:self.relateView]; + [self.relateView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.bottom.mas_equalTo(0); + make.top.mas_equalTo(self.searchView.mas_bottom); + }]; + self.relateView.relateArray = data; + } else {//无数据,显示推荐房间 + [self.presenter getHomeRecommendRoomList]; + } + } +} + +- (void)searchRoomGetRecommendSuccess:(NSArray *)data { + if (data.count) {//有值,显示列表 + [self.view addSubview:self.relateView]; + [self.relateView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.bottom.mas_equalTo(0); + make.top.mas_equalTo(self.searchView.mas_bottom); + }]; + self.relateView.recommendArray = data; + } +} + +- (void)searchRoomGetRecommendFail { + +} + +#pragma mark - XPHomeSearchRelateViewDelegate +///进入房间 +- (void)xPHomeSearchRelateViewEnterRoom:(NSString *)roomUid { + BOOL result = [[NSUserDefaults standardUserDefaults] boolForKey:kFromSearchToHomeViewKey]; + if (!result) { + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:kFromSearchToHomeViewKey]; + [[NSUserDefaults standardUserDefaults] synchronize]; + [[NSNotificationCenter defaultCenter] postNotificationName:kTabShowAnchorCardKey object:@{@"delayShow" : @(YES)}]; + } + [self dismissViewControllerAnimated:YES completion:nil]; + [XPRoomViewController openRoom:roomUid viewController:self.presentingViewController]; +} + #pragma mark - Getters And Setters - (JXCategoryTitleView *)titleView { if (!_titleView) { @@ -225,4 +289,12 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; return _recordVc; } +- (XPHomeSearchRelateView *)relateView { + if (!_relateView) { + _relateView = [[XPHomeSearchRelateView alloc] init]; + _relateView.delegate = self; + } + return _relateView; +} + @end diff --git a/xplan-ios/Main/Home/View/XPRoomSearchRecordViewController.h b/xplan-ios/Main/Home/View/XPRoomSearchRecordViewController.h index 933cfd63..f054cf99 100644 --- a/xplan-ios/Main/Home/View/XPRoomSearchRecordViewController.h +++ b/xplan-ios/Main/Home/View/XPRoomSearchRecordViewController.h @@ -11,8 +11,12 @@ NS_ASSUME_NONNULL_BEGIN @protocol XPRoomSearchRecordViewControllerDelegate +///搜索 - (void)xPRoomSearchRecordViewControllerSearchWithWord:(NSString *)word; +///点击了大家都在搜 +- (void)xPRoomSearchRecordViewControllerEveryoneSearch:(NSString *)word; + @end @interface XPRoomSearchRecordViewController : MvpViewController diff --git a/xplan-ios/Main/Home/View/XPRoomSearchRecordViewController.m b/xplan-ios/Main/Home/View/XPRoomSearchRecordViewController.m index fd482bf5..ab2867da 100644 --- a/xplan-ios/Main/Home/View/XPRoomSearchRecordViewController.m +++ b/xplan-ios/Main/Home/View/XPRoomSearchRecordViewController.m @@ -30,7 +30,7 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey"; @property (nonatomic, strong) UIStackView *contentStackView; ///大家都在搜 -@property (nonatomic, strong) UIView *everyoneSearchContentView; +@property (nonatomic, strong) UIView *allSearchContentView; ///大家都在搜标题 @property (nonatomic, strong) UILabel *everyOneTitle; @property (nonatomic, strong) UICollectionView *everyOneCollectionView; @@ -38,6 +38,8 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey"; @property (nonatomic, strong) UIView *searchContentView; ///进房记录容器 @property (nonatomic, strong) UIView *roomContentView; +///填充占位view +@property (nonatomic, strong) UIView *placeHolderView; ///搜索记录 @property (nonatomic, strong) UILabel *recordTitle; ///清空搜索记录 @@ -54,6 +56,8 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey"; @property (nonatomic, strong) NSMutableArray *searchList; ///进房记录数据源 @property (nonatomic, strong) NSMutableArray *inRoomList; +///大家都在搜数据源 +@property (nonatomic, strong) NSMutableArray *everyoneSearchList; @end @@ -69,27 +73,17 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey"; [self initSubViewConstraints]; [self initSearchRecordData]; [self.presenter getInRoomRecordList]; + [self.presenter getEveryoneSearchList]; } - (void)initSearchRecordData { [self.searchList removeAllObjects]; NSArray *array = [self searchRecordList]; [self.searchList addObjectsFromArray:array]; + self.searchContentView.hidden = array.count == 0; [self.searchCollectionView reloadData]; - if (!array.count) { - [self.searchContentView mas_updateConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(0); - }]; - self.searchContentView.hidden = YES; - } else { - self.searchContentView.hidden = NO; - [self.searchContentView mas_updateConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(30+26+8); - }]; - } } - - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [self.view endEditing:YES]; } @@ -98,12 +92,13 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey"; - (void)initSubViews { [self.view addSubview:self.contentStackView]; - [self.contentStackView addArrangedSubview:self.everyoneSearchContentView]; + [self.contentStackView addArrangedSubview:self.allSearchContentView]; [self.contentStackView addArrangedSubview:self.searchContentView]; [self.contentStackView addArrangedSubview:self.roomContentView]; + [self.contentStackView addArrangedSubview:self.placeHolderView]; - [self.everyoneSearchContentView addSubview:self.everyOneTitle]; - [self.everyoneSearchContentView addSubview:self.everyOneCollectionView]; + [self.allSearchContentView addSubview:self.everyOneTitle]; + [self.allSearchContentView addSubview:self.everyOneCollectionView]; [self.searchContentView addSubview:self.recordTitle]; [self.searchContentView addSubview:self.clearRecordBtn]; @@ -115,32 +110,31 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey"; - (void)initSubViewConstraints { [self.contentStackView mas_makeConstraints:^(MASConstraintMaker *make) { - make.top.right.left.bottom.mas_equalTo(0); + make.top.right.left.bottom.mas_equalTo(self.view); }]; - [self.everyoneSearchContentView mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.mas_equalTo(0); + [self.allSearchContentView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.top.mas_equalTo(0); + make.bottom.mas_equalTo(self.everyOneCollectionView); }]; [self.everyOneTitle mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.mas_equalTo(self.everyoneSearchContentView).mas_offset(16); - make.top.mas_equalTo(self.everyoneSearchContentView).mas_offset(10); + make.left.mas_equalTo(self.allSearchContentView).mas_offset(16); + make.top.mas_equalTo(self.allSearchContentView).mas_offset(16); make.height.mas_equalTo(20); }]; [self.everyOneCollectionView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.mas_equalTo(self.everyoneSearchContentView); + make.left.right.mas_equalTo(self.allSearchContentView); make.top.mas_equalTo(self.everyOneTitle.mas_bottom).mas_offset(8); - make.bottom.mas_equalTo(self.everyoneSearchContentView.mas_bottom).mas_offset(-8); - make.height.mas_equalTo(75); + make.height.mas_equalTo(26); }]; [self.searchContentView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.mas_equalTo(0); - make.top.mas_equalTo(0); - make.height.mas_equalTo(30+26+8); + make.bottom.mas_equalTo(self.searchCollectionView.mas_bottom); }]; [self.recordTitle mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(16); - make.top.mas_equalTo(self.searchContentView).mas_offset(10); + make.top.mas_equalTo(self.searchContentView).mas_offset(20); make.height.mas_equalTo(20); }]; [self.clearRecordBtn mas_makeConstraints:^(MASConstraintMaker *make) { @@ -156,13 +150,12 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey"; [self.roomContentView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.mas_equalTo(0); - make.top.mas_equalTo(self.searchContentView.mas_bottom).mas_offset(24); make.bottom.mas_equalTo(self.roomCollectionView.mas_bottom); }]; [self.roomTitle mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(16); - make.top.mas_equalTo(self.roomContentView); + make.top.mas_equalTo(self.roomContentView).mas_offset(20); make.height.mas_equalTo(20); }]; [self.clearRoomBtn mas_makeConstraints:^(MASConstraintMaker *make) { @@ -181,8 +174,10 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey"; - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { if (collectionView == self.searchCollectionView) { return self.searchList.count; - } else { + } else if (collectionView == self.roomCollectionView) { return self.inRoomList.count; + } else { + return self.everyoneSearchList.count; } } @@ -193,7 +188,7 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey"; return cell; } else if (collectionView == self.everyOneCollectionView) { XPHomeSearchRecordCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPHomeSearchRecordCell class]) forIndexPath:indexPath]; - cell.recordString = [self.searchList safeObjectAtIndex1:indexPath.row]; + cell.recordString = [self.everyoneSearchList safeObjectAtIndex1:indexPath.row]; return cell; } else { XPHomeAttentionCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPHomeAttentionCollectionViewCell class]) forIndexPath:indexPath]; @@ -209,7 +204,10 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey"; [self.delegate xPRoomSearchRecordViewControllerSearchWithWord:str]; } } else if (collectionView == self.everyOneCollectionView) { - + NSString *str = self.searchList[indexPath.row]; + if (self.delegate && [self.delegate respondsToSelector:@selector(xPRoomSearchRecordViewControllerEveryoneSearch:)]) { + [self.delegate xPRoomSearchRecordViewControllerEveryoneSearch:str]; + } } else { XPMineFootPrintModel *resultModel = self.inRoomList[indexPath.row]; [self dismissViewControllerAnimated:YES completion:nil]; @@ -228,6 +226,10 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey"; NSString *str = [self.searchList safeObjectAtIndex1:indexPath.row]; CGFloat width = [str boundingRectWithSize:CGSizeMake(200, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:12]} context:nil].size.width; return CGSizeMake(width + 26, 26); + } else if(collectionView == self.everyOneCollectionView){ + NSString *str = [self.everyoneSearchList safeObjectAtIndex1:indexPath.row]; + CGFloat width = [str boundingRectWithSize:CGSizeMake(200, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:12]} context:nil].size.width; + return CGSizeMake(width + 26, 26); } else { return CGSizeMake(56, 75); } @@ -275,6 +277,14 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey"; [self initSearchRecordData]; } +///获取大家都在搜列表成功 +- (void)getEveryoneSearchListSuccess:(NSArray *)array { + [self.everyoneSearchList removeAllObjects]; + [self.everyoneSearchList addObjectsFromArray:array]; + self.allSearchContentView.hidden = array.count == 0; + [self.everyOneCollectionView reloadData]; +} + ///获取进房记录成功 - (void)getInRoomRecordSuccess:(NSArray *)array { [self.inRoomList removeAllObjects]; @@ -302,9 +312,6 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey"; [self cleanSearchRecord]; [self.searchList removeAllObjects]; [self.searchCollectionView reloadData]; - [self.searchContentView mas_updateConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(0); - }]; self.searchContentView.hidden = YES; } cancelHandler:^{ }]; @@ -326,18 +333,20 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey"; if (!_contentStackView) { _contentStackView = [[UIStackView alloc] init]; _contentStackView.axis = UILayoutConstraintAxisVertical; -// _contentStackView.distribution = UIStackViewDistributionFill; -// _contentStackView.alignment = UIStackViewAlignmentFill; + _contentStackView.distribution = UIStackViewDistributionFill; + _contentStackView.alignment = UIStackViewAlignmentFill; + _contentStackView.alignment = UIStackViewAlignmentCenter; _contentStackView.spacing = 0; } return _contentStackView; } -- (UIView *)everyoneSearchContentView { - if (!_everyoneSearchContentView) { - _everyoneSearchContentView = [[UIView alloc] init]; +- (UIView *)allSearchContentView { + if (!_allSearchContentView) { + _allSearchContentView = [[UIView alloc] init]; + _allSearchContentView.hidden = YES; } - return _everyoneSearchContentView; + return _allSearchContentView; } @@ -459,6 +468,13 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey"; return _inRoomList; } +- (NSMutableArray *)everyoneSearchList { + if (!_everyoneSearchList) { + _everyoneSearchList = [NSMutableArray array]; + } + return _everyoneSearchList; +} + - (UIView *)searchContentView { if (!_searchContentView) { _searchContentView = [[UIView alloc] init]; @@ -473,5 +489,14 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey"; return _roomContentView; } +- (UIView *)placeHolderView { + if (!_placeHolderView) { + _placeHolderView = [[UIView alloc] init]; + _placeHolderView.backgroundColor = [UIColor clearColor]; + [_placeHolderView setContentHuggingPriority:UILayoutPriorityDragThatCanResizeScene forAxis:UILayoutConstraintAxisHorizontal]; + [_placeHolderView setContentCompressionResistancePriority:UILayoutPriorityFittingSizeLevel forAxis:UILayoutConstraintAxisHorizontal]; + } + return _placeHolderView; +} @end diff --git a/xplan-ios/Main/Mine/Api/Api+Mine.h b/xplan-ios/Main/Mine/Api/Api+Mine.h index 36b4ad69..a2d50408 100644 --- a/xplan-ios/Main/Mine/Api/Api+Mine.h +++ b/xplan-ios/Main/Mine/Api/Api+Mine.h @@ -271,6 +271,11 @@ NS_ASSUME_NONNULL_BEGIN /// @param roomType 类型:4:个播房;其他:派对房;不传:所有房间 + (void)requestMineCollectRoomList:(HttpRequestHelperCompletion)completion uid:(NSString *)uid page:(NSString *)page pageSize:(NSString *)pageSize roomType:(NSString *)roomType; +/// 请求大家都在搜列表 +/// @param completion 完成 +/// @param uid uid ++ (void)requestEveryoneSearch:(HttpRequestHelperCompletion)completion uid:(NSString *)uid; + @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Mine/Api/Api+Mine.m b/xplan-ios/Main/Mine/Api/Api+Mine.m index c2f605d1..f0d243a0 100644 --- a/xplan-ios/Main/Mine/Api/Api+Mine.m +++ b/xplan-ios/Main/Mine/Api/Api+Mine.m @@ -302,4 +302,12 @@ [self makeRequest:@"fans/fansRoomList" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__,uid , page, pageSize, roomType, nil]; } +/// 请求大家都在搜列表 +/// @param completion 完成 +/// @param uid uid ++ (void)requestEveryoneSearch:(HttpRequestHelperCompletion)completion uid:(NSString *)uid { + #warning todo + [self makeRequest:@"" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, uid, nil]; +} + @end diff --git a/xplan-ios/Main/Mine/View/DressUp/View/XPDressSearchViewController.m b/xplan-ios/Main/Mine/View/DressUp/View/XPDressSearchViewController.m index 7be4b2cd..fc10d0c2 100644 --- a/xplan-ios/Main/Mine/View/DressUp/View/XPDressSearchViewController.m +++ b/xplan-ios/Main/Mine/View/DressUp/View/XPDressSearchViewController.m @@ -118,7 +118,7 @@ } #pragma mark - XPHomeSearchProtocol -- (void)searchRoomSuccess:(NSArray *)data { +- (void)searchRoomSuccess:(NSArray *)data type:(nonnull NSString *)type { self.datasource = data; [self.tableView reloadData]; }