fix:修正部分问题
This commit is contained in:
@@ -137,7 +137,7 @@
|
||||
}];
|
||||
|
||||
[self.boomImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.contentView).offset(11);
|
||||
make.bottom.mas_equalTo(self.heatView.mas_top).offset(-6);
|
||||
make.trailing.mas_equalTo(self.contentView).offset(-8);
|
||||
make.size.mas_equalTo(CGSizeMake(40, 40));
|
||||
}];
|
||||
|
@@ -1104,7 +1104,7 @@
|
||||
|
||||
- (UIImageView *)progressBar {
|
||||
if (!_progressBar) {
|
||||
UIImage *progressImage = [kImage(@"room_boom_progress_bar") resizableImageWithCapInsets:UIEdgeInsetsMake(40, 0, 0, 0) resizingMode:UIImageResizingModeTile];
|
||||
UIImage *progressImage = [kImage(@"room_boom_progress_bar") resizableImageWithCapInsets:UIEdgeInsetsMake(10, 0, 20, 0) resizingMode:UIImageResizingModeTile];
|
||||
_progressBar = [[UIImageView alloc] initWithImage:progressImage];
|
||||
_progressBar.userInteractionEnabled = YES;
|
||||
_progressBar.hidden = NO;
|
||||
|
@@ -112,17 +112,27 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView;
|
||||
|
||||
- (void)updateForBoomDetailArray:(NSArray <BoomDetailModel*> *)models {
|
||||
_boomModels = models;
|
||||
if (!models || models.count == 0) {
|
||||
self.boomView.hidden = YES;
|
||||
return;
|
||||
}
|
||||
|
||||
self.boomView.hidden = NO;
|
||||
BOOL hasBoom = NO;
|
||||
if (models) {
|
||||
for (BoomDetailModel *boom in models) {
|
||||
if (boom.currLevel == 1) {
|
||||
hasBoom = YES;
|
||||
self.boomView.boomModel = boom;
|
||||
self.boomView.hidden = NO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasBoom) {
|
||||
// 处理到顶级后可能找不到数据的异常
|
||||
self.boomView.boomModel = [models lastObject];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setupBoomManager {
|
||||
|
@@ -126,14 +126,15 @@ exitCurrentRoom:(void(^)(void))exit {
|
||||
return;
|
||||
}
|
||||
|
||||
__block NSString *targetRoomUid = self.model.roomUid;
|
||||
@kWeakify(self);
|
||||
[TTPopup alertWithMessage:YMLocalizedString(@"Combo_10") confirmHandler:^{
|
||||
@kStrongify(self);
|
||||
if (self.exitCurrentRoom) {
|
||||
self.exitCurrentRoom();
|
||||
}
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[XPRoomViewController openRoom:self.model.roomUid
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[XPRoomViewController openRoom:targetRoomUid
|
||||
viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
|
||||
});
|
||||
} cancelHandler:^{}];
|
||||
|
@@ -58,11 +58,14 @@
|
||||
|
||||
BOOL isNumeric(NSString *string) {
|
||||
NSError *error = nil;
|
||||
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"^[0-9]+$" options:0 error:&error];
|
||||
// 修改正则表达式,支持整数和包含小数点的数字
|
||||
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"^[0-9]*\\.?[0-9]+$" options:0 error:&error];
|
||||
|
||||
if (error) {
|
||||
NSLog(@"Error creating regex: %@", error.localizedDescription);
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSRange range = NSMakeRange(0, string.length);
|
||||
NSTextCheckingResult *match = [regex firstMatchInString:string options:0 range:range];
|
||||
return match != nil;
|
||||
@@ -84,6 +87,28 @@ BOOL isNumeric(NSString *string) {
|
||||
}
|
||||
return formattedString;
|
||||
}
|
||||
|
||||
- (NSString *)formatCoinsWithDouble:(double)coins {
|
||||
NSString *formattedString;
|
||||
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
|
||||
[formatter setMinimumFractionDigits:0]; // 设置最少保留 0 位小数
|
||||
[formatter setMaximumFractionDigits:2]; // 设置最多保留 2 位小数
|
||||
[formatter setNumberStyle:NSNumberFormatterDecimalStyle]; // 使用小数格式
|
||||
|
||||
if (coins >= 1000000.0) {
|
||||
// 转换为M单位
|
||||
double valueInMillions = coins / 1000000.0;
|
||||
formattedString = [NSString stringWithFormat:@"%@M", [formatter stringFromNumber:@(valueInMillions)]];
|
||||
} else if (coins >= 1000.0) {
|
||||
// 转换为K单位
|
||||
double valueInThousands = coins / 1000.0;
|
||||
formattedString = [NSString stringWithFormat:@"%@K", [formatter stringFromNumber:@(valueInThousands)]];
|
||||
} else {
|
||||
// 保持原始值
|
||||
formattedString = [formatter stringFromNumber:@(coins)];
|
||||
}
|
||||
return formattedString;
|
||||
}
|
||||
#pragma mark - Getters And Setters
|
||||
- (void)setTitle:(NSString *)title {
|
||||
if (![title isKindOfClass:[NSString class]]) {
|
||||
@@ -94,7 +119,7 @@ BOOL isNumeric(NSString *string) {
|
||||
}
|
||||
|
||||
if (isNumeric(title)) {
|
||||
_titleLabel.text = [self formatCoins:[title integerValue]];
|
||||
_titleLabel.text = [self formatCoinsWithDouble:[title doubleValue]];
|
||||
} else {
|
||||
_titleLabel.text = title;
|
||||
}
|
||||
|
Reference in New Issue
Block a user