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 @@ -26,49 +26,30 @@ import com.cornellappdev.score.theme.Style.bodyNormal
import com.cornellappdev.score.util.highlightsList
import com.cornellappdev.score.util.recentSearchList

sealed interface SearchResultsState {
data object Recent : SearchResultsState
data class Results(val items: List<HighlightData>) : SearchResultsState
data object Empty : SearchResultsState
}
enum class SearchUiState { RECENT, EMPTY, RESULTS }

@Composable
fun HighlightsCardLazyColumn(
recentSearchList: List<String>,
query: String,
highlightsList: List<HighlightData>,
onItemClick: () -> Unit,
onCloseClick: () -> Unit,
filteredResults: List<HighlightData>,
onItemClick: (String) -> Unit,
onCloseClick: (String) -> Unit,
numResultsHeader: (@Composable () -> Unit)? = null
) {

Column(
modifier = Modifier.padding(horizontal = 24.dp)
) {
/*todo: move to VM*/
val resultsState: SearchResultsState =
when {
recentSearchList.isNotEmpty() && query.isEmpty() ->
SearchResultsState.Recent

query.isNotEmpty() -> {
val filtered = highlightsList.filter {
it.title.contains(query, ignoreCase = true)
}

if (filtered.isEmpty()) {
SearchResultsState.Empty
} else {
SearchResultsState.Results(filtered)
}
}

else -> SearchResultsState.Recent
}

val uiStateKey = when {
query.isEmpty() -> SearchUiState.RECENT
filteredResults.isEmpty() -> SearchUiState.EMPTY
else -> SearchUiState.RESULTS
}

AnimatedContent(
targetState = resultsState,
targetState = uiStateKey,
transitionSpec = {
(fadeIn() + slideInVertically { it / 8 }) togetherWith
(fadeOut() + slideOutVertically { -it / 8 })
Expand All @@ -77,29 +58,29 @@ fun HighlightsCardLazyColumn(
) { state ->

when (state) {
SearchResultsState.Recent -> {
SearchUiState.RECENT -> {
RecentSearches(
recentSearchList,
onItemClick,
onCloseClick
)
}

SearchResultsState.Empty -> {
SearchUiState.EMPTY -> {
EmptyStateBox(
icon = R.drawable.ic_kid_star,
title = "No results yet."
)
}

is SearchResultsState.Results -> {
SearchUiState.RESULTS -> {
Column {
numResultsHeader?.invoke()

LazyColumn(
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
items(state.items) { item ->
items(filteredResults) { item ->
when (item) {
is HighlightData.Video ->
VideoHighlightCard(item.data, true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ import androidx.compose.ui.unit.dp
import com.cornellappdev.score.R
import com.cornellappdev.score.components.ScorePreview
import com.cornellappdev.score.model.HighlightData
import com.cornellappdev.score.screen.HighlightsSubScreenType
import com.cornellappdev.score.theme.Style.bodyNormal
import com.cornellappdev.score.theme.Style.heading2
import com.cornellappdev.score.util.highlightsList

@Composable
fun HighlightsCardRow(
highlightsList: List<HighlightData>,
rowHeader: String
rowHeader: String,
toSubScreen: (HighlightsSubScreenType) -> Unit
) {
Column(
modifier = Modifier.fillMaxWidth()
Expand All @@ -47,7 +49,7 @@ fun HighlightsCardRow(
style = heading2
)
Row(
modifier = Modifier.clickable {/*todo navigation to Today screen*/ },
modifier = Modifier.clickable { toSubScreen(if (rowHeader == "Today") HighlightsSubScreenType.TODAY else HighlightsSubScreenType.PAST3DAYS) },
verticalAlignment = Alignment.CenterVertically
) {
Text(
Expand Down Expand Up @@ -82,6 +84,6 @@ fun HighlightsCardRow(
@Composable
private fun HighlightsCardRowPreview() {
ScorePreview {
HighlightsCardRow(highlightsList, "Today")
HighlightsCardRow(highlightsList, "Today", {})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,30 @@ 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,
contentColor = GrayPrimary
contentColor = GrayPrimary,
disabledContainerColor = GrayLight
),
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 4.dp),
) {
Expand All @@ -67,32 +69,41 @@ private fun HighlightsFilterButton(

@Composable
fun HighlightsFilterRow(
sportList: List<Sport>,
onFilterSelected: (Sport) -> Unit,
sportList: List<SportSelection>,
selectedSport: 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 ->

val isSelected = selectedSport == selection

HighlightsFilterButton(
sport = selection.sport,
onFilterSelected = onFilterSelected,
isSelected = isSelected
)
}
item { Spacer(Modifier.width(12.dp)) }
}
}

@Preview
@Composable
private fun HighlightsFilterButtonPreview() {
var isSelected by remember { mutableStateOf(false) }
HighlightsFilterButton(Sport.BASEBALL, { isSelected = !isSelected }, isSelected = isSelected)
HighlightsFilterButton(Sport.BASEBALL, { !isSelected }, isSelected = isSelected)
}
Comment on lines 100 to 103
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Preview click no longer toggles isSelected.

The lambda passed to onFilterSelected now has signature (SportSelection) -> Unit. { !isSelected } just computes and discards !isSelected; the preview button won't actually toggle its selected state on click. Wire the state update through the callback so the preview reflects real behavior.

🛠️ Proposed fix
-    var isSelected by remember { mutableStateOf(false) }
-    HighlightsFilterButton(Sport.BASEBALL, { !isSelected }, isSelected = isSelected)
+    var isSelected by remember { mutableStateOf(false) }
+    HighlightsFilterButton(
+        sport = Sport.BASEBALL,
+        onFilterSelected = { isSelected = !isSelected },
+        isSelected = isSelected
+    )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@app/src/main/java/com/cornellappdev/score/components/highlights/HighlightsFilter.kt`
around lines 100 - 103, The preview's onFilterSelected lambda currently computes
`{ !isSelected }` but doesn't update state and no longer matches the
`(SportSelection) -> Unit` signature; update the Preview in
HighlightsFilterButtonPreview so the lambda accepts the SportSelection parameter
and toggles the local isSelected state (e.g., `{ _: SportSelection -> isSelected
= !isSelected }`), ensuring the local var isSelected is mutated when
HighlightsFilterButton's onFilterSelected is invoked so clicks in the preview
reflect real behavior.


@Preview
@Composable
private fun HighlightsFilterRowPreview() {
HighlightsFilterRow(sportList, {})
HighlightsFilterRow(sportSelectionList, SportSelection.All, {})
}
Loading
Loading