Skip to content

Instantly share code, notes, and snippets.

@rjuric
Last active March 16, 2023 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjuric/a74d428d4d6594fafec88fe6e5965bc9 to your computer and use it in GitHub Desktop.
Save rjuric/a74d428d4d6594fafec88fe6e5965bc9 to your computer and use it in GitHub Desktop.
Bracket cells to display match data
struct BracketCell: View {
let matchData: MatchData
var body: some View {
VStack(spacing: 0) {
topLabelArea
team1ScoreArea
team2ScoreArea
touchForMoreInfoArea
}
.listRowSeparator(.hidden)
.listRowInsets(EdgeInsets())
.padding()
}
private var topLabelArea: some View {
Text("\(matchData.team1) - \(matchData.team2)")
.foregroundColor(.white)
.bold()
.frame(height: 20)
.padding(.horizontal)
.frame(maxWidth: .infinity)
.background(Color.gray)
}
private var team1ScoreArea: some View {
HStack(spacing: 0) {
Text(matchData.team1)
Spacer()
Text("\(matchData.team1Score)")
.bold()
}
.padding(.horizontal)
.frame(height: 20)
.frame(maxWidth: .infinity)
.background(Color.white)
.border(Color.black, width: 1)
}
private var team2ScoreArea: some View {
HStack(spacing: 0) {
Text(matchData.team2)
Spacer()
Text("\(matchData.team2Score)")
.bold()
}
.padding(.horizontal)
.frame(height: 20)
.frame(maxWidth: .infinity)
.background(Color.white)
.border(Color.black, width: 1)
}
private var touchForMoreInfoArea: some View {
Text("Touch For More Info")
.frame(height: 20)
.padding(.horizontal)
.frame(maxWidth: .infinity)
.background(Color.gray)
.foregroundColor(.black)
}
}
struct BracketCell_Previews: PreviewProvider {
private static let previewMatchData = MatchData(team1: "Team 1", team2: "Team 2", team1Score: 2, team2Score: 1)
static var previews: some View {
BracketCell(matchData: previewMatchData)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment