房间PK结果弹框的UI问题

This commit is contained in:
fengshuo
2022-05-27 18:24:13 +08:00
parent f172f32b40
commit 7227152adf
11 changed files with 133 additions and 46 deletions

View File

@@ -38,6 +38,7 @@
#import "XPUserCardViewController.h"
#import "XPRoomTopicAlertView.h"
#import "XPRoomSendTextView.h"
#import "XPRoomPKResultView.h"
@implementation XPRoomMessageParser
@@ -288,24 +289,39 @@
} else if(attachment.second == Custom_Message_Sub_Room_PK_Result) {
NSString * victoryStr;
if (model.result == RoomPKResultType_Draw) {
RoomPKTeamModel * blueTeam;
RoomPKTeamModel * redTeam;
for (int i = 0 ; i < model.teams.count; i++) {
RoomPKTeamModel * team = [model.teams objectAtIndex:i];
if (team.team == GroupType_Red) {
redTeam = team;
}else{
blueTeam = team;
}
}
RoomPKTeamModel * team = [model.teams firstObject];
if (model.voteMode == RoomPKVoteModeType_NumberPerson) {
victoryStr = @"平局";
NSString * resultScale = [NSString stringWithFormat:@"%@:%@",[NSString stringWithFormat:@"%lld", team.score],[NSString stringWithFormat:@"%lld", team.score]];
NSString * result = [NSString stringWithFormat:@"本场PK结果%@\n PK值%@",victoryStr, resultScale];
NSString * result = [NSString stringWithFormat:@"本场PK结果%@\nPK值:%@",victoryStr, resultScale];
[attribute appendAttributedString:[self createTextAttribute:result color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]];
}else{
if (team.protecScore > 0) {
NSString * resultScale = [NSString stringWithFormat:@"%@:%@",[NSString stringWithFormat:@"%lld", team.score],[NSString stringWithFormat:@"%lld", team.score]];
victoryStr = @"平局";
NSString * result = [NSString stringWithFormat:@"本场PK结果%@\n PK值%@",victoryStr, resultScale];
NSString * result = [NSString stringWithFormat:@"本场PK结果%@\nPK值%@",victoryStr, resultScale];
[attribute appendAttributedString:[self createTextAttribute:result color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]];
}else{
victoryStr = @"平局";
NSString * result = [NSString stringWithFormat:@"本场PK结果%@\n PK值%@",victoryStr, @"0:0"];
NSString * result = [NSString stringWithFormat:@"本场PK结果%@\nPK值%@",victoryStr, @"0:0"];
[attribute appendAttributedString:[self createTextAttribute:result color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]];
}
}
if (team.score > 0) {
[attribute appendAttributedString:[[NSMutableAttributedString alloc] initWithString:@"\n"]];
NSString * teamStr = [NSString stringWithFormat:@"蓝队守护者:%@ \n 蓝队守护值: %@ \n 红队守护者: %@ \n 红队守护值: %@", blueTeam.protector.nick.length > 0 ? blueTeam.protector.nick : @"", [[NSNumber numberWithLongLong:blueTeam.protecScore] stringValue], redTeam.protector.nick.length > 0 ? redTeam.protector.nick : @"", [[NSNumber numberWithLongLong:redTeam.protecScore] stringValue]];
[attribute appendAttributedString:[self createTextAttribute:teamStr color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]];
}
}else{
RoomPKTeamModel * victoryTeam;
RoomPKTeamModel * failTeam;
@@ -317,26 +333,31 @@
failTeam = team;
}
}
if (model.result == RoomPKResultType_Red){
victoryStr = @"红队胜利";
victoryStr = @"红队";
}else if (model.result == RoomPKResultType_Blue){
victoryStr = @"蓝队胜利";
victoryStr = @"蓝队";
}
NSString * resultScale = [NSString stringWithFormat:@"%@:%@",[NSString stringWithFormat:@"%lld", victoryTeam.score],[NSString stringWithFormat:@"%lld", failTeam.score]];
NSString * result;
if (model.voteMode == RoomPKVoteModeType_NumberPerson) {
result = [NSString stringWithFormat:@"本场PK结果%@\n PK值%@ \n 胜利方战斗值:%@",victoryStr, resultScale,[NSNumber numberWithLongLong:victoryTeam.score]];
result = [NSString stringWithFormat:@"本场PK结果%@胜利\nPK值%@ \n 胜利方战斗值:%@",victoryStr, resultScale,[NSNumber numberWithLongLong:victoryTeam.score]];
}else{
if (victoryTeam.protector) {
result = [NSString stringWithFormat:@"本场PK结果%@ \n PK值%@ \n 胜利方战斗值:%@ \n 守护者:%@ \n 守护值:%@",victoryStr, resultScale,[[NSNumber numberWithLongLong:victoryTeam.score] stringValue],victoryTeam.protector.nick.length > 0 ?victoryTeam.protector.nick : @"", [[NSNumber numberWithLongLong:victoryTeam.protecScore] stringValue]];
NSString * victoryProteror = victoryTeam.protector.nick.length > 0 ? victoryTeam.protector.nick : @"";
result = [NSString stringWithFormat:@"本场PK结果%@胜利! \nPK值%@ \n %@守护者:%@ \n %@守护值:%@",victoryStr, resultScale,victoryStr, victoryProteror, victoryStr,[[NSNumber numberWithLongLong:victoryTeam.protecScore] stringValue]];
}else{
result = [NSString stringWithFormat:@"本场PK结果%@ \n PK值%@ \n 胜利方战斗值:%@ \n 守护值:%@",victoryStr, resultScale,[[NSNumber numberWithLongLong:victoryTeam.score] stringValue], [[NSNumber numberWithLongLong:victoryTeam.protecScore] stringValue]];
result = [NSString stringWithFormat:@"本场PK结果%@胜利! \nPK值%@ \n %@守护值:%@",victoryStr, resultScale,victoryStr,[[NSNumber numberWithLongLong:victoryTeam.protecScore] stringValue]];
}
}
[attribute appendAttributedString:[self createTextAttribute:result color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]];
}
@kWeakify(self);
[attribute yy_setTextHighlightRange:NSMakeRange(0, attribute.length) color:nil backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
@kStrongify(self);
[self showRoomPKResult:attachment.data];
}];
} else if(attachment.second == Custom_Message_Sub_Room_PK_Mode_Open) {
NSString * pkType;
if (model.voteMode == RoomPKVoteModeType_GiftValue) {
@@ -363,6 +384,15 @@
return attribute;
}
- (void)showRoomPKResult:(NSDictionary *)dic {
RoomPKInfoModel * pkInfo = [RoomPKInfoModel modelWithDictionary:dic];
if (pkInfo.pkStatus == RoomPKStatusType_End) {
XPRoomPKResultView * result = [[XPRoomPKResultView alloc] init];
result.roomPKResultInfoModel = pkInfo;
[TTPopup popupView:result style:TTPopupStyleAlert];
}
}
#pragma mark -
- (NSAttributedString*)createRoomFaceAttribute:(AttachmentModel *)attachment {
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];