-
-
Save rjuric/a74d428d4d6594fafec88fe6e5965bc9 to your computer and use it in GitHub Desktop.
Bracket cells to display match data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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