修改了个播评级的显示逻辑

This commit is contained in:
fengshuo
2023-01-04 18:49:02 +08:00
parent 5199bb3362
commit 9cced7047f
8 changed files with 153 additions and 110 deletions

View File

@@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
@class XPMineDataSkillCardTableViewCell, MineSkillCardListInfoModel;
@protocol XPMineDataSkillCardTableViewCellDelegate <NSObject>
- (void)xPMineDataSkillCardTableViewCell:(XPMineDataSkillCardTableViewCell *)view didSelectItem:(MineSkillCardListInfoModel *)skillInfo;
- (void)xPMineDataSkillCardTableViewCell:(XPMineDataSkillCardTableViewCell *)view didSelectItem:(nullable MineSkillCardListInfoModel *)skillInfo;
@end

View File

@@ -21,8 +21,12 @@
@property (nonatomic,strong) UILabel *titleLabel;
///
@property (nonatomic,strong) UICollectionView *collectionView;
///
@property (nonatomic,strong) UIView *emptyView;
///
@property (nonatomic,strong) UILabel *emptyLabel;
///
@property (nonatomic,strong) UIImageView *arrowImageView;
@end
@implementation XPMineDataSkillCardTableViewCell
@@ -43,7 +47,10 @@
[self.backImageView addSubview:self.titleLabel];
[self.backImageView addSubview:self.collectionView];
[self.backImageView addSubview:self.emptyLabel];
[self.backImageView addSubview:self.emptyView];
[self.emptyView addSubview:self.emptyLabel];
[self.emptyView addSubview:self.arrowImageView];
}
- (void)initSubViewConstraints {
@@ -65,11 +72,22 @@
make.right.mas_equalTo(self.backImageView).offset(-6);
}];
[self.emptyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
[self.emptyView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.backImageView).inset(10);
make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(12);
make.height.mas_equalTo(47);
}];
[self.arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(6.5, 11));
make.centerY.mas_equalTo(self.emptyView);
make.right.mas_equalTo(self.emptyView).offset(-5);
}];
[self.emptyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.emptyView);
make.centerX.mas_equalTo(self.emptyView);
}];
}
#pragma mark - UICollectionViewDelegate And UICollectionViewDatasource
@@ -93,6 +111,12 @@
}
}
- (void)tapEmptySkillCard {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineDataSkillCardTableViewCell:didSelectItem:)]) {
[self.delegate xPMineDataSkillCardTableViewCell:self didSelectItem:nil];
}
}
#pragma mark - Getters And Setters
- (void)setDatasourece:(NSArray *)datasourece {
_datasourece = datasourece;
@@ -149,16 +173,37 @@
}
return _collectionView;
}
- (UIView *)emptyView {
if (!_emptyView) {
_emptyView = [[UIView alloc] init];
_emptyView.backgroundColor = UIColorFromRGB(0xF4F7FF);
_emptyView.layer.masksToBounds = YES;
_emptyView.layer.cornerRadius = 8;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapEmptySkillCard)];
[_emptyView addGestureRecognizer:tap];
}
return _emptyView;
}
- (UIImageView *)arrowImageView {
if (!_arrowImageView) {
_arrowImageView = [[UIImageView alloc] init];
_arrowImageView.userInteractionEnabled = YES;
_arrowImageView.image = [UIImage imageNamed:@"common_right_arrow"];
}
return _arrowImageView;
}
- (UILabel *)emptyLabel {
if (!_emptyLabel) {
_emptyLabel = [[UILabel alloc] init];
_emptyLabel.text = @"还未添加技能卡喔";
_emptyLabel.font = [UIFont systemFontOfSize:10];
_emptyLabel.font = [UIFont systemFontOfSize:12];
_emptyLabel.textAlignment = NSTextAlignmentCenter;
_emptyLabel.backgroundColor = UIColorFromRGB(0xF4F7FF);
_emptyLabel.layer.masksToBounds = YES;
_emptyLabel.layer.cornerRadius = 8;
_emptyLabel.textColor = [ThemeColor secondTextColor];
_emptyLabel.userInteractionEnabled = YES;
}
return _emptyLabel;
}

View File

@@ -8,17 +8,11 @@
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class AnchorLevelTimeView;
@protocol AnchorLevelTimeViewDelegate <NSObject>
- (void)anchorLevelTimeViewReloadAnchorInfo:(AnchorLevelTimeView *)view;
@end
@interface AnchorLevelTimeView : UIView
///剩余时间秒
@property (nonatomic,assign) int nextRemaining;
///代理
@property (nonatomic,weak) id<AnchorLevelTimeViewDelegate> delegate;
- (void)countDownFinish;
- (void)countDownChange:(int)number;
@end
NS_ASSUME_NONNULL_END

View File

