diff --git a/Moblin/VideoEffects/Scoreboard/ScoreboardEffectModularView.swift b/Moblin/VideoEffects/Scoreboard/ScoreboardEffectModularView.swift index fc8268f63..bdecbd46e 100644 --- a/Moblin/VideoEffects/Scoreboard/ScoreboardEffectModularView.swift +++ b/Moblin/VideoEffects/Scoreboard/ScoreboardEffectModularView.swift @@ -24,9 +24,9 @@ struct ScoreboardEffectModularView: View { private func calculateMaxHistory() -> Int { var maxHistory = 0 for indexPlusOne in 1 ... 5 { - let homeHas = getHistoricScore(team: config.team1, indexPlusOne: indexPlusOne) != nil - let awayHas = getHistoricScore(team: config.team2, indexPlusOne: indexPlusOne) != nil - if homeHas || awayHas { + let homeHas = getHistoricScore(team: config.team1, indexPlusOne: indexPlusOne) ?? "" + let awayHas = getHistoricScore(team: config.team2, indexPlusOne: indexPlusOne) ?? "" + if !homeHas.isEmpty || !awayHas.isEmpty { maxHistory = indexPlusOne } } @@ -43,6 +43,9 @@ struct ScoreboardEffectModularView: View { HStack(alignment: .top, spacing: 0) { let maxHistory = calculateMaxHistory() let histWidth = modular.fontSize() * 1.5 + let secondaryBoxWidth = fontSize() * 1.55 + let dynamicWidth = CGFloat(modular.width) - CGFloat(secondaryBoxWidth) + CGFloat(maxHistory) * + CGFloat(histWidth) VStack(spacing: 0) { stackedHistoryTeam( team: config.team1, @@ -59,7 +62,8 @@ struct ScoreboardEffectModularView: View { histWidth: histWidth ) } - .frame(width: CGFloat(modular.width) + CGFloat(maxHistory) * histWidth) + .frame(width: dynamicWidth) + // .frame(width: CGFloat(modular.width) + CGFloat(maxHistory - 1) * histWidth) infoBox() } } @@ -76,7 +80,7 @@ struct ScoreboardEffectModularView: View { let height = CGFloat(modular.rowHeight) HStack(spacing: 0) { teamName(team: modularTeam) - .padding(.leading, 6) + .padding(.leading, 8) .padding(.trailing, 2) .frame(maxWidth: .infinity, alignment: .leading) possession(show: team.possession) @@ -196,7 +200,7 @@ struct ScoreboardEffectModularView: View { ) } teamName(team: modularTeam) - .padding(.leading, 3) + .padding(.leading, 8) .frame(maxWidth: .infinity, alignment: .leading) possession(show: team.possession) if modular.layout == .stackedInline { @@ -274,7 +278,7 @@ struct ScoreboardEffectModularView: View { fontSize: CGFloat, width: CGFloat, gray: Bool, - weight: Font.Weight = .bold + weight: Font.Weight = .heavy ) -> some View { if !value.isEmpty { ZStack { @@ -284,10 +288,13 @@ struct ScoreboardEffectModularView: View { if let label, !label.isEmpty { VStack(spacing: -2) { Text(label) - .font(.system(size: fontSize * 0.25, weight: .bold)) + .font(.system(size: fontSize * 0.25)) .offset(x: 0, y: fontSize * 0.04) Text(value) - .font(.system(size: fontSize * 0.75, weight: weight)) + .font(.system( + size: fontSize * 0.75, + weight: weight + )) // the bold toggle doesn't seem to impact the team name } } else { Text(value) @@ -309,7 +316,7 @@ struct ScoreboardEffectModularView: View { private func teamName(team: SettingsWidgetModularScoreboardTeam) -> some View { Text(team.name) - .font(.system(size: fontSize())) + .font(.system(size: fontSize(), weight: .bold)) .bold(modular.isBold) .lineLimit(1) .minimumScaleFactor(0.1)