新增勋章排行相关的 UI 组件,包括 MedalsRankViewController、MedalsRankTopView 和 MedalsRankListCell,更新 MedalsViewController 以支持展示其他用户的勋章信息,优化相关逻辑以提升用户体验,保持代码结构一致性。

This commit is contained in:
edwinQQQ
2025-06-20 18:44:20 +08:00
parent 4c76813273
commit 143ad115bc
27 changed files with 956 additions and 67 deletions

View File

@@ -545,6 +545,7 @@
4CAFEFF62DD2F21B00CD81DF /* CreateEventPickerContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CAFEFF52DD2F21B00CD81DF /* CreateEventPickerContainerView.m */; };
4CAFF00A2DD342A400CD81DF /* MessagePublicEventModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CAFF0092DD342A400CD81DF /* MessagePublicEventModel.m */; };
4CAFF00D2DD343B200CD81DF /* PublicEventTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CAFF00C2DD343B200CD81DF /* PublicEventTableViewCell.m */; };
4CB41CEC2E053D6300528517 /* MedalsRankViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CB41CEB2E053D6300528517 /* MedalsRankViewController.m */; };
4CB753D22D30F10900B13DF5 /* LuckyPackageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CB753D12D30F10900B13DF5 /* LuckyPackageViewController.m */; };
4CBBB44C2DA66334001B1C6D /* MessageCPNotifyModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CBBB44B2DA66334001B1C6D /* MessageCPNotifyModel.m */; };
4CBDC4242DC0B078005A75B9 /* EventCenterViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CBDC4232DC0B078005A75B9 /* EventCenterViewController.m */; };
@@ -2754,6 +2755,8 @@
4CAFF0092DD342A400CD81DF /* MessagePublicEventModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MessagePublicEventModel.m; sourceTree = "<group>"; };
4CAFF00B2DD343B200CD81DF /* PublicEventTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PublicEventTableViewCell.h; sourceTree = "<group>"; };
4CAFF00C2DD343B200CD81DF /* PublicEventTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PublicEventTableViewCell.m; sourceTree = "<group>"; };
4CB41CEA2E053D6300528517 /* MedalsRankViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MedalsRankViewController.h; sourceTree = "<group>"; };
4CB41CEB2E053D6300528517 /* MedalsRankViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MedalsRankViewController.m; sourceTree = "<group>"; };
4CB753D02D30F10900B13DF5 /* LuckyPackageViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LuckyPackageViewController.h; sourceTree = "<group>"; };
4CB753D12D30F10900B13DF5 /* LuckyPackageViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LuckyPackageViewController.m; sourceTree = "<group>"; };
4CBBB44A2DA66334001B1C6D /* MessageCPNotifyModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MessageCPNotifyModel.h; sourceTree = "<group>"; };
@@ -6873,6 +6876,8 @@
4CF3CE2A2E0403500071101F /* MedalsWearingControlCollectionViewCell.m */,
4CF3CE2C2E040EEC0071101F /* MedalsWearingListCollectionViewCell.h */,
4CF3CE2D2E040EEC0071101F /* MedalsWearingListCollectionViewCell.m */,
4CB41CEA2E053D6300528517 /* MedalsRankViewController.h */,
4CB41CEB2E053D6300528517 /* MedalsRankViewController.m */,
);
path = Medals;
sourceTree = "<group>";
@@ -13161,6 +13166,7 @@
E82E75062828E76400C25EF7 /* XPCoreDataManager.m in Sources */,
9B8DE0E4289CF7AA00FB6EC2 /* XPRoomGiftCompoundView.m in Sources */,
1808072D2731598F001FD836 /* XPNetImageYYLabel.m in Sources */,
4CB41CEC2E053D6300528517 /* MedalsRankViewController.m in Sources */,
E818E348286ECA4B005EDF68 /* XPMonentsPublishViewController.m in Sources */,
9B88E20C28C5EB8300D26FBA /* MessageContentRedPacketView.m in Sources */,
E896EFAF2771AF0F00AD2CC1 /* XPMineFriendEmptyTableViewCell.m in Sources */,

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "蒙版组 123@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "55265170576fb3f51936434e3c41a9129d29e72442375-r1hSuI@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 KiB

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "5@3x (2).png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "6@3x (1).png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "6@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "bg@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "幸运数字.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

View File