@@ -32,17 +32,12 @@
///
@property (nonatomic,strong) UILabel *secondsLabel;
///
@property (strong, nonatomic) dispatch_source_t timer;
@end
@implementation AnchorLevelTimeView
- (void)dealloc {
[self stopCountDown];
}
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
@@ -52,6 +47,38 @@
return self;
}
- (void)countDownFinish {
self.firstHourLabel.text = @"0";
self.secondHourLabel.text = @"0";
self.firstMinuteLabel.text = @"0";
self.secondMinuteLabel.text = @"0";
self.firstSecondLabel.text = @"0";
self.secondSecondabel.text = @"0";
}
- (void)countDownChange:(int)time {
int seconds = time % 60;
int minutes = (time / 60) % 60;
int hours = time / 3600;
NSString * hour = [NSString stringWithFormat:@"%02d", hours];
NSString * minute = [NSString stringWithFormat:@"%02d", minutes];
NSString * second = [NSString stringWithFormat:@"%02d", seconds];
if (second.length > 1){
self.firstSecondLabel.text = [second substringWithRange:NSMakeRange(0, second.length -1)];
self.secondSecondabel.text = [second substringFromIndex:second.length - 1];
}
if (minute.length > 1){
self.firstMinuteLabel.text = [minute substringWithRange:NSMakeRange(0, minute.length -1)];
self.secondMinuteLabel.text = [minute substringFromIndex:minute.length - 1];
}
if (hour.length > 1){
self.firstHourLabel.text = [hour substringWithRange:NSMakeRange(0, hour.length -1)];
self.secondHourLabel.text = [hour substringFromIndex:hour.length - 1];
}
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.firstHourLabel];
@@ -118,79 +145,7 @@
}];
}
//
- (void)stopCountDown {
if (self.timer != nil) {
dispatch_source_cancel(self.timer);
self.timer = nil;
}
}
//
- (void)openCountdownWithTime:(int)totalTime{
if (time <= 0) {
return;
}
__block int time = totalTime; //
if (self.timer != nil) {
dispatch_source_cancel(self.timer);
}
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
self.timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
dispatch_source_set_timer(self.timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //
__weak typeof(self) weakself = self;
dispatch_source_set_event_handler(self.timer, ^{
__strong typeof(weakself) self = weakself;
if(time <= 0){ //
dispatch_source_cancel(self.timer);
dispatch_async(dispatch_get_main_queue(), ^{
self.firstHourLabel.text = @"0";
self.secondHourLabel.text = @"0";
self.firstMinuteLabel.text = @"0";
self.secondMinuteLabel.text = @"0";
self.firstSecondLabel.text = @"0";
self.secondSecondabel.text = @"0";
if (self.delegate && [self.delegate respondsToSelector:@selector(anchorLevelTimeViewReloadAnchorInfo:)]) {
[self.delegate anchorLevelTimeViewReloadAnchorInfo:self];
}
});
}else{
time--;
dispatch_async(dispatch_get_main_queue(), ^{
int seconds = time % 60;
int minutes = (time / 60) % 60;
int hours = time / 3600;
NSString * hour = [NSString stringWithFormat:@"%02d", hours];
NSString * minute = [NSString stringWithFormat:@"%02d", minutes];
NSString * second = [NSString stringWithFormat:@"%02d", seconds];
if (second.length > 1){
self.firstSecondLabel.text = [second substringWithRange:NSMakeRange(0, second.length -1)];
self.secondSecondabel.text = [second substringFromIndex:second.length - 1];
}
if (minute.length > 1){
self.firstMinuteLabel.text = [minute substringWithRange:NSMakeRange(0, minute.length -1)];
self.secondMinuteLabel.text = [minute substringFromIndex:minute.length - 1];
}
if (hour.length > 1){
self.firstHourLabel.text = [hour substringWithRange:NSMakeRange(0, hour.length -1)];
self.secondHourLabel.text = [hour substringFromIndex:hour.length - 1];
}
});
}
});
dispatch_resume(self.timer);
}
#pragma mark - Getters And Setters
- (void)setNextRemaining:(int)nextRemaining {
_nextRemaining = nextRemaining;
if (_nextRemaining > 0) {
[self openCountdownWithTime:_nextRemaining];
}
}
- (UILabel *)firstHourLabel {
if (!_firstHourLabel) {

View File

@@ -12,6 +12,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface AnchorLevelView : UIView
///用户评级信息
@property (nonatomic,strong) AnchorLevelModel *levelInfo;
- (void)stopCountDown;
@end
NS_ASSUME_NONNULL_END

View File

@@ -10,14 +10,14 @@
#import <Masonry/Masonry.h>
///Tool
#import "ThemeColor.h"
#import "Api+Mine.h"
#import "TTPopup.h"
///Model
#import "AnchorLevelModel.h"
///View
#import "AnchorLevelProgressView.h"
#import "AnchorLevelTimeView.h"
@interface AnchorLevelView ()<AnchorLevelTimeViewDelegate>
@interface AnchorLevelView ()
///
@property (nonatomic,strong) UIImageView *backImageView;
@@ -35,10 +35,15 @@
@property (nonatomic,strong) UIImageView *updateImageView;
///
@property (nonatomic,strong) AnchorLevelTimeView *timeView;
///
@property (strong, nonatomic) dispatch_source_t timer;
@end
@implementation AnchorLevelView
- (void)dealloc {
[self stopCountDown];
}
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
@@ -52,8 +57,6 @@
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.backImageView];
[self.backImageView addSubview:self.levelImageView];
[self.backImageView addSubview:self.titleImageView];
[self.backImageView addSubview:self.currentLevelLabel];
@@ -117,14 +120,44 @@
}];
}
#pragma mark - AnchorLevelTimeViewDelegate
- (void)anchorLevelTimeViewReloadAnchorInfo:(AnchorLevelTimeView *)view {
[Api requestAnchorGradeInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
AnchorLevelModel * model = [AnchorLevelModel modelWithDictionary:data.data];
self.levelInfo = model;
//
- (void)stopCountDown {
if (self.timer != nil) {
dispatch_source_cancel(self.timer);
self.timer = nil;
}
}
//
- (void)openCountdownWithTime:(int)totalTime{
if (time <= 0) {
return;
}
__block int time = totalTime; //
if (self.timer != nil) {
dispatch_source_cancel(self.timer);
}
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
self.timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
dispatch_source_set_timer(self.timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //
__weak typeof(self) weakself = self;
dispatch_source_set_event_handler(self.timer, ^{
__strong typeof(weakself) self = weakself;
if(time <= 0){ //
dispatch_source_cancel(self.timer);
dispatch_async(dispatch_get_main_queue(), ^{
[self.timeView countDownFinish];
[TTPopup dismiss];
});
}else{
time--;
dispatch_async(dispatch_get_main_queue(), ^{
[self.timeView countDownChange:time];
});
}
}];
});
dispatch_resume(self.timer);
}
#pragma mark - Getters And Setters
@@ -133,7 +166,7 @@
if (_levelInfo) {
self.diamondView.levelInfo = _levelInfo;
self.replyView.levelInfo = _levelInfo;
self.timeView.nextRemaining = _levelInfo.nextRemaining;
[self openCountdownWithTime:_levelInfo.nextRemaining];
if ([_levelInfo.grade isEqualToString:@"S"]) {
self.levelImageView.image = [UIImage imageNamed:@"mine_anchor_level_s"];
} else if([_levelInfo.grade isEqualToString:@"B"]) {
@@ -212,7 +245,6 @@
- (AnchorLevelTimeView *)timeView {
if (!_timeView) {
_timeView = [[AnchorLevelTimeView alloc] init];
_timeView.delegate = self;
}
return _timeView;
}

View File

@@ -191,7 +191,7 @@
make.width.mas_equalTo(91);
make.height.mas_equalTo(28);
make.right.mas_equalTo(self);
make.bottom.mas_equalTo(self.skillCardButton.mas_top).offset(-14);
make.bottom.mas_equalTo(self.avatarImageView).offset(-19);
}];
}
@@ -514,7 +514,12 @@
self.attentionStackView.hidden = NO;
self.accountView.hidden = NO;
self.nobleEntranceView.hidden = NO;
self.skillCardButton.hidden = NO;
if (self.anchorLevel.isHidden) {
self.skillCardButton.hidden = NO;
} else {
self.skillCardButton.hidden = YES;
}
}
}
}
@@ -536,6 +541,7 @@
if (_anchorLevelInfo) {
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventRoom_grade_profit_pop_show];
self.anchorLevel.hidden = NO;
self.skillCardButton.hidden = YES;
if ([_anchorLevelInfo.grade isEqualToString:@"S"]) {
[self.anchorLevel setBackgroundImage:[UIImage imageNamed:@"mine_anchor_level_enter_s"] forState:UIControlStateNormal];
} else if([_anchorLevelInfo.grade isEqualToString:@"B"]) {
@@ -549,6 +555,11 @@
}
} else {
self.anchorLevel.hidden = YES;
if (self.userInfo.parentMode) {//
self.skillCardButton.hidden = YES;
} else {
self.skillCardButton.hidden = NO;
}
}
}
@@ -639,6 +650,7 @@
_skillCardButton.backgroundColor = UIColorRGBAlpha(0xFFFFFF, 0.7);
_skillCardButton.layer.cornerRadius = 14;
_skillCardButton.layer.masksToBounds = YES;
_skillCardButton.hidden = YES;
[_skillCardButton addTarget:self action:@selector(tapSkillCardRecognizer) forControlEvents:UIControlEventTouchUpInside];
}
return _skillCardButton;

View File

@@ -435,7 +435,10 @@
gradeView.levelInfo = info;
TTPopupService * config = [[TTPopupService alloc] init];
config.contentView = gradeView;
@kWeakify(gradeView);
config.didFinishDismissHandler = ^(BOOL isDismissOnBackgroundTouch) {
@kStrongify(gradeView);
[gradeView stopCountDown];
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventRoom_grade_profit_close_click];
};
[TTPopup popupWithConfig:config];