Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions Moblin/VideoEffects/Scoreboard/ScoreboardEffectModularView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand All @@ -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,
Expand All @@ -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()
}
}
Expand All @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
Expand All @@ -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)
Expand Down
Loading