@@ -198,7 +198,7 @@ static NSString *clinet_s = @"uyzjdhds";
[Api loginWithThirdPart:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
@kStrongify(self);
[XNDJTDDLoadingTool hideOnlyView:kWindow];
AccountModel * model = [AccountModel modelWithDictionary:data.data];
AccountModel * model = [AccountModel modelWithDictionary:data.data];
if (model != nil) {
[[AccountInfoStorage instance] saveAccountInfo:model];
[[self getView] loginThirdPartSuccess];

View File

@@ -63,6 +63,26 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign) NSInteger medalNum;
@end
@interface MedalsRankUserModel : PIBaseModel
@property (nonatomic, assign) NSInteger gender;
@property (nonatomic, assign) NSInteger uid;
@property (nonatomic, assign) NSInteger erbanNo;
@property (nonatomic, copy) NSString *nick;
@property (nonatomic, copy) NSString *avatar;
@property (nonatomic, assign) NSInteger birth;
@property (nonatomic, assign) NSInteger medalCount;
@property (nonatomic, assign) NSInteger rank;
@end
@interface MedalsRankModel : PIBaseModel
@property (nonatomic, strong) MedalsRankUserModel*mine;
@property (nonatomic, copy) NSArray <MedalsRankUserModel *>*rankList;
@end
@interface MedalsModel : PIBaseModel
@end

View File

@@ -51,6 +51,20 @@
@end
@implementation MedalsRankUserModel
@end
@implementation MedalsRankModel
+ (NSDictionary *)mj_objectClassInArray {
return @{
@"rankList" : [MedalsRankUserModel class],
};
}
@end
@implementation MedalsModel
@end

View File

@@ -11,21 +11,26 @@ NS_ASSUME_NONNULL_BEGIN
@protocol MedalsPresenterProtocol <NSObject>
@optional
- (void)userMedalsSuccess:(UserMedalsModel *)userMedalsModel;
- (void)userMedalsFailure;
- (void)squareMedalsSuccess:(NSArray <MedalSeriesVo *> *)squareMedalsModel;
- (void)squareMedalsFailure;
@optional
- (void)mineAllMedalsSuccess:(MineAllMedalModel *)model;
- (void)mineAllMedalsFailure;
- (void)rankListSuccess:(MedalsRankModel *)model;
- (void)rankListFailure;
@end
@interface MedalsPresenter : BaseMvpPresenter
- (NSInteger)pageSize;
- (NSInteger)rankListSize;
/// 我的勋章页面(主/客态通用)
/// - Parameters:
@@ -47,6 +52,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)updateMedalUseStatus:(NSString *)medalId isUse:(BOOL)isUse;
- (void)rankList:(NSInteger)page;
@end
NS_ASSUME_NONNULL_END

View File

@@ -14,6 +14,10 @@
return 8;
}
- (NSInteger)rankListSize {
return 2;
}
- (void)userMedals:(NSInteger)uid page:(NSInteger)page type:(NSInteger)type {
@kWeakify(self);
[Api medalMine:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
@@ -70,4 +74,18 @@
} showLoading:YES errorToast:YES] id:medalId useStatus:@(isUse == YES ? 1 : 0)];
}
- (void)rankList:(NSInteger)page {
@kWeakify(self);
[Api medalRank:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
@kStrongify(self);
if ([[self getView] respondsToSelector:@selector(rankListSuccess:)]) {
[[self getView] rankListSuccess:[MedalsRankModel modelWithJSON:data.data]];
}
} fail:^(NSInteger code, NSString * _Nullable msg) {
if ([[self getView] respondsToSelector:@selector(rankListFailure)]) {
[[self getView] rankListFailure];
}
} showLoading:YES errorToast:YES] pageNo:@(page) pageSize:@([self rankListSize])];
}
@end

View File

