Skip to content
Open
Show file tree
Hide file tree
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
17 changes: 17 additions & 0 deletions app/src/main/graphql/Highlights.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
query Highlights($sportsType: String) {
articles(sportsType: $sportsType) {
title
image
sportsType
publishedAt
url
}
youtubeVideos {
title
thumbnail
url
publishedAt
duration
sportsType
}
}
17 changes: 16 additions & 1 deletion app/src/main/graphql/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ type Query {

gamesBySportGender(sport: String!, gender: String!): [GameType]

gamesByDate(startDate: DateTime!, endDate: DateTime!): [GameType]

teams: [TeamType]

team(id: String!): TeamType
Expand Down Expand Up @@ -58,6 +60,8 @@ Attributes:
- thumbnail: The URL of the video's thumbnail.
- url: The URL to the video.
- published_at: The date and time the video was published.
- duration: The duration of the video (optional).
- sportsType: The sport type extracted from the video title.
"""
type YoutubeVideoType {
id: String
Expand All @@ -73,6 +77,10 @@ type YoutubeVideoType {
url: String!

publishedAt: String!

duration: String

sportsType: String
}

"""
Expand Down Expand Up @@ -181,6 +189,13 @@ type TeamType {
name: String!
}

"""
The `DateTime` scalar type represents a DateTime
value as specified by
[iso8601](https://en.wikipedia.org/wiki/ISO_8601).
"""
scalar DateTime

type Mutation {
"""
Creates a new game.
Expand All @@ -195,7 +210,7 @@ type Mutation {
"""
Creates a new youtube video.
"""
createYoutubeVideo(b64Thumbnail: String!, description: String!, id: String!, publishedAt: String!, thumbnail: String!, title: String!, url: String!): CreateYoutubeVideo
createYoutubeVideo(b64Thumbnail: String!, description: String!, duration: String!, id: String!, publishedAt: String!, thumbnail: String!, title: String!, url: String!): CreateYoutubeVideo

"""
Creates a new article.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ fun ArticleHighlightCard(
Text(
color = Color.White,
style = labelsNormal,
text = articleHighlight.date
text = articleHighlight.dateString
)
}
}
Expand All @@ -110,6 +110,7 @@ private fun ArticleHighlightCardPreview() {
"Late Goal Lifts No. 6 Men’s Hockey Over Brown",
"maxresdefault.jpg",
"https://cornellsun.com/article/london-mcdavid-is-making-a-name-for-herself-at-cornell",
null,
"11/9",
Sport.ICE_HOCKEY
),
Expand All @@ -125,6 +126,7 @@ private fun WideArticleHighlightCardPreview() {
"Late Goal Lifts No. 6 Men’s Hockey Over Brown",
"maxresdefault.jpg",
"https://cornellsun.com/article/london-mcdavid-is-making-a-name-for-herself-at-cornell",
null,
"11/9",
Sport.ICE_HOCKEY
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,26 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.cornellappdev.score.model.Sport
import com.cornellappdev.score.model.SportSelection
import com.cornellappdev.score.theme.GrayLight
import com.cornellappdev.score.theme.GrayPrimary
import com.cornellappdev.score.theme.Stroke
import com.cornellappdev.score.theme.Style.bodyNormal
import com.cornellappdev.score.theme.White
import com.cornellappdev.score.util.sportList
import com.cornellappdev.score.util.sportSelectionList

@Composable
private fun HighlightsFilterButton(
sport: Sport,
onFilterSelected: (Sport) -> Unit,
onFilterSelected: (SportSelection) -> Unit,
isSelected: Boolean = false,
) {
OutlinedButton(
modifier = Modifier
.height(32.dp),
border = BorderStroke(width = 1.dp, color = Stroke),
onClick = { onFilterSelected(sport) },
onClick = { onFilterSelected(SportSelection.SportSelect(sport)) },
shape = RoundedCornerShape(100.dp),
colors = outlinedButtonColors(
containerColor = if (isSelected) GrayLight else White,
Expand All @@ -67,21 +69,26 @@ private fun HighlightsFilterButton(

@Composable
fun HighlightsFilterRow(
sportList: List<Sport>,
onFilterSelected: (Sport) -> Unit,
sportList: List<SportSelection>,
onFilterSelected: (SportSelection) -> Unit,
) {
LazyRow(
modifier = Modifier
.fillMaxWidth(),
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(12.dp),
contentPadding = PaddingValues(start = 24.dp, end = 24.dp),
verticalAlignment = Alignment.CenterVertically
) {
item { Spacer(Modifier.width(12.dp)) }
items(sportList) { item ->
HighlightsFilterButton(item, onFilterSelected)
items(
items = sportList.filterIsInstance<SportSelection.SportSelect>(),
key = { it.sport }
) { selection ->
HighlightsFilterButton(
sport = selection.sport,
onFilterSelected = onFilterSelected
)
}
item { Spacer(Modifier.width(12.dp)) }
}

}

@Preview
Expand All @@ -94,5 +101,5 @@ private fun HighlightsFilterButtonPreview() {
@Preview
@Composable
private fun HighlightsFilterRowPreview() {
HighlightsFilterRow(sportList, {})
HighlightsFilterRow(sportSelectionList, {})
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.cornellappdev.score.components.ScorePreview
import com.cornellappdev.score.model.Sport
import com.cornellappdev.score.model.SportSelection
import com.cornellappdev.score.util.sportList
import com.cornellappdev.score.util.sportSelectionList

@Composable
fun HighlightsScreenSearchFilterBar(
sportList: List<Sport>
sportList: List<SportSelection>
) {
Column(modifier = Modifier.fillMaxWidth()) {
HighlightsSearchBar(modifier = Modifier.padding(horizontal = 24.dp))
Expand All @@ -28,6 +30,6 @@ fun HighlightsScreenSearchFilterBar(
@Composable
private fun HighlightsScreenSearchFilterBarPreview() {
ScorePreview {
HighlightsScreenSearchFilterBar(sportList)
HighlightsScreenSearchFilterBar(sportSelectionList)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private fun Modifier.highlightsSearchRowModifier(): Modifier = this
.background(Color.White, RoundedCornerShape(100.dp))
.border(1.dp, GrayLight, RoundedCornerShape(100.dp))
.clip(RoundedCornerShape(100.dp))
.padding(horizontal = 16.dp, vertical = 8.dp)
.padding(horizontal = 8.dp, vertical = 8.dp)

@Composable
fun HighlightsSearchBar(
Expand Down Expand Up @@ -89,21 +89,19 @@ fun HighlightsSearchBar(
Row(
modifier =
Modifier
.highlightsSearchRowModifier()
.padding(horizontal = 8.dp),
.highlightsSearchRowModifier(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center
horizontalArrangement = Arrangement.spacedBy(4.dp)
) {
Icon(
painter = painterResource(R.drawable.search),
contentDescription = "search icon",
tint = Color.Unspecified
)
Spacer(Modifier.width(8.dp))
Box {
innerTextField()
if (searchQuery.isEmpty()) {
Expand Down Expand Up @@ -162,7 +160,7 @@ fun HighlightsSearchEntryPointRow(
.clickable { onClick() }
.then(modifier),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
horizontalArrangement = Arrangement.spacedBy(4.dp)
) {
Icon(
painter = painterResource(R.drawable.search),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ private fun VideoHighlightCardHeader(
AsyncImage(
model = imageUrl,
contentDescription = "Highlight article image",
contentScale = ContentScale.Crop
contentScale = ContentScale.Crop,
modifier = Modifier
.fillMaxWidth()
)
Box(
modifier = Modifier
Expand Down Expand Up @@ -94,17 +96,27 @@ fun VideoHighlightCardBody(
Row(
verticalAlignment = Alignment.CenterVertically
) {
Icon(
painter = painterResource(videoHighlight.sport.emptyIcon),
contentDescription = "Sport icon",
modifier = Modifier.size(24.dp),
tint = Color.Unspecified
)
Icon(
painter = painterResource(if (videoHighlight.gender == GenderDivision.FEMALE) R.drawable.ic_gender_women else R.drawable.ic_gender_men),
contentDescription = "Gender icon",
tint = Color.Unspecified
)
videoHighlight.sport?.let { sport ->
Icon(
painter = painterResource(sport.emptyIcon),
contentDescription = "Sport icon",
modifier = Modifier.size(24.dp),
tint = Color.Unspecified
)
}

videoHighlight.gender?.let { gender ->
val iconRes = when (gender) {
GenderDivision.FEMALE -> R.drawable.ic_gender_women
else -> R.drawable.ic_gender_men
}

Icon(
painter = painterResource(iconRes),
contentDescription = "Gender icon",
tint = Color.Unspecified
)
}
}
}
Spacer(Modifier.height(8.dp))
Expand All @@ -123,7 +135,7 @@ fun VideoHighlightCardBody(
}
Text(
style = labelsNormal,
text = videoHighlight.date
text = videoHighlight.dateString
)
}
}
Expand Down Expand Up @@ -157,17 +169,21 @@ class VideoHighlightsPreviewProvider : PreviewParameterProvider<VideoHighlightPr
"vs Columbia",
"maxresdefault.jpg",
"https://cornellsun.com/article/london-mcdavid-is-making-a-name-for-herself-at-cornell",
"11/9",
null,
"11/9/25",
Sport.BASEBALL,
GenderDivision.MALE
GenderDivision.MALE,
"0:44"
),
VideoHighlightData(
"Late Goal Lifts No. 6 Men’s Hockey Over Brown",
"maxresdefault.jpg",
"https://cornellsun.com/article/london-mcdavid-is-making-a-name-for-herself-at-cornell",
"11/9",
null,
"11/9/25",
Sport.BASEBALL,
GenderDivision.MALE
GenderDivision.MALE,
"0:44"
)
)
for (sample in samples) {
Expand Down
Loading
Loading