更新 XPMineUserInfoHeaderView.m,新增 medalsStackView 和 medalMP4Views 属性以支持勋章展示逻辑;添加 medalsHeight 方法计算勋章高度;实现 setupMedalsArea 方法以配置勋章视图;更新 updateMedalsDisplay 方法以处理勋章的 MP4 和图片展示,保持代码结构一致性。同时,更新 .vscode/settings.json 文件以添加拼写检查词汇。

This commit is contained in:
edwinQQQ
2025-06-24 16:45:26 +08:00
parent 7810057542
commit 6573c0f6fe
2 changed files with 168 additions and 5 deletions

15
.vscode/settings.json vendored
View File

@@ -9,16 +9,29 @@
"cSpell.words": [
"autoreleasepool",
"Autoresizing",
"BGMP",
"Bugly",
"Commont",
"Contol",
"CPSVGA",
"erban",
"exper",
"Headwear",
"HWDMP",
"Interitem",
"kindof",
"MSRTL",
"NIMSDK",
"Nonnull",
"NSEC",
"NSURL",
"Offical",
"Procotol",
"QGVAP",
"Subview",
"subviews",
"Superview",
"Uids"
"Uids",
"XNDJTDD"
]
}

View File

@@ -173,7 +173,8 @@ HWDMP4PlayDelegate>
@property (nonatomic, strong) SVGAImageView *personalBGSvga;
@property (nonatomic, strong) UIStackView *medalsStackView;
@property (nonatomic, copy) NSArray <BaseModelVo *> *userMedals;
@property (nonatomic, strong) NSArray<VAPView *> *medalMP4Views;
@end
@@ -217,6 +218,14 @@ HWDMP4PlayDelegate>
return namePlateHeight;
}
+ (CGFloat)medalsHeight:(NSArray *)medalsList {
if (medalsList.count > 0) {
// 30px + 12px (6px * 2)
return 30 + 12;
}
return 0;
}
+ (CGFloat)headerHeight:(UserInfoModel *)model cps:(NSInteger)cps {
CGFloat height = 0;
NSInteger numberOfLines = 1;
@@ -241,8 +250,8 @@ HWDMP4PlayDelegate>
numberOfLines = ceil(textRect.size.height / lineHeight);
}
// topAlbum + cp + name plate area + line contents + others
height = kGetScaleWidth(195) + 160 + [self namePlateHeight:model.userNameplateList] + (lineHeight * numberOfLines) + kGetScaleWidth(80);
// topAlbum + cp + name plate area + medals area + line contents + others
height = kGetScaleWidth(195) + 160 + [self namePlateHeight:model.userNameplateList] + [self medalsHeight:model.medalsPic] + (lineHeight * numberOfLines) + kGetScaleWidth(80);
if (cps == 0) {
cps = 1;
}
@@ -289,6 +298,8 @@ HWDMP4PlayDelegate>
[self setupNameplateArea];
[self setupMedalsArea];
[self setupLocateArea];
[self setupCustomDesc];
@@ -524,12 +535,25 @@ HWDMP4PlayDelegate>
}];
}
- (void)setupMedalsArea {
[self.userInfoView addSubview:self.medalsStackView];
[self.medalsStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.nameplateCollectionView.mas_bottom).offset(6);
make.leading.mas_equalTo(self.userInfoView).offset(kGetScaleWidth(15));
// make.trailing.mas_equalTo(self.userInfoView).offset(kGetScaleWidth(-15));
make.height.mas_equalTo(30);
}];
//
self.medalsStackView.hidden = YES;
}
- (void)setupLocateArea {
[self.userInfoView addSubview:self.locateLabel];
[self.locateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.userInfoView).offset(kGetScaleWidth(15));
make.height.mas_equalTo(18);
make.top.mas_equalTo(self.nameplateCollectionView.mas_bottom).offset(6);
make.top.mas_equalTo(self.medalsStackView.mas_bottom).offset(6);
}];
}
@@ -870,6 +894,9 @@ HWDMP4PlayDelegate>
} else {
self.nobleImageView.hidden = YES;
}
//
[self updateMedalsDisplay:userInfo.medalsPic];
}
- (void)loadNamePlate:(NSString *)imagePath targetView:(NetImageView *)targetView {
@@ -1594,4 +1621,127 @@ HWDMP4PlayDelegate>
return _personalBGImageView;
}
- (UIStackView *)medalsStackView {
if (!_medalsStackView) {
_medalsStackView = [[UIStackView alloc] init];
_medalsStackView.backgroundColor = [UIColor clearColor];
_medalsStackView.axis = UILayoutConstraintAxisHorizontal;
_medalsStackView.distribution = UIStackViewDistributionEqualSpacing;
_medalsStackView.alignment = UIStackViewAlignmentCenter;
_medalsStackView.spacing = 5;
}
return _medalsStackView;
}
- (NSArray<VAPView *> *)medalMP4Views {
if (!_medalMP4Views) {
_medalMP4Views = [NSArray array];
}
return _medalMP4Views;
}
- (void)updateMedalsDisplay:(NSArray<BaseModelVo *> *)medals {
#if DEBUG
NSMutableArray *arr = [NSMutableArray arrayWithArray:medals];
[arr addObjectsFromArray:arr.copy];
[arr addObjectsFromArray:arr.copy];
[arr addObjectsFromArray:arr.copy];
[arr addObjectsFromArray:arr.copy];
[arr addObjectsFromArray:arr.copy];
[arr addObjectsFromArray:arr.copy];
medals = arr.copy;
#endif
//
for (VAPView *mp4View in self.medalMP4Views) {
[mp4View stopHWDMP4];
}
// StackView
for (UIView *subview in self.medalsStackView.arrangedSubviews) {
[self.medalsStackView removeArrangedSubview:subview];
[subview removeFromSuperview];
}
if (medals.count == 0) {
self.medalsStackView.hidden = YES;
return;
}
self.medalsStackView.hidden = NO;
NSMutableArray<VAPView *> *mp4Views = [NSMutableArray array];
// 10
NSInteger count = MIN(medals.count, 10);
for (NSInteger i = 0; i < count; i++) {
BaseModelVo *medal = medals[i];
UIView *medalContainer = [[UIView alloc] init];
medalContainer.backgroundColor = [UIColor clearColor];
if ([medal.picUrl.lowercaseString hasSuffix:@".mp4"]) {
// MP4 - XPRoomGiftAnimationParser
VAPView *mp4View = [[VAPView alloc] init];
mp4View.contentMode = UIViewContentModeScaleAspectFit;
mp4View.hwd_Delegate = self;
[medalContainer addSubview:mp4View];
[mp4View mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(medalContainer);
}];
[mp4Views addObject:mp4View];
// parser MP4 URL
XPRoomGiftAnimationParser *parser = [[XPRoomGiftAnimationParser alloc] init];
@kWeakify(self);
[parser parseWithURL:[medal.picUrl pureURLString]
completionBlock:^(NSString * _Nullable videoUrl) {
@kStrongify(self);
if (videoUrl.length) {
[mp4View setMute:YES];
[mp4View playHWDMP4:videoUrl repeatCount:-1 delegate:self];
}
} failureBlock:^(NSError * _Nullable error) {
//
NSLog(@"Medal MP4 parse failed: %@", error);
}];
} else {
//
NetImageView *imageView = [[NetImageView alloc] init];
imageView.imageUrl = medal.picUrl;
imageView.contentMode = UIViewContentModeScaleAspectFit;
[medalContainer addSubview:imageView];
[imageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(medalContainer);
}];
}
[self.medalsStackView addArrangedSubview:medalContainer];
[medalContainer mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(30).priority(UILayoutPriorityRequired);
}];
//
[medalContainer setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
[medalContainer setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
//
[medalContainer setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
[medalContainer setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
}
self.medalMP4Views = [mp4Views copy];
}
- (void)stopAllMedalsMP4 {
for (VAPView *mp4View in self.medalMP4Views) {
[mp4View stopHWDMP4];
}
self.medalMP4Views = @[];
}
- (void)dealloc {
[self stopAllMedalsMP4];
}
@end