@@ -220,22 +220,38 @@
//
CGFloat itemWidth = 25.0; //
CGFloat leftMargin = 20.0; //
CGFloat rightMargin = 20.0; //
// 20
CGFloat availableWidth = self.bounds.size.width;// - 40.0; // 20
//
CGFloat availableWidth = self.bounds.size.width - leftMargin - rightMargin;
//
//
CGFloat spacing = 0;
if (maxLevel > 1) {
spacing = (availableWidth - itemWidth * maxLevel) / (maxLevel - 1);
CGFloat startX = leftMargin;
if (maxLevel == 1) {
//
startX = (self.bounds.size.width - itemWidth) / 2.0;
} else if (maxLevel > 1) {
//
//
CGFloat totalItemWidth = itemWidth * maxLevel;
//
CGFloat totalSpacingWidth = availableWidth - totalItemWidth;
// = - 1
spacing = totalSpacingWidth / (maxLevel - 1);
//
if (spacing < 10.0) {
spacing = 10.0;
//
CGFloat totalWidth = totalItemWidth + spacing * (maxLevel - 1);
// 使
startX = (self.bounds.size.width - totalWidth) / 2.0;
}
}
//
spacing = MAX(spacing, 10.0);
// 20
CGFloat startX = 20.0;
for (NSInteger i = 1; i <= maxLevel; i++) {
//
LevelItemView *levelItem = [[LevelItemView alloc] initWithLevel:i];
@@ -279,22 +295,40 @@
[super layoutSubviews];
if (_maxLevel > 0 && _levelItems.count > 0) {
// 20
CGFloat itemWidth = 25.0;
CGFloat availableWidth = self.bounds.size.width;// - 40.0; // 20
//
CGFloat itemWidth = 25.0; //
CGFloat leftMargin = 20.0; //
CGFloat rightMargin = 20.0; //
//
//
CGFloat availableWidth = self.bounds.size.width - leftMargin - rightMargin;
//
CGFloat spacing = 0;
if (_maxLevel > 1) {
spacing = (availableWidth - itemWidth * _maxLevel) / (_maxLevel - 1);
CGFloat startX = leftMargin;
if (_maxLevel == 1) {
//
startX = (self.bounds.size.width - itemWidth) / 2.0;
} else if (_maxLevel > 1) {
//
//
CGFloat totalItemWidth = itemWidth * _maxLevel;
//
CGFloat totalSpacingWidth = availableWidth - totalItemWidth;
// = - 1
spacing = totalSpacingWidth / (_maxLevel - 1);
//
if (spacing < 10.0) {
spacing = 10.0;
//
CGFloat totalWidth = totalItemWidth + spacing * (_maxLevel - 1);
// 使
startX = (self.bounds.size.width - totalWidth) / 2.0;
}
}
//
spacing = MAX(spacing, 10.0);
// 20
CGFloat startX = 20.0;
for (NSInteger i = 0; i < _levelItems.count; i++) {
LevelItemView *item = _levelItems[i];
CGFloat x = startX + i * (itemWidth + spacing);
@@ -411,20 +445,37 @@
- (void)calculateLayoutParams:(CGFloat *)itemWidth spacing:(CGFloat *)spacing startX:(CGFloat *)startX forMaxLevel:(NSInteger)maxLevel {
*itemWidth = 25.0; //
//
CGFloat availableWidth = self.bounds.size.width;
CGFloat leftMargin = 20.0; //
CGFloat rightMargin = 20.0; //
//
//
CGFloat availableWidth = self.bounds.size.width - leftMargin - rightMargin;
//
*spacing = 0;
if (maxLevel > 1) {
*spacing = (availableWidth - (*itemWidth) * maxLevel) / (maxLevel - 1);
*startX = leftMargin;
if (maxLevel == 1) {
//
*startX = (self.bounds.size.width - (*itemWidth)) / 2.0;
} else if (maxLevel > 1) {
//
//
CGFloat totalItemWidth = (*itemWidth) * maxLevel;
//
CGFloat totalSpacingWidth = availableWidth - totalItemWidth;
// = - 1
*spacing = totalSpacingWidth / (maxLevel - 1);
//
if (*spacing < 10.0) {
*spacing = 10.0;
//
CGFloat totalWidth = totalItemWidth + (*spacing) * (maxLevel - 1);
// 使
*startX = (self.bounds.size.width - totalWidth) / 2.0;
}
}
//
*spacing = MAX(*spacing, 10.0);
// 20
*startX = 20.0;
}
@end

View File

@@ -0,0 +1,16 @@
//
// MedalsRankViewController.h
// YuMi
//
// Created by P on 2025/6/20.
//
#import "MvpViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface MedalsRankViewController : MvpViewController
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,468 @@
//
// MedalsRankViewController.m
// YuMi
//
// Created by P on 2025/6/20.
//
#import "MedalsRankViewController.h"
#import "MedalsPresenter.h"
#import "MedalsViewController.h"
#import "UserInfoModel.h"
@interface MedalsRankListCell : UITableViewCell
@property (nonatomic, strong) UILabel *indexLabel;
@property (nonatomic, strong) NetImageView *avatarImageView;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *countLabel;
+ (void)registerTo:(UITableView *)tableView;
+ (instancetype)cellFor:(UITableView *)tableView atIndexPath:(NSIndexPath *)index;
- (void)updateCell:(MedalsRankUserModel *)userModel atIndex:(NSInteger)index;
@end
@implementation MedalsRankListCell
+ (NSString *)cellID {
return NSStringFromClass([MedalsRankListCell class]);
}
+ (void)registerTo:(UITableView *)tableView {
[tableView registerClass:[self class] forCellReuseIdentifier:[self cellID]];
}
+ (instancetype)cellFor:(UITableView *)tableView atIndexPath:(NSIndexPath *)index {
MedalsRankListCell *cell = [tableView dequeueReusableCellWithIdentifier:[self cellID] forIndexPath:index];
return cell;
}
- (void)updateCell:(MedalsRankUserModel *)userModel atIndex:(NSInteger)index {
self.avatarImageView.imageUrl = userModel.avatar;
self.nameLabel.text = userModel.nick;
self.indexLabel.text = @(userModel.rank).stringValue;
self.countLabel.text = @(userModel.medalCount).stringValue;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
self.backgroundColor = [UIColor clearColor];
self.contentView.backgroundColor = [UIColor clearColor];
self.indexLabel = [UILabel labelInitWithText:@"" font:kFontMedium(14) textColor:[UIColor whiteColor]];
[self.contentView addSubview:self.indexLabel];
[self.indexLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.contentView);
make.leading.mas_equalTo(18);
}];
NetImageConfig *config = [[NetImageConfig alloc] init];
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
self.avatarImageView = [[NetImageView alloc] initWithConfig:config];
[self.avatarImageView setCornerRadius:47/2];
[self.contentView addSubview:self.avatarImageView];
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.contentView);
make.leading.mas_equalTo(self.indexLabel.mas_trailing).offset(16);
make.size.mas_equalTo(CGSizeMake(47, 47));
}];
self.nameLabel = [UILabel labelInitWithText:@"" font:kFontSemibold(15) textColor:[UIColor whiteColor]];
[self.contentView addSubview:self.nameLabel];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.avatarImageView.mas_trailing).offset(6);
make.top.mas_equalTo(self.avatarImageView);
}];
UIImageView *rankIcon = [[UIImageView alloc] initWithImage:kImage(@"medals_rank")];
[self.contentView addSubview:rankIcon];
[rankIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.avatarImageView.mas_trailing).offset(6);
make.bottom.mas_equalTo(self.avatarImageView);
make.size.mas_equalTo(CGSizeMake(10, 14));
}];
self.countLabel = [UILabel labelInitWithText:@"" font:kFontMedium(14) textColor:[UIColor whiteColor]];
[self.contentView addSubview:self.countLabel];
[self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(rankIcon.mas_trailing).offset(6);
make.centerY.mas_equalTo(rankIcon);
}];
UILabel *detailLabel = [UILabel labelInitWithText:YMLocalizedString(@"20.20.61_text_13")
font:kFontRegular(12)
textColor:[UIColor colorWithWhite:1 alpha:0.6]];
[self.contentView addSubview:detailLabel];
[detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.trailing.mas_equalTo(self.contentView).offset(-28);
make.centerY.mas_equalTo(self.contentView);
}];
UIImageView *arrow = [[UIImageView alloc] initWithImage:kImage(@"grey_right_arrow")];
[self.contentView addSubview:arrow];
[arrow mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.contentView);
make.trailing.mas_equalTo(self.contentView).offset(-15);
make.size.mas_equalTo(CGSizeMake(15, 15));
}];
}
return self;
}
@end
@interface MedalsRankTopView : UIView
@property (nonatomic, assign) NSInteger topLevel;
@property (nonatomic, strong) MedalsRankUserModel *userModel;
@end
@implementation MedalsRankTopView
{
NetImageView *avataImageView;
UIImageView *decorationImageView;
UILabel *nameLabel;
UILabel *honorLabel;
UIImageView *honorImageView;
UIImageView *medalIconImageView;
UILabel *medalCountLabel;
UIStackView *medalCountStack;
}
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
NetImageConfig *config = [[NetImageConfig alloc] init];
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
avataImageView = [[NetImageView alloc] initWithConfig:config];
[avataImageView setCornerRadius:50];
[self addSubview:avataImageView];
[avataImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self);
make.size.mas_equalTo(CGSizeMake(100, 100));
}];
decorationImageView = [[UIImageView alloc] init];
[self addSubview:decorationImageView];
[decorationImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
}];
honorImageView = [[UIImageView alloc] initWithImage:kImage(@"medals_rank_namebar")];
[self addSubview:honorImageView];
[honorImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self);
make.bottom.mas_equalTo(self).offset(6);
}];
honorLabel = [UILabel labelInitWithText:YMLocalizedString(@"20.20.61_text_12")
font:kFontSemibold(12)
textColor:UIColorFromRGB(0xfff27b)];
[self addSubview:honorLabel];
[honorLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(honorImageView);
}];
nameLabel = [UILabel labelInitWithText:@"" font:kFontSemibold(15) textColor:UIColorFromRGB(0xffffff)];
[self addSubview:nameLabel];
medalIconImageView = [[UIImageView alloc] initWithImage:kImage(@"medals_rank")];
medalCountLabel = [UILabel labelInitWithText:@"0" font:kFontMedium(14) textColor:UIColorFromRGB(0xffffff)];
medalCountStack = [[UIStackView alloc] initWithArrangedSubviews:@[
medalIconImageView,
medalCountLabel
]];
[self addSubview:medalCountStack];
honorLabel.hidden = YES;
honorImageView.hidden = YES;
}
return self;
}
- (void)setTopLevel:(NSInteger)topLevel {
_topLevel = topLevel;
NSString *imagePath = @"";
NSInteger nameTopOffset = 0;
NSInteger bottomOffset = 0;
switch (topLevel) {
case 1:
imagePath = @"medals_rank_top_1";
honorLabel.hidden = NO;
honorImageView.hidden = NO;
nameTopOffset = 8;
bottomOffset = 40;
break;
case 2:
imagePath = @"medals_rank_top_2";
nameTopOffset = -4;
bottomOffset = 20;
break;
case 3:
imagePath = @"medals_rank_top_3";
nameTopOffset = -4;
bottomOffset = 20;
break;
default:
break;
}
[nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self);
make.top.mas_equalTo(self.mas_bottom).offset(nameTopOffset);
}];
[medalCountStack mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self);
make.top.mas_equalTo(nameLabel.mas_bottom).offset(4);
}];
if (![NSString isEmpty:imagePath]) {
decorationImageView.image = kImage(imagePath);
}
}
- (void)setUserModel:(MedalsRankUserModel *)userModel {
_userModel = userModel;
if (userModel) {
avataImageView.imageUrl = userModel.avatar;
nameLabel.text = userModel.nick;
medalCountLabel.text = @(userModel.medalCount).stringValue;
}
}
@end
@interface MedalsRankViewController () <MedalsPresenterProtocol, UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UILabel *indexLabel;
@property (nonatomic, strong) NetImageView *avatarImageView;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *countLabel;
@property (nonatomic, strong) MedalsRankTopView *topOne;
@property (nonatomic, strong) MedalsRankTopView *topTwo;
@property (nonatomic, strong) MedalsRankTopView *topThree;
@property (nonatomic, strong) MedalsRankUserModel *mineRankModel;
@property (nonatomic, strong) NSMutableArray <MedalsRankUserModel *>*rankList;
@property (nonatomic, strong) UITableView *rankTableView;
@end
@implementation MedalsRankViewController
- (BOOL)isHiddenNavBar {
return YES;
}
- (MedalsPresenter *)createPresenter {
return [[MedalsPresenter alloc] init];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self setupUI];
[self loadData];
}
#pragma mark -
- (void)setupUI {
self.view.backgroundColor = UIColorFromRGB(0x1B0043);
[self setupTopArea];
[self setupRankList];
[self setupBottomArea];
[self setupNavigationBar];
}
- (void)setupNavigationBar {
[self setupCustomNavigationBar:^{}
title:YMLocalizedString(@"20.20.61_text_11")
titleColor:[UIColor whiteColor]];
}
- (void)setupTopArea {
UIImageView *topBG = [[UIImageView alloc] initWithImage:kImage(@"medals_rank_top_bg")];
topBG.frame = CGRectMake(0, 0, KScreenWidth, kGetScaleWidth(270));
[self.view addSubview:topBG];
self.topOne = [self rankTopView:1];
self.topTwo = [self rankTopView:2];
self.topThree = [self rankTopView:3];
[self.view addSubview:self.topOne];
[self.view addSubview:self.topTwo];
[self.view addSubview:self.topThree];
[self.topOne mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.view).offset(95);
make.centerX.mas_equalTo(self.view);
make.size.mas_equalTo(CGSizeMake(209, 145));
}];
[self.topTwo mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(topBG.mas_bottom);
make.leading.mas_equalTo(self.view).offset(25);
make.size.mas_equalTo(CGSizeMake(145, 145));
}];
[self.topThree mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(topBG.mas_bottom);
make.trailing.mas_equalTo(self.view).offset(-25);
make.size.mas_equalTo(CGSizeMake(145, 145));
}];
}
- (void)setupRankList {
[self.view addSubview:self.rankTableView];
CGFloat height = 84 + kSafeAreaBottomHeight;
[self.rankTableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.topTwo.mas_bottom).offset(40);
make.bottom.mas_equalTo(self.view).offset(-height);
make.leading.trailing.mas_equalTo(self.view);
}];
}
- (void)setupBottomArea {
CGFloat height = 84;
UIView *bottomArea = [[UIView alloc] initWithFrame:CGRectMake(0, KScreenHeight - height, KScreenWidth, height)];
[bottomArea addGradientBackgroundWithColors:@[
UIColorFromRGB(0x3d1479),
UIColorFromRGB(0x1c0044),
] startPoint:CGPointMake(0.5, 0) endPoint:CGPointMake(0.5, 1) cornerRadius:0];
[self.view addSubview:bottomArea];
self.indexLabel = [UILabel labelInitWithText:@"" font:kFontMedium(14) textColor:[UIColor whiteColor]];
[bottomArea addSubview:self.indexLabel];
[self.indexLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(bottomArea);
make.leading.mas_equalTo(18);
}];
NetImageConfig *config = [[NetImageConfig alloc] init];
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
self.avatarImageView = [[NetImageView alloc] initWithConfig:config];
[self.avatarImageView setCornerRadius:47/2];
[bottomArea addSubview:self.avatarImageView];
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(bottomArea);
make.leading.mas_equalTo(self.indexLabel.mas_trailing).offset(16);
make.size.mas_equalTo(CGSizeMake(47, 47));
}];
self.nameLabel = [UILabel labelInitWithText:@"" font:kFontSemibold(15) textColor:[UIColor whiteColor]];
[bottomArea addSubview:self.nameLabel];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.avatarImageView.mas_trailing).offset(6);
make.top.mas_equalTo(self.avatarImageView);
}];
UIImageView *rankIcon = [[UIImageView alloc] initWithImage:kImage(@"medals_rank")];
[bottomArea addSubview:rankIcon];
[rankIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.avatarImageView.mas_trailing).offset(6);
make.bottom.mas_equalTo(self.avatarImageView);
make.size.mas_equalTo(CGSizeMake(10, 14));
}];
self.countLabel = [UILabel labelInitWithText:@"" font:kFontMedium(14) textColor:[UIColor whiteColor]];
[bottomArea addSubview:self.countLabel];
[self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(rankIcon.mas_trailing).offset(6);
make.centerY.mas_equalTo(rankIcon);
}];
}
#pragma mark -
- (void)loadData {
[self.presenter rankList:1];
}
- (void)rankListSuccess:(MedalsRankModel *)model {
if (model) {
self.mineRankModel = model.mine;
self.avatarImageView.imageUrl = self.mineRankModel.avatar;
self.nameLabel.text = self.mineRankModel.nick;
self.indexLabel.text = @(self.mineRankModel.rank).stringValue;
self.countLabel.text = @(self.mineRankModel.medalCount).stringValue;
self.rankList = [NSMutableArray array];
for (MedalsRankUserModel *user in model.rankList) {
if (user.rank == 1) {
self.topOne.userModel = user;
} else if (user.rank == 2) {
self.topTwo.userModel = user;
} else if (user.rank == 3) {
self.topThree.userModel = user;
} else {
[self.rankList addObject:user];
}
}
#if DEBUG
[self.rankList addObjectsFromArray:model.rankList];
#endif
[self.rankTableView reloadData];
}
}
- (void)rankListFailure {
}
#pragma mark - UITableView DataSource & Delegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.rankList.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 70;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
MedalsRankListCell *cell = [MedalsRankListCell cellFor:tableView atIndexPath:indexPath];
MedalsRankUserModel *model = [self.rankList xpSafeObjectAtIndex:indexPath.row];
[cell updateCell:model atIndex:indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
MedalsRankUserModel *model = [self.rankList xpSafeObjectAtIndex:indexPath.row];
if (model) {
UserInfoModel *userInfo = [[UserInfoModel alloc] init];
userInfo.uid = model.uid;
userInfo.avatar = model.avatar;
userInfo.nick = model.nick;
MedalsViewController *vc = [[MedalsViewController alloc] initForOtherMedals:userInfo];
[self.navigationController pushViewController:vc animated:YES];
}
}
#pragma mark -
- (MedalsRankTopView *)rankTopView:(NSInteger)rank {
MedalsRankTopView *topView = [[MedalsRankTopView alloc] initWithFrame:CGRectMake(0, 0, rank == 1 ? 209 : 145, 145)];
topView.topLevel = rank;
return topView;
}
- (UITableView *)rankTableView {
if (!_rankTableView) {
_rankTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_rankTableView.delegate = self;
_rankTableView.dataSource = self;
_rankTableView.backgroundColor = [UIColor clearColor];
[MedalsRankListCell registerTo:_rankTableView];
}
return _rankTableView;
}
@end

