diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index 3bbb9f1c..78daeeaa 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 14566F2629BACBC500C73AE5 /* XPNewHomeFilterView.m in Sources */ = {isa = PBXBuildFile; fileRef = 14566F2529BACBC500C73AE5 /* XPNewHomeFilterView.m */; }; 146567D929B1D62E00A1F5B9 /* XPNewHomeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 146567D829B1D62E00A1F5B9 /* XPNewHomeViewController.m */; }; 146567DC29B1D6A900A1F5B9 /* XPNewHomeNavView.m in Sources */ = {isa = PBXBuildFile; fileRef = 146567DB29B1D6A900A1F5B9 /* XPNewHomeNavView.m */; }; 146567E229B1E1CF00A1F5B9 /* XPNewHomeHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 146567E129B1E1CF00A1F5B9 /* XPNewHomeHeaderView.m */; }; @@ -1299,6 +1300,8 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 14566F2429BACBC500C73AE5 /* XPNewHomeFilterView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPNewHomeFilterView.h; sourceTree = ""; }; + 14566F2529BACBC500C73AE5 /* XPNewHomeFilterView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPNewHomeFilterView.m; sourceTree = ""; }; 146567D729B1D62E00A1F5B9 /* XPNewHomeViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPNewHomeViewController.h; sourceTree = ""; }; 146567D829B1D62E00A1F5B9 /* XPNewHomeViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPNewHomeViewController.m; sourceTree = ""; }; 146567DA29B1D6A900A1F5B9 /* XPNewHomeNavView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPNewHomeNavView.h; sourceTree = ""; }; @@ -8503,6 +8506,8 @@ 146567DB29B1D6A900A1F5B9 /* XPNewHomeNavView.m */, 146567E029B1E1CF00A1F5B9 /* XPNewHomeHeaderView.h */, 146567E129B1E1CF00A1F5B9 /* XPNewHomeHeaderView.m */, + 14566F2429BACBC500C73AE5 /* XPNewHomeFilterView.h */, + 14566F2529BACBC500C73AE5 /* XPNewHomeFilterView.m */, 146567E329B1F55200A1F5B9 /* XPFindNewFriendTableViewCell.h */, 146567E429B1F55200A1F5B9 /* XPFindNewFriendTableViewCell.m */, 14EDBBA829B5935F001D3E16 /* XPFindNewFriendViewController.h */, @@ -10107,6 +10112,7 @@ E8E859D528264C2300EE4857 /* ContextFilterLogFormatter.m in Sources */, 9B92A35C27980A2900AD168F /* XPSkillCardHeadView.m in Sources */, 186A534726FC6ED900D67B2C /* TTAlertConfig.m in Sources */, + 14566F2629BACBC500C73AE5 /* XPNewHomeFilterView.m in Sources */, 18F403EE2758CF2F00A6C548 /* MessageContentImage.m in Sources */, 18E7B31E26F0984C0064BC9B /* UserLevelVo.m in Sources */, E8DBB70127B6501200AA285D /* XPLittleGameMiniStageView.m in Sources */, diff --git a/xplan-ios/Main/Home/Model/HomeRecommendRoomModel.h b/xplan-ios/Main/Home/Model/HomeRecommendRoomModel.h index 941c7f1a..dab0655e 100644 --- a/xplan-ios/Main/Home/Model/HomeRecommendRoomModel.h +++ b/xplan-ios/Main/Home/Model/HomeRecommendRoomModel.h @@ -7,6 +7,7 @@ #import #import "XPEnum.h" +@class HomePartyMicUserModel; NS_ASSUME_NONNULL_BEGIN @interface HomeRecommendRoomModel : NSObject @@ -40,9 +41,24 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, assign) BOOL crossPking; ///是否是推荐房间 @property (nonatomic, assign) BOOL isRecommend; +///麦上用户 +@property (nonatomic, strong) NSArray *micUsers; @property (nonatomic, copy) NSString *erbanNo; @end + +@interface HomePartyMicUserModel : NSObject +///头像 +@property (nonatomic, copy) NSString *avatar; +///性别 +@property (nonatomic,assign) GenderType gender; +///姓名 +@property (nonatomic,copy) NSString *nick; +///用户的uid +@property (nonatomic,copy) NSString *uid; + +@end + NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Home/Model/HomeRecommendRoomModel.m b/xplan-ios/Main/Home/Model/HomeRecommendRoomModel.m index a2568aca..136670e5 100644 --- a/xplan-ios/Main/Home/Model/HomeRecommendRoomModel.m +++ b/xplan-ios/Main/Home/Model/HomeRecommendRoomModel.m @@ -9,4 +9,14 @@ @implementation HomeRecommendRoomModel ++ (NSDictionary *)objectClassInArray { + return @{ + @"micUsers": [HomePartyMicUserModel class] + }; +} + +@end + +@implementation HomePartyMicUserModel + @end diff --git a/xplan-ios/Main/Home/View/XPHomeLittleGameViewController.m b/xplan-ios/Main/Home/View/XPHomeLittleGameViewController.m index 9a6bea83..95105488 100644 --- a/xplan-ios/Main/Home/View/XPHomeLittleGameViewController.m +++ b/xplan-ios/Main/Home/View/XPHomeLittleGameViewController.m @@ -26,6 +26,7 @@ @interface XPHomeLittleGameViewController () ///列表 @property (nonatomic,strong) UITableView *tableView; +@property (nonatomic, copy) void(^scrollCallback)(UIScrollView *scrollView); ///快速匹配 @property (nonatomic,strong) UIButton *matchButton; @property (nonatomic,strong) NSMutableArray *datasource; @@ -172,6 +173,19 @@ return self.view; } +- (UIScrollView *)listScrollView { + return self.tableView; +} + +- (void)listViewDidScrollCallback:(void (^)(UIScrollView *))callback { + self.scrollCallback = callback; +} + +- (void)scrollViewDidScroll:(UIScrollView *)scrollView { + self.scrollCallback(scrollView); +} + + #pragma mark - Event Response - (void)matchButtonAction:(UIButton *)sender { [self.presenter quickMatchLittleGameRoom]; diff --git a/xplan-ios/Main/Home/View/XPNewHomeFilterView.h b/xplan-ios/Main/Home/View/XPNewHomeFilterView.h new file mode 100644 index 00000000..a9bb5881 --- /dev/null +++ b/xplan-ios/Main/Home/View/XPNewHomeFilterView.h @@ -0,0 +1,25 @@ +// +// XPNewHomeFilterView.h +// xplan-ios +// +// Created by XY on 2023/3/10. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface XPNewHomeFilterView : UIView + +/// 选择的下标 +@property (nonatomic, copy) void (^ selectBlock)(NSUInteger index, NSString *title); + +/// 添加筛选视图 +/// - Parameters: +/// - vcView: VC的view +/// - targetView: 筛选按钮 +- (void)addToVCView:(UIView *)vcView targetView:(UIView *)targetView; + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Home/View/XPNewHomeFilterView.m b/xplan-ios/Main/Home/View/XPNewHomeFilterView.m new file mode 100644 index 00000000..c17e59a9 --- /dev/null +++ b/xplan-ios/Main/Home/View/XPNewHomeFilterView.m @@ -0,0 +1,134 @@ +// +// XPNewHomeFilterView.m +// xplan-ios +// +// Created by XY on 2023/3/10. +// + +#import "XPNewHomeFilterView.h" +#import "ThemeColor.h" + +@interface XPNewHomeFilterView() + +@property (nonatomic, strong) UITableView *tableView; +@property (nonatomic, strong) UIView *shadowView; + +@property (nonatomic, strong) NSArray *dataSource; + +@end + +@implementation XPNewHomeFilterView + +- (instancetype)initWithFrame:(CGRect)frame { + self = [super initWithFrame:frame]; + if (self) { + UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(bgTap:)]; + tap.delegate = self; + [self addGestureRecognizer:tap]; + } + return self; +} + +/// 添加筛选视图 +/// - Parameters: +/// - vcView: VC的view +/// - targetView: 筛选按钮 +- (void)addToVCView:(UIView *)vcView targetView:(UIView *)targetView { + [vcView addSubview:self]; + self.frame = vcView.bounds; + + CGRect targetFrame = [vcView convertRect:targetView.frame fromView:targetView.superview]; + CGFloat tabW = 86; + CGFloat tabX = CGRectGetMaxX(targetFrame) - tabW; + CGFloat tabY = CGRectGetMaxY(targetFrame)+4; + CGFloat tabH = self.tableView.rowHeight*self.dataSource.count; + self.tableView.frame = CGRectMake(tabX, tabY, tabW, tabH); + + [self addSubview:self.shadowView]; + self.shadowView.frame = self.tableView.frame; + [self addSubview:self.tableView]; + [self.tableView reloadData]; + +} + +/// 点击消失 +- (void)bgTap:(UITapGestureRecognizer *)tap { + [self dismiss]; +} + +- (void)dismiss { + [self removeFromSuperview]; +} + +#pragma mark - UITableViewDelegate + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return self.dataSource.count; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([UITableViewCell class])]; + if (!cell) { + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([UITableViewCell class])]; + cell.textLabel.textAlignment = NSTextAlignmentCenter; + cell.textLabel.textColor = [ThemeColor secondTextColor]; + cell.textLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular]; + cell.selectionStyle = UITableViewCellSelectionStyleNone; + } + cell.textLabel.text = self.dataSource[indexPath.row]; + return cell; +} + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + if (self.selectBlock) { + self.selectBlock(indexPath.row, self.dataSource[indexPath.row]); + } + [self dismiss]; +} + +#pragma mark - UIGestureRecognizerDelegate + +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { + if ([touch.view isDescendantOfView:self.tableView]) { + return NO; + } + return YES; +} + +#pragma mark - Getters And Setters + +- (UITableView *)tableView { + if (!_tableView) { + _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; + _tableView.backgroundColor = UIColor.clearColor; + _tableView.rowHeight = 30; + _tableView.delegate = self; + _tableView.dataSource = self; + _tableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0); + _tableView.separatorColor = [UIColor colorWithWhite:0.92 alpha:1]; + _tableView.layer.cornerRadius = 8; + } + return _tableView; +} + +- (UIView *)shadowView { + if (!_shadowView) { + _shadowView = [[UIView alloc] init]; + _shadowView.backgroundColor = UIColor.whiteColor; + _shadowView.layer.cornerRadius = 8; + _shadowView.layer.shadowColor = UIColor.blackColor.CGColor; + _shadowView.layer.shadowOffset = CGSizeMake(0, 0); + _shadowView.layer.shadowOpacity = 0.3; + _shadowView.layer.shadowRadius = 5; + } + return _shadowView; +} + +- (NSArray *)dataSource { + if (!_dataSource) { + _dataSource = @[@"全部", @"只看女生", @"只看男生"]; + } + return _dataSource; +} + +@end diff --git a/xplan-ios/Main/Home/View/XPNewHomeViewController.m b/xplan-ios/Main/Home/View/XPNewHomeViewController.m index 418fde50..a8c0b255 100644 --- a/xplan-ios/Main/Home/View/XPNewHomeViewController.m +++ b/xplan-ios/Main/Home/View/XPNewHomeViewController.m @@ -43,6 +43,7 @@ #import "XPNewHomeHeaderView.h" #import "XPRoomSearchContainerViewController.h" #import "XPHomeRecommendOtherRoomView.h" +#import "XPNewHomeFilterView.h" ///P #import "XPHomeRecommendPresenter.h" #import "XPHomeRecommendProtocol.h" @@ -191,10 +192,10 @@ make.top.bottom.mas_equalTo(0); }]; [self.filterBtn mas_makeConstraints:^(MASConstraintMaker *make) { - make.size.mas_equalTo(CGSizeMake(54, 24)); + make.height.mas_equalTo(24); }]; [self.refreshBtn mas_makeConstraints:^(MASConstraintMaker *make) { - make.size.mas_equalTo(CGSizeMake(65, 24)); + make.height.mas_equalTo(24); }]; [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(50); @@ -205,15 +206,24 @@ /// 点击筛选 - (void)filterBtnAction { - self.filterBtn.userInteractionEnabled = NO; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - self.filterBtn.userInteractionEnabled = YES; - }); + XPNewHomeFilterView *filterView = [[XPNewHomeFilterView alloc] init]; + @weakify(self); + filterView.selectBlock = ^(NSUInteger index, NSString *title) { + @strongify(self); + [self.filterBtn setTitle:title forState:UIControlStateNormal]; + //TODO: 刷新列表 + + }; + [filterView addToVCView:self.view targetView:self.filterBtn]; } /// 点击换一换 - (void)refreshBtnAction { [_friendVC refreshData]; + self.refreshBtn.userInteractionEnabled = NO; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + self.refreshBtn.userInteractionEnabled = YES; + }); } #pragma mark - XPHomeRecommendProtocol @@ -449,12 +459,13 @@ if (!_filterBtn) { _filterBtn = [XPButton buttonWithType:UIButtonTypeCustom]; [_filterBtn setImage:[UIImage imageNamed:@"home_filter_arrow"] forState:UIControlStateNormal]; - [_filterBtn setTitle:@"所有" forState:UIControlStateNormal]; + [_filterBtn setTitle:@"全部" forState:UIControlStateNormal]; [_filterBtn setTitleColor:[ThemeColor secondTextColor] forState:UIControlStateNormal]; _filterBtn.titleLabel.font = [UIFont systemFontOfSize:11 weight:UIFontWeightMedium]; _filterBtn.backgroundColor = UIColor.whiteColor; _filterBtn.layer.cornerRadius = 12; _filterBtn.clipsToBounds = YES; + _filterBtn.contentEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 10); [_filterBtn addTarget:self action:@selector(filterBtnAction) forControlEvents:UIControlEventTouchUpInside]; _filterBtn.imagePosition = XPButtonImagePositionRight; _filterBtn.imageTitleSpace = 4; @@ -472,6 +483,7 @@ _refreshBtn.backgroundColor = UIColor.whiteColor; _refreshBtn.layer.cornerRadius = 12; _refreshBtn.clipsToBounds = YES; + _refreshBtn.contentEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 10); [_refreshBtn addTarget:self action:@selector(refreshBtnAction) forControlEvents:UIControlEventTouchUpInside]; _refreshBtn.imagePosition = XPButtonImagePositionRight; _refreshBtn.imageTitleSpace = 4; diff --git a/xplan-ios/Main/Home/View/XPPartyListCollectionViewCell.m b/xplan-ios/Main/Home/View/XPPartyListCollectionViewCell.m index 8a4337c4..18bb910d 100644 --- a/xplan-ios/Main/Home/View/XPPartyListCollectionViewCell.m +++ b/xplan-ios/Main/Home/View/XPPartyListCollectionViewCell.m @@ -193,6 +193,21 @@ self.roomTitleLabel.text = _roomModel.title.length > 0 ? _roomModel.title : @""; self.numberLabel.text = [NSString stringWithFormat:@"%ld", _roomModel.onlineNum]; self.roomTagImageView.imageUrl = _roomModel.tagPict; + + if (_roomModel.micUsers.count > 5) { + _roomModel.micUsers = [_roomModel.micUsers subarrayWithRange:NSMakeRange(0, 5)]; + } + + for (int i = 0; i < self.stackView.subviews.count; i++) { + NetImageView * imageView = [self.stackView.subviews safeObjectAtIndex1:i]; + if (i < _roomModel.micUsers.count) { + HomePartyMicUserModel * userInfo = [_roomModel.micUsers safeObjectAtIndex1:i]; + imageView.imageUrl = userInfo.avatar; + imageView.hidden = NO; + } else { + imageView.hidden = YES; + } + } } } diff --git a/xplan-ios/Main/Home/View/XPPartyViewController.m b/xplan-ios/Main/Home/View/XPPartyViewController.m index fb8a7990..f7bee9c7 100644 --- a/xplan-ios/Main/Home/View/XPPartyViewController.m +++ b/xplan-ios/Main/Home/View/XPPartyViewController.m @@ -20,6 +20,7 @@ #import "XPPartyHeaderView.h" /// VC #import "XPPartyListViewController.h" +#import "XPHomeLittleGameViewController.h" ///P #import "XPHomeContainerPresenter.h" #import "XPHomeContainerProtocol.h" @@ -119,11 +120,19 @@ - (void)getHomeTagListSuccess:(NSArray *)array { [self.pagingView.mainTableView.mj_header endRefreshing]; NSMutableArray *tempArr = [array mutableCopy]; - if (tempArr.count > 0 && [tempArr.firstObject.name isEqualToString:@"喜欢"]) { - HomeTagModel *recommend = [[HomeTagModel alloc] init]; - recommend.name = @"推荐"; - recommend.tid = @"recommend"; - [tempArr replaceObjectAtIndex:0 withObject:recommend]; + if (tempArr.count > 0 ) { + NSString *firstName = array.firstObject.name; + if (![firstName isEqualToString:@"推荐"]) { + HomeTagModel *recommend = [[HomeTagModel alloc] init]; + recommend.name = @"推荐"; + recommend.tid = @"recommend"; + if ([firstName isEqualToString:@"喜欢"]) { + [tempArr replaceObjectAtIndex:0 withObject:recommend]; + }else{ + [tempArr insertObject:recommend atIndex:0]; + } + } + } self.tagList = tempArr; NSMutableArray * titles = [NSMutableArray array]; @@ -166,16 +175,17 @@ } - (id)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index { - XPPartyListViewController *listVC = [[XPPartyListViewController alloc] init]; HomeTagModel *tag = [self.tagList safeObjectAtIndex1:index]; - listVC.tabId = tag.tid; - return (id )listVC; + if ([tag.name isEqualToString:@"小游戏"]) { + XPHomeLittleGameViewController * likeVC = [[XPHomeLittleGameViewController alloc] init]; + return (id )likeVC; + } else { + XPPartyListViewController *listVC = [[XPPartyListViewController alloc] init]; + listVC.tabId = tag.tid; + return (id )listVC; + } } -- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index { - - -} #pragma mark - Getters And Setters