Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 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
32 changes: 32 additions & 0 deletions app/src/main/graphql/GameById.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
query GameById($id: String!) {
game(id: $id){
id
city
date
gender
location
opponentId
result
sport
state
time
scoreBreakdown
team {
id
color
image
name
}
boxScore {
team
period
time
description
scorer
assist
scoreBy
corScore
oppScore
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.cornellappdev.score.components

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -123,6 +124,7 @@ private fun FeaturedGameCardPreview() = ScorePreview {

@Composable
fun FeaturedGameCard(
id: String,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should never require an id to show a Composable, the only parameters Composables should take are things related to its view state, or click methods. So really, this composable should have an onClick: () -> Unit method. Then we would write:

onClick = { 
                    onClick(game.id)
                }

And pass it through like that. Lmk if that makes sense.

leftTeamLogo: Painter,
rightTeamLogo: String,
team: String,
Expand All @@ -137,11 +139,12 @@ fun FeaturedGameCard(
modifier: Modifier = Modifier,
headerModifier: Modifier = Modifier,
leftScore: Int? = null,
rightScore: Int? = null
rightScore: Int? = null,
onClick: (String) -> Unit = {}
) {
Column(
modifier = modifier
.fillMaxWidth()
.fillMaxWidth().clickable { onClick(id) }
) {

FeaturedGameHeader(
Expand All @@ -156,6 +159,7 @@ fun FeaturedGameCard(
)

GameCard(
id = id,
teamLogo = rightTeamLogo,
team = team,
date = date,
Expand All @@ -172,7 +176,8 @@ fun FeaturedGameCard(
bottomStart = 16.dp,
bottomEnd = 16.dp
)
)
),
onClick = onClick
)
}
}
Expand All @@ -181,6 +186,7 @@ fun FeaturedGameCard(
@Composable
private fun GameScheduleScreen() = ScorePreview {
FeaturedGameCard(
id = "1",
leftTeamLogo = painterResource(R.drawable.cornell_logo),
rightTeamLogo = "https://cornellbigred.com/images/logos/penn_200x200.png?width=80&height=80&mode=max",//painterResource(R.drawable.penn_logo),
leftScore = 32,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import com.cornellappdev.score.theme.saturatedGreen

@Composable
fun GameCard(
id: String,
teamLogo: String,
team: String,
date: String,
Expand All @@ -57,7 +58,7 @@ fun GameCard(
sportIcon: Painter,
topCornerRound: Boolean,
modifier: Modifier = Modifier,
onClick: (Boolean) -> Unit = {}
onClick: (String) -> Unit
) {
val cardShape = if (topCornerRound) {
RoundedCornerShape(16.dp) // Rounded all
Expand Down Expand Up @@ -89,7 +90,7 @@ fun GameCard(
)
}
)
.clickable { onClick(false) }
.clickable { onClick(id) }
) {
Column(
modifier = Modifier
Expand Down Expand Up @@ -210,6 +211,7 @@ fun GameCard(
private fun GameCardPreview() = ScorePreview {
Column {
GameCard(
id = "1",
teamLogo = "https://cornellbigred.com/images/logos/penn_200x200.png?width=80&height=80&mode=max", //painterResource(id = R.drawable.penn_logo),
team = "Penn",
date = "5/20/2024",
Expand All @@ -219,6 +221,7 @@ private fun GameCardPreview() = ScorePreview {
sportIcon = painterResource(id = R.drawable.ic_baseball),
topCornerRound = false,
modifier = Modifier.padding(16.dp),
onClick = {}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,19 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import coil3.compose.AsyncImage
import com.cornellappdev.score.R
import com.cornellappdev.score.theme.Style.scoreHeaderText
import com.cornellappdev.score.theme.Style.vsText

@Composable
fun GameScoreHeader(
leftTeamLogo: Painter,
rightTeamLogo: Painter,
rightTeamLogo: String,
gradientColor1: Color,
gradientColor2: Color,
leftScore: Int,
rightScore: Int,
modifier: Modifier = Modifier
) {
Box(
Expand All @@ -64,7 +67,7 @@ fun GameScoreHeader(

Row {
Text(
text = "0",
text = leftScore.toString(),
style = scoreHeaderText,
modifier = Modifier.width(52.dp),
textAlign = TextAlign.Center
Expand All @@ -76,15 +79,15 @@ fun GameScoreHeader(
)

Text(
text = "0",
text = rightScore.toString(),
style = scoreHeaderText,
modifier = Modifier.width(52.dp),
textAlign = TextAlign.Center
)
}

Image(
painter = rightTeamLogo,
AsyncImage(
model = rightTeamLogo,
contentDescription = "Right Team Logo",
modifier = Modifier.height(70.dp)
)
Expand All @@ -97,9 +100,11 @@ fun GameScoreHeader(
private fun GameScoreHeaderPreview() = ScorePreview {
GameScoreHeader(
leftTeamLogo = painterResource(R.drawable.cornell_logo),
rightTeamLogo = painterResource(R.drawable.penn_logo),
rightTeamLogo = "https://images.sidearmdev.com/fit?url=https%3a%2f%2fdxbhsrqyrr690.cloudfront.net%2fsidearm.nextgen.sites%2fcornellbigred.com%2fimages%2flogos%2fpenn_200x200.png&height=80&width=80&type=webp",
gradientColor1 = Color(0xFFE1A69F),
gradientColor2 = Color(0xFF011F5B),
leftScore = 0,
rightScore = 0,
modifier = Modifier.height(185.dp)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import com.cornellappdev.score.theme.CrimsonPrimary
import com.cornellappdev.score.theme.GrayLight
import com.cornellappdev.score.theme.GrayPrimary
import com.cornellappdev.score.theme.Style.heading1
import com.cornellappdev.score.theme.White
import com.cornellappdev.score.util.gameList

@Composable
Expand Down Expand Up @@ -60,7 +59,8 @@ fun DotIndicator(
fun GamesCarousel(
games: List<GameCardData>,
variant: GamesCarouselVariant,
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
onClick: (String) -> Unit,
) {
val pagerState = rememberPagerState(pageCount = { games.size })
Column(
Expand All @@ -81,6 +81,7 @@ fun GamesCarousel(
) { page ->
val game = games[page]
FeaturedGameCard(
id = game.id,
leftTeamLogo = painterResource(R.drawable.cornell_logo),
rightTeamLogo = game.teamLogo,
team = game.team,
Expand All @@ -93,7 +94,8 @@ fun GamesCarousel(
modifier = Modifier,
headerModifier = Modifier,
gradientColor1 = CornellRed,
gradientColor2 = game.teamColor
gradientColor2 = game.teamColor,
onClick = onClick
)
}

Expand All @@ -110,5 +112,5 @@ fun GamesCarousel(
@Composable
@Preview
private fun GamesCarouselPreview() = ScorePreview {
GamesCarousel(gameList, GamesCarouselVariant.UPCOMING)
GamesCarousel(gameList, GamesCarouselVariant.UPCOMING, onClick = {})
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
Expand All @@ -24,7 +23,7 @@ import com.cornellappdev.score.theme.Style.heading2
fun NavigationHeader(title: String, onBackPressed: () -> Unit) {
Box(
modifier = Modifier
.shadow(elevation = 8.dp, clip = false, spotColor = Color.Black.copy(0.05f))
//.shadow(elevation = 8.dp, clip = false, spotColor = Color.Black.copy(0.05f))
.background(Color.White)
) {
Box(
Expand Down Expand Up @@ -55,6 +54,6 @@ fun NavigationHeader(title: String, onBackPressed: () -> Unit) {

@Preview
@Composable
private fun NavigationHeaderPreview() = ScorePreview {
NavigationHeader("Game Details", {})
private fun NavigationHeaderPreview() {
NavigationHeader("Game Details", {})
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import java.time.LocalDate
fun PastGameCard(
data: GameCardData,
modifier: Modifier = Modifier,
onClick: (Boolean) -> Unit = {}
onClick: (String) -> Unit = {}
) {
Card(
colors = CardDefaults.cardColors(containerColor = Color.White),
Expand All @@ -58,7 +58,7 @@ fun PastGameCard(
Modifier
.border(width = 1.dp, color = GrayStroke, RoundedCornerShape(16.dp))
)
.clickable { onClick(true) }
.clickable { onClick(data.id) }
) {
Row(
modifier = Modifier
Expand Down Expand Up @@ -201,6 +201,7 @@ private fun TeamScore(
@Composable
private fun PastGameCardPreview() = ScorePreview {
val gameCard = GameCardData(
id = "1",
teamLogo = "https://cornellbigred.com/images/logos/penn_200x200.png?width=80&height=80&mode=max",
team = "University of Pennsylvania",
teamColor = Color.Red,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import coil3.compose.AsyncImage
import com.cornellappdev.score.R
import com.cornellappdev.score.components.ScorePreview
import com.cornellappdev.score.model.ScoreEvent
import com.cornellappdev.score.theme.GrayPrimary
Expand Down Expand Up @@ -46,13 +48,25 @@ fun ScoreEventItem(event: ScoreEvent) {
.padding(vertical = 16.dp),
verticalAlignment = Alignment.CenterVertically
) {
Image(
painter = painterResource(event.team.logo),
contentDescription = event.team.name,
modifier = Modifier
.size(40.dp)
.padding(end = 12.dp)
)
if (event.team.name == "COR"){ // TODO: Check if its "COR" for all queries. It is for baseball
Image(
painter = painterResource(R.drawable.cornell_logo),
contentDescription = event.team.name,
modifier = Modifier
.size(40.dp)
.padding(end = 12.dp)
)
}
else{
AsyncImage(
model = event.team.logo,
contentDescription = event.team.name, // Turn this into a if statement if i know the link for cornell logo
modifier = Modifier
.size(40.dp)
.padding(end = 12.dp)
)
}


Row(
modifier = Modifier.weight(2f),
Expand Down Expand Up @@ -90,7 +104,7 @@ fun ScoreEventItem(event: ScoreEvent) {
Row(verticalAlignment = Alignment.CenterVertically) {
Text(
text = homeScore.toString(),
style = if (event.team.name == "Cornell") metricSemibold else metricNormal,
style = if (event.team.name == "Cornell") metricSemibold else metricNormal, // TODO: Check name
color = GrayPrimary,
textAlign = TextAlign.Center
)
Expand Down
Loading