首页-大家都在搜UI,搜索劫持的礼物弹窗

This commit is contained in:
chenguilong
2022-11-16 17:04:34 +08:00
committed by fengshuo
parent 92eed62cc3
commit 955d12a842
21 changed files with 681 additions and 51 deletions

View File

@@ -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 = "<group>"; };
9BFB10202897D68400B3985E /* XPTabAnchorCardModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPTabAnchorCardModel.h; sourceTree = "<group>"; };
9BFB10212897D68400B3985E /* XPTabAnchorCardModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPTabAnchorCardModel.m; sourceTree = "<group>"; };
9BFC32082924BD910002D5A4 /* XPHomeSearchRelateView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPHomeSearchRelateView.h; sourceTree = "<group>"; };
9BFC32092924BD910002D5A4 /* XPHomeSearchRelateView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPHomeSearchRelateView.m; sourceTree = "<group>"; };
9BFC320C2924CC650002D5A4 /* XPRoomSearchRecommendHeadView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomSearchRecommendHeadView.h; sourceTree = "<group>"; };
9BFC320D2924CC650002D5A4 /* XPRoomSearchRecommendHeadView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomSearchRecommendHeadView.m; sourceTree = "<group>"; };
9BFC32132924DACC0002D5A4 /* XPHomeSearchAwardView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPHomeSearchAwardView.h; sourceTree = "<group>"; };
9BFC32142924DACC0002D5A4 /* XPHomeSearchAwardView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPHomeSearchAwardView.m; sourceTree = "<group>"; };
9BFE0D8C2898C8C300F53C24 /* XPAnchorCardSkillCollectionViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPAnchorCardSkillCollectionViewCell.h; sourceTree = "<group>"; };
9BFE0D8D2898C8C300F53C24 /* XPAnchorCardSkillCollectionViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPAnchorCardSkillCollectionViewCell.m; sourceTree = "<group>"; };
9BFE0D902899042600F53C24 /* XPTaskCompleteTipView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPTaskCompleteTipView.h; sourceTree = "<group>"; };
@@ -5196,6 +5205,26 @@
path = AnchorCard;
sourceTree = "<group>";
};
9BFC320B2924C0410002D5A4 /* HomeSearchRelateView */ = {
isa = PBXGroup;
children = (
9BFC32082924BD910002D5A4 /* XPHomeSearchRelateView.h */,
9BFC32092924BD910002D5A4 /* XPHomeSearchRelateView.m */,
9BFC320C2924CC650002D5A4 /* XPRoomSearchRecommendHeadView.h */,
9BFC320D2924CC650002D5A4 /* XPRoomSearchRecommendHeadView.m */,
);
path = HomeSearchRelateView;
sourceTree = "<group>";
};
9BFC32122924DA930002D5A4 /* HomeSearchHijack */ = {
isa = PBXGroup;
children = (
9BFC32132924DACC0002D5A4 /* XPHomeSearchAwardView.h */,
9BFC32142924DACC0002D5A4 /* XPHomeSearchAwardView.m */,
);
path = HomeSearchHijack;
sourceTree = "<group>";
};
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 */,

View File

@@ -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

View File

@@ -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<HomeRecommendRoomModel *> * array = [HomeRecommendRoomModel modelsWithArray:data.data];
[[self getView] searchRoomGetRecommendSuccess:array];
}fail:^(NSInteger code, NSString * _Nullable msg) {
[[self getView] searchRoomGetRecommendFail];
}] uid:uid];
}
@end

View File

@@ -17,6 +17,9 @@ NS_ASSUME_NONNULL_BEGIN
/// 清除进房记录
- (void)cleanInRoomRecord;
///大家都在搜
- (void)getEveryoneSearchList;
@end
NS_ASSUME_NONNULL_END

View File

@@ -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

View File

@@ -11,8 +11,13 @@ NS_ASSUME_NONNULL_BEGIN
@protocol XPHomeSearchProtocol <NSObject>
///搜索房间成功
- (void)searchRoomSuccess:(NSArray *)data;
///搜索成功
- (void)searchRoomSuccess:(NSArray *)data type:(NSString *)type;
///搜索页获取推荐房间成功
- (void)searchRoomGetRecommendSuccess:(NSArray *)data;
///搜索页获取推荐房间失败
- (void)searchRoomGetRecommendFail;
@end

View File

@@ -27,4 +27,7 @@
///清除进房记录成功
- (void)cleanInRoomRecordSuccess;
///获取大家都在搜列表成功
- (void)getEveryoneSearchListSuccess:(NSArray<XPMineFootPrintModel *> *)array;
@end

View File

@@ -0,0 +1,16 @@
//
// XPHomeSearchAwardView.h
// xplan-ios
//
// Created by GreenLand on 2022/11/16.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPHomeSearchAwardView : UIView
@end
NS_ASSUME_NONNULL_END

View File

@@ -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

View File

@@ -0,0 +1,28 @@
//
// XPHomeSearchRelateView.h
// xplan-ios
//
// Created by GreenLand on 2022/11/16.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@protocol XPHomeSearchRelateViewDelegate <NSObject>
///进入房间
- (void)xPHomeSearchRelateViewEnterRoom:(NSString *)roomUid;
@end
@interface XPHomeSearchRelateView : UIView
@property (nonatomic, strong) NSArray *relateArray;
@property (nonatomic, strong) NSArray *recommendArray;
@property (nonatomic, weak) id<XPHomeSearchRelateViewDelegate> delegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -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()<UITableViewDelegate, UITableViewDataSource, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
@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

View File

@@ -0,0 +1,16 @@
//
// XPRoomSearchRecommendHeadView.h
// xplan-ios
//
// Created by GreenLand on 2022/11/16.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPRoomSearchRecommendHeadView : UICollectionReusableView
@end
NS_ASSUME_NONNULL_END

View File

@@ -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

View File

@@ -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 - <JXCategoryListContentViewDelegate>

View File

@@ -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

View File

@@ -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 ()<JXCategoryViewDelegate, JXCategoryListContainerViewDelegate, XPHomeSearchNavViewDelegate,UITextFieldDelegate, XPRoomSearchRecordViewControllerDelegate>
@interface XPRoomSearchContainerViewController ()<JXCategoryViewDelegate, JXCategoryListContainerViewDelegate, XPHomeSearchNavViewDelegate,UITextFieldDelegate, XPRoomSearchRecordViewControllerDelegate, XPHomeSearchProtocol, XPHomeSearchRelateViewDelegate>
///
@property (nonatomic, strong) NSArray<NSString *> *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

View File

@@ -11,8 +11,12 @@ NS_ASSUME_NONNULL_BEGIN
@protocol XPRoomSearchRecordViewControllerDelegate <NSObject>
///搜索
- (void)xPRoomSearchRecordViewControllerSearchWithWord:(NSString *)word;
///点击了大家都在搜
- (void)xPRoomSearchRecordViewControllerEveryoneSearch:(NSString *)word;
@end
@interface XPRoomSearchRecordViewController : MvpViewController

View File

@@ -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<UITouch *> *)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<XPMineFootPrintModel *> *)array {
[self.everyoneSearchList removeAllObjects];
[self.everyoneSearchList addObjectsFromArray:array];
self.allSearchContentView.hidden = array.count == 0;
[self.everyOneCollectionView reloadData];
}
///
- (void)getInRoomRecordSuccess:(NSArray<XPMineFootPrintModel *> *)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

View File

@@ -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

View File

@@ -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

View File

@@ -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];
}