feat: 优化首页 tab 加载逻辑 | 补全 side menu 控制逻辑 | 基本完成 20 mic | 部分小需求 | 优化房间聊天气泡

This commit is contained in:
edwinQQQ
2024-12-28 15:41:56 +08:00
parent 2c5d72846d
commit 4abb686790
98 changed files with 3209 additions and 383 deletions

View File

@@ -147,13 +147,14 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
self.backgroundColor = [[ClientConfig shareConfig] bgColor];
[self addSubview:self.tabCollectionView];
[self addSubview:self.arrowButton];
[self.tabCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.bottom.mas_equalTo(self);
make.leading.mas_equalTo(0);
make.trailing.mas_equalTo(self).offset(-15);
}];
[self addSubview:self.arrowButton];
[self.arrowButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self);
make.size.mas_equalTo(CGSizeMake(24, 24));
@@ -161,15 +162,26 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
}];
_gradientMask = [[UIView alloc] init];
[_gradientMask addGradientBackgroundWithColors:@[
UIColorRGBAlpha(0xffffff, 0),
[[ClientConfig shareConfig] bgColor],
] startPoint:CGPointMake(0, 0.5) endPoint:CGPointMake(0.3, 0.5) cornerRadius:0];
NSArray *colorArr = @[[UIColor colorWithWhite:1 alpha:0.0],
[[ClientConfig shareConfig] bgColor]];
if (isMSRTL()) {
colorArr = @[[[ClientConfig shareConfig] bgColor],
[UIColor colorWithWhite:1 alpha:0.0]];
[_gradientMask addGradientBackgroundWithColors:colorArr
startPoint:CGPointMake(0.7, 0.5)
endPoint:CGPointMake(1.0, 0.5)
cornerRadius:0];
} else {
[_gradientMask addGradientBackgroundWithColors:colorArr
startPoint:CGPointMake(0.2, 0.5)
endPoint:CGPointMake(0.4, 0.5)
cornerRadius:0];
}
[self insertSubview:self.gradientMask belowSubview:self.arrowButton];
[self.gradientMask mas_makeConstraints:^(MASConstraintMaker *make) {
make.trailing.mas_equalTo(self.arrowButton);
make.leading.mas_equalTo(self.arrowButton).offset(-20);
make.trailing.mas_equalTo(self);
make.top.bottom.mas_equalTo(self);
make.width.mas_equalTo(30);
}];
}
@@ -183,13 +195,6 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
}
- (void)setTabArray:(NSArray<PIHomeCategoryTitleModel *> *)tabArray {
// NSMutableArray *temp = @[].mutableCopy;
// for (PIHomeCategoryTitleModel *model in tabArray) {
// if (![NSString isEmpty:model.regionId]) {
// [temp addObject:model];
// }
// }
_tabArray = tabArray;
if (46 * _tabArray.count + 12 * (_tabArray.count-1) > KScreenWidth-30) {
self.gradientMask.hidden = NO;
@@ -212,7 +217,6 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
- (void)updateIndex:(NSInteger)index {
[self.tabCollectionView selectItemAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0] animated:YES scrollPosition:UICollectionViewScrollPositionNone];
// [self.tabCollectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0] atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES];
}
#pragma mark -
@@ -302,6 +306,9 @@ XPHomeRecommendViewControllerDelegate>
@property (nonatomic, copy) NSArray<HomeBannerInfoModel *> *bannerInfoList;
@property (nonatomic, copy) NSArray<HomeBannerInfoModel *> *secondBannerInfoList;
@property(nonatomic, assign) NSInteger maxReloadTagsLimitCount;
@property(nonatomic, assign) NSInteger reloadTagsLimitCount;
@end
@implementation XPNewHomeViewController
@@ -328,6 +335,9 @@ XPHomeRecommendViewControllerDelegate>
- (void)viewDidLoad {
[super viewDidLoad];
if(self.isEmpty == NO){
self.maxReloadTagsLimitCount = 5;
self.reloadTagsLimitCount = 0;
[self initSubViews];
[self initSubViewConstraints];
@@ -343,7 +353,6 @@ XPHomeRecommendViewControllerDelegate>
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self.pagingView.mainTableView.mj_header beginRefreshing];
}
- (void)viewWillDisappear:(BOOL)animated {
@@ -380,7 +389,10 @@ XPHomeRecommendViewControllerDelegate>
self.type = 0;
self.view.backgroundColor = [UIColor clearColor];
[self.view addSubview:self.pagingView];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(openRoomNotification:) name:kOpenRoomNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(openRoomNotification:)
name:kOpenRoomNotification
object:nil];
if([[AccountInfoStorage instance] getUid].length == 0){
return;
@@ -405,6 +417,7 @@ XPHomeRecommendViewControllerDelegate>
[self.navigationController pushViewController:sessionVC animated:YES];
[ClientConfig shareConfig].pushChatId = nil;
}
MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)];
header.stateLabel.font = [UIFont systemFontOfSize:10.0];
header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:10.0];
@@ -426,9 +439,11 @@ XPHomeRecommendViewControllerDelegate>
[self.pagingView.mainTableView.mj_header endRefreshing];
[self.pagingView.mainTableView.mj_footer endRefreshing];
}
-(void)logOut{
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(requestCheckIp) object:nil];
}
-(void)headerRefresh{
[self.presenter getHomeTopData];
[self.presenter getHomeRanks];
@@ -442,6 +457,10 @@ XPHomeRecommendViewControllerDelegate>
@kStrongify(self);
[self handleTapBannerItem:itemModel];
}];
// if (self.tagModelList.count == 0) {
[self.presenter getHomeTagList];
// }
}
-(void)openRoomNotification:(NSNotification *)notification{
@@ -462,7 +481,6 @@ XPHomeRecommendViewControllerDelegate>
}else{
[ClientConfig shareConfig].chatId = nil;
}
}
return;
}
@@ -642,9 +660,12 @@ XPHomeRecommendViewControllerDelegate>
///tag
- (void)getHomeTagListSuccess:(NSArray<PIHomeCategoryTitleModel *> *)array{
if(array.count == 0) {
[self.pagingView.mainTableView.mj_header endRefreshing];
[self getHomeTagListFailure];
return;
}
self.reloadTagsLimitCount = 0;
NSMutableArray *list = [NSMutableArray new];
NSMutableArray *titleArray = [NSMutableArray array];
for (PIHomeCategoryTitleModel *model in array) {
@@ -667,6 +688,24 @@ XPHomeRecommendViewControllerDelegate>
- (void)getHomeTagListFailure {
[self.pagingView.mainTableView.mj_header endRefreshing];
[self tryReloadTags];
}
- (void)tryReloadTags {
if (self.reloadTagsLimitCount >= self.maxReloadTagsLimitCount) {
return;
}
self.reloadTagsLimitCount += 1;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.pagingView.mainTableView.mj_header beginRefreshing];
});
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.presenter getHomeTagList];
});
}
- (void)displayEmpatyDataView {
}
- (void)homeChatPickSuccess:(NSString *)uid {