更新勋章相关模型和视图,添加对使用勋章的支持,优化可见性管理和状态更新逻辑,保持代码结构一致性。
This commit is contained in:
@@ -58,7 +58,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
@interface MineAllMedalModel : PIBaseModel
|
@interface MineAllMedalModel : PIBaseModel
|
||||||
@property (nonatomic, copy) NSArray <MedalVo *> *allMedals;
|
@property (nonatomic, copy) NSArray <MedalVo *> *allMedals;
|
||||||
@property (nonatomic, copy) NSDictionary <NSString *,NSArray *> *vipMedalSeatVos;
|
@property (nonatomic, copy) NSDictionary <NSString *,NSArray *> *vipMedalSeatVos;
|
||||||
@property (nonatomic, copy) NSArray *useMedals;
|
@property (nonatomic, copy) NSArray <MedalVo *> *useMedals;
|
||||||
@property (nonatomic, assign) NSInteger vipLevel;
|
@property (nonatomic, assign) NSInteger vipLevel;
|
||||||
@property (nonatomic, assign) NSInteger medalNum;
|
@property (nonatomic, assign) NSInteger medalNum;
|
||||||
@end
|
@end
|
||||||
|
@@ -44,6 +44,7 @@
|
|||||||
+ (NSDictionary *)mj_objectClassInArray {
|
+ (NSDictionary *)mj_objectClassInArray {
|
||||||
return @{
|
return @{
|
||||||
@"allMedals" : [MedalVo class],
|
@"allMedals" : [MedalVo class],
|
||||||
|
@"useMedals" : [MedalVo class],
|
||||||
// @"vipMedalSeatVos" : [VipMedalSeatVo class],
|
// @"vipMedalSeatVos" : [VipMedalSeatVo class],
|
||||||
// @"allMedals" : [MedalVo class],
|
// @"allMedals" : [MedalVo class],
|
||||||
};
|
};
|
||||||
|
@@ -25,6 +25,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
- (void)rankListSuccess:(MedalsRankModel *)model;
|
- (void)rankListSuccess:(MedalsRankModel *)model;
|
||||||
- (void)rankListFailure;
|
- (void)rankListFailure;
|
||||||
|
|
||||||
|
- (void)useMedalSuccess;
|
||||||
|
- (void)userMedalsFailure;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface MedalsPresenter : BaseMvpPresenter
|
@interface MedalsPresenter : BaseMvpPresenter
|
||||||
|
@@ -70,10 +70,17 @@
|
|||||||
|
|
||||||
- (void)updateMedalUseStatus:(NSString *)medalId
|
- (void)updateMedalUseStatus:(NSString *)medalId
|
||||||
isUse:(BOOL)isUse {
|
isUse:(BOOL)isUse {
|
||||||
|
@kWeakify(self);
|
||||||
[Api medalUseMedal:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
[Api medalUseMedal:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||||||
|
@kStrongify(self);
|
||||||
|
if ([[self getView] respondsToSelector:@selector(useMedalSuccess)]) {
|
||||||
|
[[self getView] useMedalSuccess];
|
||||||
|
}
|
||||||
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
||||||
|
@kStrongify(self);
|
||||||
|
if ([[self getView] respondsToSelector:@selector(userMedalsFailure)]) {
|
||||||
|
[[self getView] userMedalsFailure];
|
||||||
|
}
|
||||||
} showLoading:YES errorToast:YES] id:medalId useStatus:@(isUse == YES ? 1 : 0)];
|
} showLoading:YES errorToast:YES] id:medalId useStatus:@(isUse == YES ? 1 : 0)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -243,12 +243,25 @@ typedef enum : NSInteger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)setupWearingButton {
|
- (void)setupWearingButton {
|
||||||
|
UIView *wearingBg = [[UIView alloc] init];
|
||||||
|
[wearingBg addGradientBackgroundWithColors:@[
|
||||||
|
UIColorFromRGB(0xf2e7ff),
|
||||||
|
UIColorFromRGB(0xb497f6)
|
||||||
|
] startPoint:CGPointMake(0, 0.5) endPoint:CGPointMake(1, 0.5) cornerRadius:25/2];
|
||||||
|
[wearingBg setAllCornerRadius:25/2 borderWidth:1 borderColor:[UIColor whiteColor]];
|
||||||
|
[self.view addSubview:wearingBg];
|
||||||
|
|
||||||
|
|
||||||
UIButton *wearingButton = [self wearingButton];
|
UIButton *wearingButton = [self wearingButton];
|
||||||
[self.view addSubview:wearingButton];
|
[self.view addSubview:wearingButton];
|
||||||
[wearingButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
[wearingButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.top.mas_equalTo(90);
|
make.top.mas_equalTo(90);
|
||||||
make.trailing.mas_equalTo(-12);
|
make.trailing.mas_equalTo(-12);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
[wearingBg mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
|
make.edges.mas_equalTo(wearingButton).insets(UIEdgeInsetsMake(0, -15, 0, -25));
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setupEmptyUserMedals {
|
- (void)setupEmptyUserMedals {
|
||||||
@@ -449,6 +462,12 @@ typedef enum : NSInteger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)_updateWearingInfo {
|
||||||
|
if (self.displayType != MedalsCenterDisplayType_Other) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void)_updateOtherInfo:(UserMedalsModel *)userModel {
|
- (void)_updateOtherInfo:(UserMedalsModel *)userModel {
|
||||||
if (self.displayType == MedalsCenterDisplayType_Other) {
|
if (self.displayType == MedalsCenterDisplayType_Other) {
|
||||||
self.otherAvatar.imageUrl = userModel.avatar;
|
self.otherAvatar.imageUrl = userModel.avatar;
|
||||||
@@ -612,6 +631,8 @@ typedef enum : NSInteger {
|
|||||||
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
|
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||||
[button addTarget:self action:@selector(didTapWearingButton:) forControlEvents:UIControlEventTouchUpInside];
|
[button addTarget:self action:@selector(didTapWearingButton:) forControlEvents:UIControlEventTouchUpInside];
|
||||||
[button setTitle:YMLocalizedString(@"20.20.61_text_2") forState:UIControlStateNormal];
|
[button setTitle:YMLocalizedString(@"20.20.61_text_2") forState:UIControlStateNormal];
|
||||||
|
[button setTitleColor:UIColorFromRGB(0x201440) forState:UIControlStateNormal];
|
||||||
|
button.titleLabel.font = kFontMedium(12);
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
@class MedalVo;
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface MedalsWearingControlCollectionViewCell : UICollectionViewCell
|
@interface MedalsWearingControlCollectionViewCell : UICollectionViewCell
|
||||||
@@ -15,6 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
+ (instancetype)cellFor:(UICollectionView *)collectionView atIndexPath:(NSIndexPath *)index;
|
+ (instancetype)cellFor:(UICollectionView *)collectionView atIndexPath:(NSIndexPath *)index;
|
||||||
|
|
||||||
- (void)updateVIPLevel:(NSInteger)level;
|
- (void)updateVIPLevel:(NSInteger)level;
|
||||||
|
- (void)updateMedal:(MedalVo *)medalVo;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@@ -6,11 +6,48 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "MedalsWearingControlCollectionViewCell.h"
|
#import "MedalsWearingControlCollectionViewCell.h"
|
||||||
|
#import "MedalsModel.h"
|
||||||
|
|
||||||
|
@interface VipPill : UIView
|
||||||
|
|
||||||
|
- (void)updateLevel:(NSInteger)level;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation VipPill {
|
||||||
|
UILabel *contentLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithFrame:(CGRect)frame
|
||||||
|
{
|
||||||
|
self = [super initWithFrame:frame];
|
||||||
|
if (self) {
|
||||||
|
[self addGradientBackgroundWithColors:@[
|
||||||
|
UIColorFromRGB(0xf2e7ff),
|
||||||
|
UIColorFromRGB(0xb497f6)
|
||||||
|
] startPoint:CGPointMake(0, 0.5) endPoint:CGPointMake(1, 0.5) cornerRadius:6.5];
|
||||||
|
[self setAllCornerRadius:6.5 borderWidth:1 borderColor:[UIColor whiteColor]];
|
||||||
|
|
||||||
|
contentLabel = [UILabel labelInitWithText:@"VIP" font:kFontHeavy(10) textColor:UIColorFromRGB(0x1b0043)];
|
||||||
|
[self addSubview:contentLabel];
|
||||||
|
[contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
|
make.center.mas_equalTo(self);
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)updateLevel:(NSInteger)level {
|
||||||
|
contentLabel.text = [NSString stringWithFormat:@"VIP%@", @(level)];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@interface MedalsWearingControlCollectionViewCell ()
|
@interface MedalsWearingControlCollectionViewCell ()
|
||||||
|
|
||||||
@property (nonatomic, strong) NetImageView *medalImageView;
|
@property (nonatomic, strong) NetImageView *medalImageView;
|
||||||
@property (nonatomic, strong) UIImageView *vipImageView;
|
@property (nonatomic, strong) UIImageView *vipImageView;
|
||||||
|
@property (nonatomic, strong) VipPill *pill;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@@ -31,10 +68,36 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateVIPLevel:(NSInteger)level {
|
- (void)updateVIPLevel:(NSInteger)level {
|
||||||
self.vipImageView.hidden = level < 1;
|
if (level <= 0) {
|
||||||
|
self.pill.hidden = YES;
|
||||||
|
self.vipImageView.hidden = YES;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.vipImageView.hidden = NO;
|
||||||
NSString *imagePath = [NSString stringWithFormat:@"medals_control_vip%@",
|
NSString *imagePath = [NSString stringWithFormat:@"medals_control_vip%@",
|
||||||
@(level)];
|
@(level)];
|
||||||
self.vipImageView.image = kImage(imagePath);
|
self.vipImageView.image = kImage(imagePath);
|
||||||
|
|
||||||
|
self.pill.hidden = self.vipImageView.hidden;
|
||||||
|
[self.pill updateLevel:level];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)updateMedal:(MedalVo *)medalVo {
|
||||||
|
if (!medalVo) {
|
||||||
|
self.medalImageView.imageUrl = @"";
|
||||||
|
#if DEBUG
|
||||||
|
self.medalImageView.backgroundColor = [UIColor clearColor];
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (![medalVo.picUrl hasSuffix:@"mp4"]) {
|
||||||
|
self.medalImageView.imageUrl = medalVo.picUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
self.medalImageView.backgroundColor = [UIColor redColor];
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)initWithFrame:(CGRect)frame
|
- (instancetype)initWithFrame:(CGRect)frame
|
||||||
@@ -43,6 +106,7 @@
|
|||||||
if (self) {
|
if (self) {
|
||||||
[self.contentView addSubview:self.medalImageView];
|
[self.contentView addSubview:self.medalImageView];
|
||||||
[self.contentView addSubview:self.vipImageView];
|
[self.contentView addSubview:self.vipImageView];
|
||||||
|
[self.contentView addSubview:self.pill];
|
||||||
|
|
||||||
[self.medalImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.medalImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.edges.mas_equalTo(self.contentView);
|
make.edges.mas_equalTo(self.contentView);
|
||||||
@@ -52,6 +116,9 @@
|
|||||||
make.centerY.mas_equalTo(self.contentView.mas_bottom);
|
make.centerY.mas_equalTo(self.contentView.mas_bottom);
|
||||||
make.size.mas_equalTo(CGSizeMake(32, 13));
|
make.size.mas_equalTo(CGSizeMake(32, 13));
|
||||||
}];
|
}];
|
||||||
|
[self.pill mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
|
make.edges.mas_equalTo(self.vipImageView);
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@@ -73,4 +140,11 @@
|
|||||||
return _vipImageView;
|
return _vipImageView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (VipPill *)pill {
|
||||||
|
if (!_pill) {
|
||||||
|
_pill = [[VipPill alloc] initWithFrame:CGRectZero];
|
||||||
|
}
|
||||||
|
return _pill;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@@ -16,6 +16,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
|
|
||||||
- (void)updateCell:(MedalVo *)medalModel;
|
- (void)updateCell:(MedalVo *)medalModel;
|
||||||
|
|
||||||
|
// 可见性管理
|
||||||
|
- (void)willDisplay;
|
||||||
|
- (void)didEndDisplaying;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
@@ -55,6 +55,7 @@
|
|||||||
self = [super initWithFrame:frame];
|
self = [super initWithFrame:frame];
|
||||||
if (self) {
|
if (self) {
|
||||||
[self setupUI];
|
[self setupUI];
|
||||||
|
[self setupNotifications];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@@ -168,6 +169,51 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - 可见性管理
|
||||||
|
|
||||||
|
- (void)willDisplay {
|
||||||
|
self.isVisible = YES;
|
||||||
|
[self resumeMP4Playback];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)didEndDisplaying {
|
||||||
|
self.isVisible = NO;
|
||||||
|
[self pauseMP4Playback];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - 通知处理
|
||||||
|
|
||||||
|
- (void)appDidEnterBackground {
|
||||||
|
[self pauseMP4Playback];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)appWillEnterForeground {
|
||||||
|
if (self.isVisible) {
|
||||||
|
[self resumeMP4Playback];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)didReceiveMemoryWarning {
|
||||||
|
// 内存警告时停止播放
|
||||||
|
if (!self.isVisible) {
|
||||||
|
[self stopMP4Playback];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - 生命周期
|
||||||
|
|
||||||
|
- (void)dealloc {
|
||||||
|
// 停止播放
|
||||||
|
[self stopMP4Playback];
|
||||||
|
|
||||||
|
// 移除通知观察者
|
||||||
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||||
|
|
||||||
|
// 清理资源
|
||||||
|
self.mp4Parser = nil;
|
||||||
|
NSLog(@"MedalsWearingListCollectionViewCell dealloc");
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
- (VAPView *)mp4View {
|
- (VAPView *)mp4View {
|
||||||
if (!_mp4View) {
|
if (!_mp4View) {
|
||||||
@@ -188,4 +234,39 @@
|
|||||||
return _selectedImageView;
|
return _selectedImageView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setupNotifications {
|
||||||
|
// 监听应用进入后台和恢复前台的通知
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
|
selector:@selector(appDidEnterBackground)
|
||||||
|
name:UIApplicationDidEnterBackgroundNotification
|
||||||
|
object:nil];
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
|
selector:@selector(appWillEnterForeground)
|
||||||
|
name:UIApplicationWillEnterForegroundNotification
|
||||||
|
object:nil];
|
||||||
|
|
||||||
|
// 监听内存警告通知
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
|
selector:@selector(didReceiveMemoryWarning)
|
||||||
|
name:UIApplicationDidReceiveMemoryWarningNotification
|
||||||
|
object:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)prepareForReuse {
|
||||||
|
[super prepareForReuse];
|
||||||
|
|
||||||
|
// 停止播放
|
||||||
|
[self stopMP4Playback];
|
||||||
|
|
||||||
|
// 隐藏 mp4 视图
|
||||||
|
self.mp4View.hidden = YES;
|
||||||
|
self.imageView.hidden = NO;
|
||||||
|
|
||||||
|
// 重置状态
|
||||||
|
self.mp4Path = nil;
|
||||||
|
self.imagePath = nil;
|
||||||
|
self.isVisible = NO;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
#import "MedalsWearingControlCollectionViewCell.h"
|
#import "MedalsWearingControlCollectionViewCell.h"
|
||||||
#import "MJRefresh.h"
|
#import "MJRefresh.h"
|
||||||
|
|
||||||
@interface MedalsWearingViewController () <UICollectionViewDelegateFlowLayout, UICollectionViewDataSource>
|
@interface MedalsWearingViewController () <UICollectionViewDelegateFlowLayout, UICollectionViewDataSource, MedalsPresenterProtocol>
|
||||||
|
|
||||||
@property (nonatomic, strong) UIView *dismissArea;
|
@property (nonatomic, strong) UIView *dismissArea;
|
||||||
@property (nonatomic, strong) UIView *contentArea;
|
@property (nonatomic, strong) UIView *contentArea;
|
||||||
@@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
@property (nonatomic, assign) NSInteger medalsAreaPage;
|
@property (nonatomic, assign) NSInteger medalsAreaPage;
|
||||||
|
|
||||||
|
@property (nonatomic, copy) NSArray <MedalVo *> *useMedalsVo;
|
||||||
@property (nonatomic, copy) NSArray <MedalVo *> *allMedalsVo;
|
@property (nonatomic, copy) NSArray <MedalVo *> *allMedalsVo;
|
||||||
//@property (nonatomic, copy) NSArray <VipMedalSeatVo *> *vipSeatVo;
|
|
||||||
@property (nonatomic, copy) NSDictionary *vipSeatDic;
|
@property (nonatomic, copy) NSDictionary *vipSeatDic;
|
||||||
@property (nonatomic, assign) NSInteger minVipLevelForSeats;
|
@property (nonatomic, assign) NSInteger minVipLevelForSeats;
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
make.height.mas_equalTo(kGetScaleWidth(147));
|
make.height.mas_equalTo(kGetScaleWidth(147));
|
||||||
}];
|
}];
|
||||||
[self.controlAreaCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.controlAreaCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.edges.mas_equalTo(self.controlAreaBG).insets(UIEdgeInsetsMake(15, 15, 15, 15));
|
make.edges.mas_equalTo(self.controlAreaBG).insets(UIEdgeInsetsMake(15, 15, 0, 15));
|
||||||
}];
|
}];
|
||||||
|
|
||||||
[self.contentArea addSubview:self.medalsAreaCollectionView];
|
[self.contentArea addSubview:self.medalsAreaCollectionView];
|
||||||
@@ -107,6 +107,7 @@
|
|||||||
|
|
||||||
self.vipSeatDic = model.vipMedalSeatVos;
|
self.vipSeatDic = model.vipMedalSeatVos;
|
||||||
self.allMedalsVo = model.allMedals;
|
self.allMedalsVo = model.allMedals;
|
||||||
|
self.useMedalsVo = model.useMedals;
|
||||||
|
|
||||||
[self.controlAreaCollectionView reloadData];
|
[self.controlAreaCollectionView reloadData];
|
||||||
[self.medalsAreaCollectionView reloadData];
|
[self.medalsAreaCollectionView reloadData];
|
||||||
@@ -121,6 +122,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)useMedalSuccess {
|
||||||
|
[self headerRefresh];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)userMedalsFailure {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
- (void)endRefresh {
|
- (void)endRefresh {
|
||||||
[self.medalsAreaCollectionView.mj_header endRefreshing];
|
[self.medalsAreaCollectionView.mj_header endRefreshing];
|
||||||
[self.medalsAreaCollectionView.mj_footer endRefreshing];
|
[self.medalsAreaCollectionView.mj_footer endRefreshing];
|
||||||
@@ -140,32 +149,53 @@
|
|||||||
if (collectionView == self.controlAreaCollectionView) {
|
if (collectionView == self.controlAreaCollectionView) {
|
||||||
MedalsWearingControlCollectionViewCell *cell = [MedalsWearingControlCollectionViewCell cellFor:collectionView atIndexPath:indexPath];
|
MedalsWearingControlCollectionViewCell *cell = [MedalsWearingControlCollectionViewCell cellFor:collectionView atIndexPath:indexPath];
|
||||||
|
|
||||||
// 根据 vipSeatDic 数据判断是否调用 updateVIPLevel
|
// 找到 vipSeatDic 的最小 key,判断当前 index 是否适用显示 VIP level
|
||||||
NSString *seatKey = [NSString stringWithFormat:@"%ld", (long)(indexPath.row + 1)];
|
NSInteger minSeatIndex = NSIntegerMax;
|
||||||
NSArray *vipLevels = self.vipSeatDic[seatKey];
|
for (NSString *key in self.vipSeatDic.allKeys) {
|
||||||
|
NSInteger seatIndex = [key integerValue];
|
||||||
if (vipLevels && vipLevels.count > 0) {
|
if (seatIndex < minSeatIndex) {
|
||||||
// 找到最低的 VIP level
|
minSeatIndex = seatIndex;
|
||||||
NSInteger currentMinVipLevel = NSIntegerMax;
|
|
||||||
for (NSNumber *levelNum in vipLevels) {
|
|
||||||
NSInteger level = [levelNum integerValue];
|
|
||||||
if (level < currentMinVipLevel) {
|
|
||||||
currentMinVipLevel = level;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentMinVipLevel != NSIntegerMax) {
|
|
||||||
// 更新全局最低VIP level
|
|
||||||
if (self.minVipLevelForSeats == 0 || currentMinVipLevel < self.minVipLevelForSeats) {
|
|
||||||
self.minVipLevelForSeats = currentMinVipLevel;
|
|
||||||
}
|
|
||||||
[cell updateVIPLevel:currentMinVipLevel];
|
|
||||||
}
|
|
||||||
} else if (self.minVipLevelForSeats > 0) {
|
|
||||||
// 当前座位没有对应的vip seat vo,但之前已经有最低VIP level,则沿用
|
|
||||||
[cell updateVIPLevel:self.minVipLevelForSeats];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 当前 cell 的座位索引(从1开始)
|
||||||
|
NSInteger currentSeatIndex = indexPath.row + 1;
|
||||||
|
|
||||||
|
// 只有当前座位索引大于等于最小座位索引时,才处理 VIP level 逻辑
|
||||||
|
if (minSeatIndex != NSIntegerMax && currentSeatIndex >= minSeatIndex) {
|
||||||
|
// 根据 vipSeatDic 数据判断是否调用 updateVIPLevel
|
||||||
|
NSString *seatKey = [NSString stringWithFormat:@"%ld", (long)currentSeatIndex];
|
||||||
|
NSArray *vipLevels = self.vipSeatDic[seatKey];
|
||||||
|
|
||||||
|
if (vipLevels && vipLevels.count > 0) {
|
||||||
|
// 找到最低的 VIP level
|
||||||
|
NSInteger currentMinVipLevel = NSIntegerMax;
|
||||||
|
for (NSNumber *levelNum in vipLevels) {
|
||||||
|
NSInteger level = [levelNum integerValue];
|
||||||
|
if (level < currentMinVipLevel) {
|
||||||
|
currentMinVipLevel = level;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentMinVipLevel != NSIntegerMax) {
|
||||||
|
// 更新全局最低VIP level
|
||||||
|
if (self.minVipLevelForSeats == 0 || currentMinVipLevel < self.minVipLevelForSeats) {
|
||||||
|
self.minVipLevelForSeats = currentMinVipLevel;
|
||||||
|
}
|
||||||
|
[cell updateVIPLevel:currentMinVipLevel];
|
||||||
|
}
|
||||||
|
} else if (self.minVipLevelForSeats > 0) {
|
||||||
|
// 当前座位没有对应的vip seat vo,但之前已经有最低VIP level,则沿用
|
||||||
|
[cell updateVIPLevel:self.minVipLevelForSeats];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 如果当前座位索引小于最小座位索引,则不显示 VIP level
|
||||||
|
[cell updateVIPLevel:-1];
|
||||||
|
}
|
||||||
|
|
||||||
|
MedalVo *medalVo = [self.useMedalsVo xpSafeObjectAtIndex:indexPath.row];
|
||||||
|
[cell updateMedal:medalVo];
|
||||||
|
|
||||||
return cell;
|
return cell;
|
||||||
} else if (collectionView == self.medalsAreaCollectionView) {
|
} else if (collectionView == self.medalsAreaCollectionView) {
|
||||||
MedalsWearingListCollectionViewCell *cell = [MedalsWearingListCollectionViewCell cellFor:collectionView atIndexPath:indexPath];
|
MedalsWearingListCollectionViewCell *cell = [MedalsWearingListCollectionViewCell cellFor:collectionView atIndexPath:indexPath];
|
||||||
@@ -182,6 +212,19 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理 cell 的可见性
|
||||||
|
- (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath {
|
||||||
|
if ([cell isKindOfClass:[MedalsWearingListCollectionViewCell class]]) {
|
||||||
|
[(MedalsWearingListCollectionViewCell *)cell willDisplay];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath {
|
||||||
|
if ([cell isKindOfClass:[MedalsWearingListCollectionViewCell class]]) {
|
||||||
|
[(MedalsWearingListCollectionViewCell *)cell didEndDisplaying];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - Refresh Actions
|
#pragma mark - Refresh Actions
|
||||||
- (void)headerRefresh {
|
- (void)headerRefresh {
|
||||||
self.medalsAreaPage = 1;
|
self.medalsAreaPage = 1;
|
||||||
@@ -239,6 +282,7 @@
|
|||||||
_controlAreaCollectionView.backgroundColor = [UIColor clearColor];
|
_controlAreaCollectionView.backgroundColor = [UIColor clearColor];
|
||||||
_controlAreaCollectionView.delegate = self;
|
_controlAreaCollectionView.delegate = self;
|
||||||
_controlAreaCollectionView.dataSource = self;
|
_controlAreaCollectionView.dataSource = self;
|
||||||
|
_controlAreaCollectionView.clipsToBounds = NO;
|
||||||
|
|
||||||
[MedalsWearingControlCollectionViewCell registerTo:_controlAreaCollectionView];
|
[MedalsWearingControlCollectionViewCell registerTo:_controlAreaCollectionView];
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user