View File

@@ -12,6 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface MedalsViewController : MvpViewController
- (instancetype)initForMyMedals:(UserInfoModel *)userInfo;
- (instancetype)initForOtherMedals:(UserInfoModel *)userInfo;
- (instancetype)initForMedalsSquare;
@end

View File

@@ -12,6 +12,9 @@
#import "MedalsCollectionViewCell.h"
#import "MedalsDetailView.h"
#import "MedalsWearingViewController.h"
#import "MedalsRankViewController.h"
#import <QGVAPWrapView.h>
#import "XPRoomGiftAnimationParser.h"
typedef enum : NSInteger {
MedalsCenterTab_TaskMedals = 1,
@@ -19,9 +22,14 @@ typedef enum : NSInteger {
MedalsCenterTab_GloryMedals = 3,
} MedalsCenterTabType;
typedef enum : NSInteger {
MedalsCenterDisplayType_Mine,
MedalsCenterDisplayType_Other,
MedalsCenterDisplayType_Square
} MedalsCenterDisplayType;
@interface MedalsViewController () <MedalsPresenterProtocol, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
@property (nonatomic, assign) BOOL isForMyMedals;
@property (nonatomic, strong) UserInfoModel *userInfo;
@property (nonatomic, copy) NSArray <UIButton *> *centerTabButtons;
@property (nonatomic, strong) UILabel *medalDescLabel;
@@ -38,7 +46,17 @@ typedef enum : NSInteger {
@property (nonatomic, assign) NSInteger currentPageGloryMedals;
@property (nonatomic, assign) MedalsCenterTabType currentTabType;
@property (nonatomic, assign) MedalsCenterDisplayType displayType;
@property (nonatomic, strong) UserMedalsModel *userMedalsModel;
@property (nonatomic, strong) UIImageView *otherBG;
@property (nonatomic, strong) NetImageView *otherAvatar;
@property (nonatomic, strong) NetImageView *otherMedal;
@property (nonatomic, strong) VAPView *otherMP4View;
@property (nonatomic, strong) XPRoomGiftAnimationParser *mp4Parser;
@property (nonatomic, strong) UILabel *otherNameLabel;
@property (nonatomic, strong) UILabel *otherCountLabel;
@end
@@ -47,7 +65,16 @@ typedef enum : NSInteger {
- (instancetype)initForMyMedals:(UserInfoModel *)userInfo {
self = [super init];
if (self) {
self.isForMyMedals = YES;
self.displayType = MedalsCenterDisplayType_Mine;
self.userInfo = userInfo;
}
return self;
}
- (instancetype)initForOtherMedals:(UserInfoModel *)userInfo {
self = [super init];
if (self) {
self.displayType = MedalsCenterDisplayType_Other;
self.userInfo = userInfo;
}
return self;
@@ -56,7 +83,7 @@ typedef enum : NSInteger {
- (instancetype)initForMedalsSquare {
self = [super init];
if (self) {
self.isForMyMedals = NO;
self.displayType = MedalsCenterDisplayType_Square;
}
return self;
}
@@ -79,26 +106,46 @@ typedef enum : NSInteger {
#pragma mark - UI
- (void)setupUI {
[self setupBackground];
[self setupNavigationBar];
[self setupCenterTabs];
if (self.userInfo.medals.medalCount == 0) {
[self setupEmptyUserMedals];
if (self.displayType != MedalsCenterDisplayType_Other) {
[self setupWearingButton];
if (self.userInfo.medals.medalCount == 0) {
[self setupEmptyUserMedals];
}
} else {
[self setupOthersMedalInfo];
}
[self setupWearingButton];
[self setupCenterTabs];
[self setupBottomMedalsList];
[self setupEmptyView];
[self setupNavigationBar];
}
- (void)setupNavigationBar {
NSString *title = @"";
NSArray *navigationButtons = [NSArray array];
switch (self.displayType) {
case MedalsCenterDisplayType_Mine:
title = YMLocalizedString(@"20.20.61_text_1");
navigationButtons = @[[self medalsRankButton],
[self medalsSquareButton]];
break;
case MedalsCenterDisplayType_Other:
title = [NSString stringWithFormat:YMLocalizedString(@"20.20.61_text_14"),
self.userInfo.nick];
break;
case MedalsCenterDisplayType_Square:
title = YMLocalizedString(@"20.20.61_text_10");
break;
default:
break;
}
[self setupCustomNavigationBar:^{}
title:self.isForMyMedals ? YMLocalizedString(@"20.20.61_text_1") : YMLocalizedString(@"20.20.61_text_10")
title:title
titleColor:[UIColor whiteColor]];
[self setupCustonNavigationRightButtons:@[
[self medalsRankButton],
[self medalsSquareButton],
] sizes:@[
[self setupCustonNavigationRightButtons:navigationButtons
sizes:@[
[NSValue valueWithCGSize:CGSizeMake(22, 22)],
[NSValue valueWithCGSize:CGSizeMake(22, 22)]
]];
@@ -106,17 +153,77 @@ typedef enum : NSInteger {
- (void)setupBackground {
self.view.backgroundColor = UIColorFromRGB(0x1B0043);
UIImageView *topBg = [self topBG];
UIImageView *bottomBg = [self bottomBG];
[self.view addSubview:topBg];
[self.view addSubview:bottomBg];
[topBg mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.leading.trailing.mas_equalTo(self.view);
make.height.mas_equalTo(kGetScaleWidth(314));
if (self.displayType == MedalsCenterDisplayType_Other) {
[bottomBg mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.leading.trailing.mas_equalTo(self.view);
make.top.mas_equalTo(self.view).offset(66 + 98 + 44 + kSafeAreaTopHeight);
}];
} else {
UIImageView *topBg = [self topBG];
[self.view addSubview:topBg];
[topBg mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.leading.trailing.mas_equalTo(self.view);
make.height.mas_equalTo(kGetScaleWidth(314));
}];
[bottomBg mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.leading.trailing.mas_equalTo(self.view);
make.height.mas_equalTo(kGetScaleWidth(445));
}];
}
}
- (void)setupOthersMedalInfo {
UIImageView *bg = [[UIImageView alloc] initWithImage:kImage(@"medals_other_bg")];
[self.view addSubview:bg];
[bg mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(80);
make.leading.trailing.mas_equalTo(self.view).inset(12);
make.height.mas_equalTo(kGetScaleWidth(98));
}];
[bottomBg mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.leading.trailing.mas_equalTo(self.view);
make.height.mas_equalTo(kGetScaleWidth(445));
self.otherBG = bg;
[self.view addSubview:self.otherAvatar];
[self.otherAvatar mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(bg);
make.leading.mas_equalTo(bg).offset(15);
make.size.mas_equalTo(CGSizeMake(53, 53));
}];
self.otherNameLabel = [UILabel labelInitWithText:@""
font:kFontSemibold(15)
textColor:UIColorFromRGB(0x313131)];
[self.view addSubview:self.otherNameLabel];
[self.otherNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.otherAvatar.mas_trailing).offset(10);
make.top.mas_equalTo(self.otherAvatar);
}];
UIImageView *rankIcon = [[UIImageView alloc] initWithImage:kImage(@"medals_rank")];
[self.view addSubview:rankIcon];
[rankIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.otherAvatar.mas_trailing).offset(10);
make.bottom.mas_equalTo(self.otherAvatar);
make.size.mas_equalTo(CGSizeMake(14, 18));
}];
self.otherCountLabel = [UILabel labelInitWithText:@""
font:kFontMedium(20)
textColor:UIColorFromRGB(0x313131)];
[self.view addSubview:self.otherCountLabel];
[self.otherCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(rankIcon.mas_trailing).offset(6);
make.centerY.mas_equalTo(rankIcon);
}];
self.otherMedal = [[NetImageView alloc] initWithImage:kImage(@"medals_empty")];
[self.view addSubview:self.otherMedal];
[self.otherMedal mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(bg);
make.trailing.mas_equalTo(bg).offset(-15);
make.size.mas_equalTo(CGSizeMake(80, 80));
}];
}
@@ -124,8 +231,13 @@ typedef enum : NSInteger {
UIStackView *centerTabsStackView = [self centerTabStack];
[self.view addSubview:centerTabsStackView];
[centerTabsStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(kGetScaleWidth(314));
make.bottom.mas_equalTo(kGetScaleWidth(-445));
if (self.displayType == MedalsCenterDisplayType_Other) {
make.top.mas_equalTo(self.otherBG.mas_bottom).offset(18);
} else {
make.top.mas_equalTo(kGetScaleWidth(314));
// make.bottom.mas_equalTo(kGetScaleWidth(-445));
}
make.height.mas_equalTo(44);
make.leading.trailing.mas_equalTo(self.view);
}];
}
@@ -262,20 +374,22 @@ typedef enum : NSInteger {
}
- (void)loadMedalsList:(MedalsCenterTabType)tabType page:(NSInteger)tabPage {
if (self.isForMyMedals) {
if (self.displayType == MedalsCenterDisplayType_Square) {
[self.presenter squareMedals:tabPage
type:tabType];
} else {
[self.presenter userMedals:self.userInfo.uid
page:tabPage
type:tabType];
} else {
[self.presenter squareMedals:tabPage
type:tabType];
}
}
#pragma mark - MedalsPresenterProtocol
- (void)userMedalsSuccess:(UserMedalsModel *)userMedalsModel {
self.userMedalsModel = userMedalsModel;
[self endReresh];
[self _updateDataSource:userMedalsModel.medalSeries];
[self _updateOtherInfo:userMedalsModel];
}
- (void)userMedalsFailure {
@@ -292,6 +406,14 @@ typedef enum : NSInteger {
[self endReresh];
}
- (void)_updateOtherInfo:(UserMedalsModel *)userModel {
if (self.displayType == MedalsCenterDisplayType_Other) {
self.otherAvatar.imageUrl = userModel.avatar;
self.otherNameLabel.text = userModel.nick;
self.otherCountLabel.text = @(userModel.medalNum).stringValue;
}
}
- (void)_updateDataSource:(NSArray <MedalSeriesVo *>*)models {
if (models.count < 8) {
@@ -338,7 +460,8 @@ typedef enum : NSInteger {
}
- (void)didTapRankButton:(UIButton *)sender {
MedalsRankViewController *vc = [[MedalsRankViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
- (void)didTapWearingButton:(UIButton *)sender {
@@ -348,7 +471,9 @@ typedef enum : NSInteger {
}
- (void)didTapEmptyMedalButton:(UIButton *)sender {
MedalsWearingViewController *vc = [[MedalsWearingViewController alloc] init];
[self addChildViewController:vc];
[self.view addSubview:vc.view];
}
- (void)didTapCenterTab:(UIButton *)sender {
@@ -566,4 +691,14 @@ typedef enum : NSInteger {
return _emptyView;
}
- (NetImageView *)otherAvatar {
if (!_otherAvatar) {
NetImageConfig *config = [[NetImageConfig alloc] init];
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
_otherAvatar = [[NetImageView alloc] initWithConfig:config];
[_otherAvatar setAllCornerRadius:53/2 borderWidth:1 borderColor:[UIColor whiteColor]];
}
return _otherAvatar;
}
@end

View File

@@ -23,7 +23,6 @@
@property (nonatomic, copy) NSArray <MedalVo *> *allMedalsVo;
@property (nonatomic, copy) NSArray <VipMedalSeatVo *> *vipSeatVo;
//@property (nonatomic, copy) NSArray <VipMedalSeatVo *> *vipSeatVo;
@end
@@ -97,6 +96,9 @@
self.vipSeatVo = model.vipMedalSeatVos;
self.allMedalsVo = model.allMedals;
if (model.allMedals.count < [self.presenter pageSize]) {
// TODO: footer
}
[self.controlAreaCollectionView reloadData];
[self.medalsAreaCollectionView reloadData];

View File

@@ -3667,3 +3667,7 @@
"20.20.61_text_8" = "Expiration time:%@";
"20.20.61_text_9" = "Forever";
"20.20.61_text_10" = "Medals Square";
"20.20.61_text_11" = "Medal Hall of Fame";
"20.20.61_text_12" = "Powerful Owner";
"20.20.61_text_13" = "View his medals";
"20.20.61_text_14" = "%@'s medal";