覆盖羽声

This commit is contained in:
启星
2025-10-20 09:43:10 +08:00
parent affed1af58
commit 0d82f9e0ef
1331 changed files with 43209 additions and 14707 deletions

View File

@@ -7,8 +7,11 @@
#import "QXHomeSearchResultVC.h"
#import "QXHomeRoomCell.h"
#import "QXSearchHeaderReusableView.h"
#import "QXSearchUserCell.h"
#import "QXUserHomePageViewController.h"
@interface QXHomeSearchResultVC ()<UICollectionViewDelegate,UICollectionViewDataSource>
@interface QXHomeSearchResultVC ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
@property (nonatomic,strong)UICollectionView *collectionView;
@end
@@ -30,33 +33,75 @@
[self.view addSubview:self.collectionView];
}
-(void)setResultArray:(NSArray *)resultArray{
_resultArray = resultArray;
-(void)setModel:(QXSearchListModel *)model{
_model = model;
[self.collectionView reloadData];
}
#pragma mark - UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 1;
return 2;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return self.resultArray.count;
if (section == 0) {
return self.model.rooms.count;
}else{
return self.model.users.count;
}
}
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
QXHomeRoomCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXHomeRoomCell" forIndexPath:indexPath];
cell.searchModel = self.resultArray[indexPath.row];
return cell;
if (indexPath.section == 0) {
QXHomeRoomCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXHomeRoomCell" forIndexPath:indexPath];
cell.model = self.model.rooms[indexPath.row];
return cell;
}else{
QXSearchUserCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXSearchUserCell" forIndexPath:indexPath];
cell.model = self.model.users[indexPath.row];
return cell;
}
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
return CGSizeMake((SCREEN_WIDTH-15*3-1)/2.0, (SCREEN_WIDTH-15*3-1)/2.0);
if (indexPath.section == 0) {
return CGSizeMake((SCREEN_WIDTH-15*3-1)/2.0, (SCREEN_WIDTH-15*3-1)/2.0);
}else{
return CGSizeMake(SCREEN_WIDTH, 92);
}
}
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
QXSearchHeaderReusableView *reusableView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"QXSearchHeaderReusableView" forIndexPath:indexPath];
if (indexPath.section == 0) {
reusableView.title = @"相关房间";
}else{
reusableView.title = @"相关用户";
}
return reusableView;
}else{
return nil;
}
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{
return CGSizeMake(SCREEN_WIDTH, 48);
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section{
return CGSizeZero;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
QXSearchModel *model = self.resultArray[indexPath.row];
[[QXGlobal shareGlobal] joinRoomWithRoomId:model.id isRejoin:NO navagationController:self.navigationController];
if (indexPath.section == 0) {
QXRoomListModel *model = self.model.rooms[indexPath.row];
[[QXGlobal shareGlobal] joinRoomWithRoomId:model.room_id isRejoin:NO navagationController:self.navigationController];
}else{
QXUserHomeModel *model = self.model.users[indexPath.row];
QXUserHomePageViewController *vc = [[QXUserHomePageViewController alloc] init];
vc.user_id = model.user_id;
[self.navigationController pushViewController:vc animated:YES];
}
}
@@ -66,11 +111,14 @@
layout.minimumLineSpacing = 15;
layout.minimumInteritemSpacing = 15;
layout.sectionInset = UIEdgeInsetsMake(0, 15, 0, 15);
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 16, SCREEN_WIDTH, SCREEN_HEIGHT-(NavContentHeight+TabbarContentHeight)) collectionViewLayout:layout];
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 16, SCREEN_WIDTH, SCREEN_HEIGHT-NavContentHeight) collectionViewLayout:layout];
_collectionView.delegate = self;
_collectionView.dataSource = self;
_collectionView.bounces = YES;
_collectionView.backgroundColor = [UIColor clearColor];
[_collectionView registerNib:[UINib nibWithNibName:@"QXHomeRoomCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"QXHomeRoomCell"];
[_collectionView registerNib:[UINib nibWithNibName:@"QXSearchUserCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"QXSearchUserCell"];
[_collectionView registerClass:[QXSearchHeaderReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"QXSearchHeaderReusableView"];
}
return _collectionView;
}