修正线上首页显示内容不对问题

阿语环境下,有概率会 hot 列表显示为最后一个 tab 的内容
This commit is contained in:
edwinQQQ
2025-03-14 19:44:58 +08:00
parent e7b2f594e8
commit d6e13ac0fe
5 changed files with 171 additions and 142 deletions

View File

@@ -20,9 +20,9 @@
@property(nonatomic,strong) UILabel *nameLabel;
@property(nonatomic,strong) UILabel *subLabel;
///
@property(nonatomic,strong) UILabel *heatView;
@property(nonatomic,strong) UILabel *heatNumLable;
///
@property(nonatomic,strong) UIImageView *heatGifView;
@property(nonatomic,strong) UIImageView *heatIcon;
///pk
@property(nonatomic,strong) SVGAParser *parser;
@property(nonatomic,strong) SVGAImageView *pkImageView;
@@ -35,37 +35,44 @@
@property (nonatomic, strong) NetImageView *levelImageView;
@property (nonatomic, strong) NSMutableArray<NetImageView *> *iconViews;
@property(nonatomic, strong) UIStackView *iconStackView;
@property(nonatomic, strong) UIStackView *nameStackView;
@property(nonatomic, strong) UIStackView *subTabStackView;
@end
@implementation XPNewHomePartyCollectionViewCell
- (NetImageView *)createIconViewWithTag:(NSInteger)tag {
NetImageConfig *config = [[NetImageConfig alloc] init];
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
NetImageView *iconView = [[NetImageView alloc] initWithConfig:config];
iconView.tag = tag;
iconView.layer.cornerRadius = kGetScaleWidth(20)/2;
iconView.layer.masksToBounds = YES;
iconView.layer.borderWidth = 1;
iconView.layer.borderColor = [UIColor whiteColor].CGColor;
iconView.hidden = YES; //
[self.contentView addSubview:iconView];
return iconView;
}
-(instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if(self){
self.clipsToBounds = NO;
self.contentView.clipsToBounds = NO;
self.membersCount = (kGetScaleWidth(345) - kGetScaleWidth(90))/kGetScaleWidth(20);
self.iconViews = [NSMutableArray array];
for (int i = 0; i < self.membersCount; i++) {
NetImageView *iconView = [self createIconViewWithTag:100 + i];
[self.iconViews addObject:iconView];
}
[self installUI];
[self installConstraints];
self.membersCount = (kGetScaleWidth(345) - kGetScaleWidth(90))/kGetScaleWidth(20);
for (int i = 0; i < self.membersCount; i++) {
NetImageConfig *config = [[NetImageConfig alloc]init];
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
NetImageView *iconView = [[NetImageView alloc]initWithConfig:config];
iconView.tag = 100 + i;
iconView.layer.cornerRadius = kGetScaleWidth(20)/2;
iconView.layer.masksToBounds = YES;
iconView.layer.borderWidth = 1;
iconView.layer.borderColor = [UIColor whiteColor].CGColor;
iconView.hidden = NO;
[self.contentView addSubview:iconView];
CGFloat left = kGetScaleWidth(90) + i * kGetScaleWidth(16);
[iconView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.subLabel.mas_bottom).mas_offset(kGetScaleWidth(8));
make.leading.mas_equalTo(left);
make.width.height.mas_equalTo(kGetScaleWidth(20));
}];
}
}
return self;
}
@@ -80,19 +87,21 @@
make.edges.mas_equalTo(self.contentView);
}];
[self.contentView addSubview:self.avatarView];
[self.contentView addSubview:self.tagImageView];
[self.contentView addSubview:self.rankImageView];
[self.contentView addSubview:self.levelImageView];
[self.contentView addSubview:self.avatarView];
[self.avatarView addSubview:self.pkImageView];
[self.contentView addSubview:self.nameLabel];
[self.contentView addSubview:self.flagImage];
[self.contentView addSubview:self.subLabel];
[self.contentView addSubview:self.heatGifView];
[self.contentView addSubview:self.heatView];
[self.contentView addSubview:self.levelImageView];
_nameStackView = [[UIStackView alloc] initWithArrangedSubviews:@[self.flagImage, self.nameLabel]];
_nameStackView.spacing = 4;
[self.contentView addSubview:self.nameStackView];
_subTabStackView = [[UIStackView alloc] initWithArrangedSubviews:@[self.tagImageView, self.subLabel]];
_subTabStackView.spacing = 4;
[self.contentView addSubview:self.subTabStackView];
[self.contentView addSubview:self.heatIcon];
[self.contentView addSubview:self.heatNumLable];
[self.contentView addSubview:self.boomImageView];
@kWeakify(self);
@@ -105,68 +114,16 @@
} failureBlock:^(NSError * _Nullable error) {
}];
}
-(void)installConstraints{
[self.avatarView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(kGetScaleWidth(73));
make.leading.mas_equalTo(kGetScaleWidth(10));
make.bottom.mas_equalTo(-kGetScaleWidth(10));
}];
[self.flagImage mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.avatarView.mas_trailing).offset(12);
make.height.mas_equalTo(kGetScaleWidth(14));
make.width.mas_equalTo(kGetScaleWidth(18));
make.top.mas_equalTo(self.avatarView).offset(4);
}];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.avatarView.mas_trailing).offset(12 + 6 + 18);
make.top.mas_equalTo(self.avatarView).offset(0);
make.trailing.mas_equalTo(self).offset(-32);
make.height.mas_equalTo(kGetScaleWidth(22));
}];
[self.rankImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.contentView).insets(UIEdgeInsetsMake(-20, -10, 0, -10));
}];
[self.tagImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.flagImage.mas_bottom).offset(4);
make.leading.mas_equalTo(self.flagImage);
make.width.mas_equalTo(0);
make.height.mas_equalTo(20);
}];
[self.subLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.equalTo(self.tagImageView.mas_trailing);
make.trailing.mas_equalTo(self).offset(-32);
make.height.mas_equalTo(20);
make.centerY.mas_equalTo(self.tagImageView);
}];
[self.heatView mas_makeConstraints:^(MASConstraintMaker *make) {
make.trailing.mas_equalTo(-8);
[self.avatarView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(kGetScaleWidth(73));
make.leading.mas_equalTo(kGetScaleWidth(10));
make.bottom.mas_equalTo(-kGetScaleWidth(10));
make.height.mas_equalTo(kGetScaleWidth(17));
}];
[self.heatGifView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(kGetScaleWidth(14));
make.height.mas_equalTo(kGetScaleWidth(14));
make.trailing.equalTo(self.heatView.mas_leading).mas_offset(-4);
make.centerY.equalTo(self.heatView);
}];
[self.pkImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(kGetScaleWidth(23));
make.height.mas_equalTo(kGetScaleWidth(22));
make.trailing.mas_equalTo(-kGetScaleWidth(6));
make.bottom.equalTo(self.avatarView.mas_bottom).mas_offset(-kGetScaleWidth(6));
}];
[self.levelImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.top.mas_equalTo(self.avatarView);
make.size.mas_equalTo(CGSizeMake(40, 16));
}];
[self.boomImageView mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -174,6 +131,66 @@
make.trailing.mas_equalTo(self.contentView).offset(-8);
make.size.mas_equalTo(CGSizeMake(40, 40));
}];
[self.nameStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.avatarView);
make.leading.mas_equalTo(self.avatarView.mas_trailing).offset(12);
make.trailing.mas_equalTo(self.boomImageView.mas_leading);
make.height.mas_equalTo(22);
}];
[self.flagImage mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(18);
}];
[self.subTabStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.nameStackView.mas_bottom).offset(4);
make.leading.mas_equalTo(self.nameStackView);
make.height.mas_equalTo(22);
make.trailing.mas_equalTo(self.boomImageView.mas_leading);
}];
[self.tagImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(0);
}];
[self.heatNumLable mas_makeConstraints:^(MASConstraintMaker *make) {
make.trailing.mas_equalTo(-8);
make.bottom.mas_equalTo(-kGetScaleWidth(10));
make.height.mas_equalTo(kGetScaleWidth(17));
}];
[self.heatIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(kGetScaleWidth(14));
make.height.mas_equalTo(kGetScaleWidth(14));
make.trailing.equalTo(self.heatNumLable.mas_leading).mas_offset(-4);
make.centerY.equalTo(self.heatNumLable);
}];
[self.pkImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(kGetScaleWidth(23));
make.height.mas_equalTo(kGetScaleWidth(22));
make.trailing.mas_equalTo(-kGetScaleWidth(6));
make.bottom.equalTo(self.avatarView.mas_bottom).mas_offset(-kGetScaleWidth(6));
}];
[self.levelImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.avatarView).offset(-2);
make.leading.mas_equalTo(self.avatarView);
make.size.mas_equalTo(CGSizeMake(40, 16));
}];
_iconStackView = [[UIStackView alloc] initWithArrangedSubviews:self.iconViews];
_iconStackView.spacing = -4;
[self.contentView addSubview:self.iconStackView];
[self.iconStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.avatarView.mas_trailing).offset(12);
make.bottom.equalTo(self.avatarView.mas_bottom);
make.height.mas_equalTo(kGetScaleWidth(20));
}];
}
- (void)setRoomInfo:(HomePlayRoomModel *)roomInfo{
@@ -181,6 +198,19 @@
_avatarView.imageUrl = _roomInfo.avatar;
self.levelImageView.imageUrl = roomInfo.roomLevelIcon;
for (int i = 0; i < self.membersCount; i++) {
NetImageView *iconView = _iconViews[i];
if (i < _roomInfo.micUsers.count) {
iconView.hidden = NO;
//
[iconView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(kGetScaleWidth(20));
}];
} else {
iconView.hidden = YES;
}
}
switch (roomInfo.homeRoomType) {
case 1:{
NSTextAttachment *attach = [[NSTextAttachment alloc] init];
@@ -226,45 +256,39 @@
self.boomImageView.hidden = YES;
}
[self.subLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.trailing.mas_equalTo(self).offset(self.boomImageView.hidden ? -8 : -40);
}];
if ([NSString isEmpty:roomInfo.tagPict]) {
self.subLabel.text = roomInfo.roomDesc.length > 0 ? roomInfo.roomDesc : YMLocalizedString(@"XPHomeMineViewController3");
self.tagImageView.hidden = YES;
} else {
@kWeakify(self);
[self.tagImageView loadImageWithUrl:roomInfo.tagPict
completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) {
@kStrongify(self);
self.tagImageView.image = image;
CGFloat width = kGetScaleWidth(62);
if (image.size.height > 0){
width = image.size.width * kGetScaleWidth(19) / image.size.height;
if (image) {
self.tagImageView.hidden = NO;
self.tagImageView.image = image;
CGFloat width = kGetScaleWidth(62);
if (image.size.height > 0){
width = image.size.width * kGetScaleWidth(19) / image.size.height;
}
[self.tagImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(width);
}];
[self layoutIfNeeded];
} else {
self.tagImageView.hidden = YES;
}
[self.tagImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(width);
}];
self.subLabel.text = [NSString stringWithFormat:@" %@", roomInfo.roomDesc.length > 0 ? roomInfo.roomDesc : YMLocalizedString(@"XPHomeMineViewController3")];
}];
}
[self.flagImage mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(roomInfo.regionFlag.length > 0 ? kGetScaleWidth(18) : 0);
}];
[self.nameLabel mas_updateConstraints:^(MASConstraintMaker *make) {
if (roomInfo.regionFlag.length > 0) {
make.leading.mas_equalTo(self.avatarView.mas_trailing).offset(12 + 6 + 18);
} else {
make.leading.mas_equalTo(self.avatarView.mas_trailing).offset(12);
}
}];
self.flagImage.imageUrl = roomInfo.regionFlag;
_heatView.text = [NSString isEmpty:roomInfo.hotValue.stringValue] ? @"0" : @(roomInfo.hotValue.integerValue).stringValue;
self.flagImage.imageUrl = roomInfo.regionFlag;
self.flagImage.hidden = [NSString isEmpty:roomInfo.regionFlag];
self.heatNumLable.text = [NSString isEmpty:roomInfo.hotValue.stringValue] ? @"0" : @(roomInfo.hotValue.integerValue).stringValue;
self.pkImageView.hidden = !_roomInfo.crossPking;
_pkImageView.hidden = !_roomInfo.crossPking;
if (roomInfo.hourTop > 0) {
NSString *name = [NSString stringWithFormat:@"room_top_%ld", (long)roomInfo.hourTop];
_rankImageView.image = [UIImage getLanguageImage:name];
@@ -282,10 +306,7 @@
iconView.hidden = YES;
}
}
// [self.heatView mas_updateConstraints:^(MASConstraintMaker *make) {
// make.width.mas_equalTo(self.roomInfo.width);
// }];
[self layoutIfNeeded];
}
#pragma mark -
@@ -333,19 +354,19 @@
}
return _nameLabel;
}
-(UILabel *)heatView{
if(!_heatView){
_heatView = [UILabel labelInitWithText:@"0" font:kFontMedium(10) textColor:UIColorFromRGB(0x84868A)];
_heatView.textAlignment = NSTextAlignmentRight;
-(UILabel *)heatNumLable{
if(!_heatNumLable){
_heatNumLable = [UILabel labelInitWithText:@"0" font:kFontMedium(10) textColor:UIColorFromRGB(0x84868A)];
_heatNumLable.textAlignment = NSTextAlignmentRight;
}
return _heatView;
return _heatNumLable;
}
- (UIImageView *)heatGifView{
if(!_heatGifView){
_heatGifView = [UIImageView new];
_heatGifView.image = kImage(@"ms_home_heat_icon");
- (UIImageView *)heatIcon{
if(!_heatIcon){
_heatIcon = [UIImageView new];
_heatIcon.image = kImage(@"ms_home_heat_icon");
}
return _heatGifView;
return _heatIcon;
}
- (SVGAParser *)parser{

View File

@@ -363,7 +363,7 @@
MSBaseRTLFlowLayout *layout = [[MSBaseRTLFlowLayout alloc] init];
layout.minimumInteritemSpacing = kGetScaleWidth(0);
layout.minimumLineSpacing = kGetScaleWidth(18);
layout.sectionInset = UIEdgeInsetsMake(0, kGetScaleWidth(15), 0, kGetScaleWidth(15));
layout.sectionInset = UIEdgeInsetsMake(20, 15, 0, 15);
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
_collectionView.backgroundColor = [UIColor clearColor];
_collectionView.dataSource = self;
@@ -372,7 +372,6 @@
[_collectionView registerClass:[XPNewHomePartyCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPNewHomePartyCollectionViewCell class])];
[_collectionView registerClass:[XPGuildEmptyCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPGuildEmptyCollectionViewCell class])];
[_collectionView registerClass:[HomePartyBannerCell class] forCellWithReuseIdentifier:NSStringFromClass([HomePartyBannerCell class])];
_collectionView.contentInset = UIEdgeInsetsMake(10, 0, 10, 0);
}
return _collectionView;
}

View File

@@ -49,7 +49,7 @@
#import "ClientConfig.h"
#import "SessionViewController.h"
#import "Api+Main.h"
#import "XPLoginViewController.h"
#import "LoginViewController.h"
#import "BaseNavigationController.h"
#import "XPAdImageTool.h"
#import "PIHomeCategoryTitleModel.h"
@@ -210,6 +210,7 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
self.arrowButton.hidden = YES;
}
[self.tabCollectionView reloadData];
@kWeakify(self);
dispatch_async(dispatch_get_main_queue(), ^{
@kStrongify(self);
@@ -223,9 +224,10 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
animated:NO
scrollPosition:UICollectionViewScrollPositionNone];
} else {
[self.tabCollectionView selectItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]
animated:NO
scrollPosition:UICollectionViewScrollPositionNone];
// index
// [self.tabCollectionView selectItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]
// animated:NO
// scrollPosition:UICollectionViewScrollPositionNone];
if (isMSRTL()) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
@@ -389,7 +391,7 @@ XPHomeRecommendOtherRoomViewDelegate>
if ([NIMSDK sharedSDK].loginManager.isLogined) {
[[NIMSDK sharedSDK].loginManager logout:nil];
}
XPLoginViewController *lvc = [[XPLoginViewController alloc] init];
LoginViewController *lvc = [[LoginViewController alloc] init];
BaseNavigationController * nav = [[BaseNavigationController alloc] initWithRootViewController:lvc];
nav.modalPresentationStyle = UIModalPresentationFullScreen;
kWindow.rootViewController = nav;
@@ -462,15 +464,17 @@ XPHomeRecommendOtherRoomViewDelegate>
}
-(void)logOut{
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(requestCheckIp) object:nil];
[NSObject cancelPreviousPerformRequestsWithTarget:self
selector:@selector(requestCheckIp)
object:nil];
}
-(void)headerRefresh{
[self.presenter getHomeTopData];
[self.presenter getHomeTagList];
[self.presenter getHomeRanks];
PIHomeCategoryTitleModel *tagModel = [self.tagModelList xpSafeObjectAtIndex:self.type];
XPHomePartyViewController *homeVC = [self.validListDict objectForKey:[NSNumber numberWithInteger:self.type]];
homeVC.tagModel = tagModel;
@@ -513,7 +517,7 @@ XPHomeRecommendOtherRoomViewDelegate>
}
- (void)initSubViewConstraints {
[self.pagingView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.view).mas_offset(kGetScaleWidth(10));
make.top.equalTo(self.view).mas_offset(10);
make.leading.bottom.trailing.mas_equalTo(0);
}];
}
@@ -610,6 +614,7 @@ XPHomeRecommendOtherRoomViewDelegate>
if (homeV) {
return homeV;
}
XPHomePartyViewController *homeVC = [[XPHomePartyViewController alloc] init];
homeVC.bannerInfoList = self.bannerInfoList;
homeVC.tagModel = [self.tagModelList xpSafeObjectAtIndex:index];
@@ -707,7 +712,7 @@ XPHomeRecommendOtherRoomViewDelegate>
self.titleView.titles = titleArray;
[self.titleView reloadData];
[self createTagScrollView];
[self.categoryTagList setTabArray:list];
}
@@ -777,7 +782,9 @@ XPHomeRecommendOtherRoomViewDelegate>
}else {
NSString * uid = [AccountInfoStorage instance].getUid;
if (model.ID.length > 0 && uid.length > 0) {
@kWeakify(self);
[Api homePickResource:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
@kStrongify(self);
if (code == 200) {
HomeMenuSourceModel * sourceModel = [HomeMenuSourceModel modelWithDictionary:data.data];
if (sourceModel.isPick) {
@@ -866,7 +873,6 @@ XPHomeRecommendOtherRoomViewDelegate>
if (!_pagingView) {
_pagingView = [[JXPagerView alloc] initWithDelegate:self listContainerType:0];
_pagingView.mainTableView.gestureDelegate = self;
// _pagingView.currentScrollingListView.delegate = self;
_pagingView.backgroundColor = [UIColor clearColor];
_pagingView.listContainerView.backgroundColor = [UIColor clearColor];
_pagingView.listContainerView.listCellBackgroundColor = [UIColor clearColor];

View File

@@ -60,6 +60,8 @@ NS_ASSUME_NONNULL_BEGIN
- (id)copy NS_UNAVAILABLE;
- (id)mutableCopy NS_UNAVAILABLE;
- (void)exitRoom;
@end
NS_ASSUME_NONNULL_END

View File

@@ -2296,10 +2296,11 @@ XPCandyTreeInsufficientBalanceViewDelegate>
#pragma mark - NIMLoginManagerDelegate
- (void)onKickout:(NIMLoginKickoutResult *)result {
[self exitRoom];
// [self exitRoom];
[self dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark - NIMConversationManagerDelegate
- (void)didAddRecentSession:(NIMRecentSession *)recentSession
totalUnreadCount:(NSInteger)totalUnreadCount {