-
Notifications
You must be signed in to change notification settings - Fork 0
Highlights Search Screen UI #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
bce211d
6a04011
7859639
289f4e4
de3f5f8
82b1a32
b8bab79
1b3d9ec
e34db06
cba8227
69eac9d
a597341
250559d
edf83c0
1ad57cd
91c976f
5dc83ea
917f1da
b8dd80c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| package com.cornellappdev.score.components.highlights | ||
|
|
||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.Column | ||
| import androidx.compose.foundation.layout.Spacer | ||
| import androidx.compose.foundation.layout.height | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.lazy.LazyColumn | ||
| import androidx.compose.foundation.lazy.items | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import com.cornellappdev.score.R | ||
| import com.cornellappdev.score.components.EmptyStateBox | ||
| import com.cornellappdev.score.components.ScorePreview | ||
| import com.cornellappdev.score.model.HighlightData | ||
| import com.cornellappdev.score.theme.Style.bodyNormal | ||
| import com.cornellappdev.score.util.highlightsList | ||
| import com.cornellappdev.score.util.recentSearchList | ||
|
|
||
| @Composable | ||
| fun HighlightsCardLazyColumn( | ||
| recentSearchList: List<String>, | ||
| query: String, | ||
| highlightsList: List<HighlightData>, | ||
| numResultsHeader: (@Composable () -> Unit)? = null | ||
| ) { | ||
| Column( | ||
| modifier = Modifier.padding(horizontal = 24.dp) | ||
| ) { | ||
| if (recentSearchList.isNotEmpty() && query.isEmpty()) { //start state: no search attempted yet | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: It could be potentially worth considering using something like animatedcontent here to have more control over the transition between recent searches content and the search results |
||
| RecentSearches(recentSearchList) | ||
| } else if (query.isNotEmpty()) { //filtering - will pull this out to the viewmodel when i do that, just here for sanity check rn | ||
| val filteredList = highlightsList.filter { | ||
| it.title.contains(query, ignoreCase = true) | ||
| } | ||
| if (filteredList.isEmpty()) { | ||
| EmptyStateBox( | ||
| icon = R.drawable.ic_kid_star, | ||
| title = "No results yet.", | ||
| ) | ||
| } else { | ||
| numResultsHeader?.invoke() | ||
| LazyColumn( | ||
| verticalArrangement = Arrangement.spacedBy(16.dp) | ||
| ) { | ||
| items(highlightsList) { item -> | ||
| when (item) { | ||
| is HighlightData.Video -> VideoHighlightCard(item.data, true) | ||
| is HighlightData.Article -> ArticleHighlightCard(item.data, true) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /* Used to display number of results in on HighlightsSearchScreen*/ | ||
| @Composable | ||
| fun HighlightsCardLazyColumnNumResultsHeader( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: probably don't need to abbreviate num or can potentially just remove num |
||
| size: Int | ||
| ) { | ||
| Column { | ||
| Text("$size Results", style = bodyNormal) | ||
| Spacer(Modifier.height(16.dp)) | ||
| } | ||
| } | ||
|
|
||
| @Preview | ||
| @Composable | ||
| private fun HighlightsCardLazyColumnSubScreenPreview() { | ||
| ScorePreview { | ||
| HighlightsCardLazyColumn(recentSearchList, "", highlightsList) | ||
| } | ||
| } | ||
|
|
||
| @Preview | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: might be good to have a preview or preview parameter where we can see the highlights list as well instead of just recent searches |
||
| @Composable | ||
| private fun HighlightsCardLazyColumnSearchResultsPreview() { | ||
| ScorePreview { | ||
| HighlightsCardLazyColumn( | ||
| recentSearchList, "", highlightsList, | ||
| { HighlightsCardLazyColumnNumResultsHeader(highlightsList.size) }) | ||
| } | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| package com.cornellappdev.score.components.highlights | ||
|
|
||
| import androidx.compose.animation.AnimatedVisibility | ||
| import androidx.compose.foundation.clickable | ||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.Column | ||
| import androidx.compose.foundation.layout.Row | ||
| import androidx.compose.foundation.layout.Spacer | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.height | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.shape.RoundedCornerShape | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.runtime.mutableStateOf | ||
| import androidx.compose.runtime.remember | ||
| import androidx.compose.runtime.setValue | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.draw.clip | ||
| import androidx.compose.ui.focus.onFocusChanged | ||
| import androidx.compose.ui.platform.LocalFocusManager | ||
| 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.theme.Style.bodyMedium | ||
| import com.cornellappdev.score.util.sportList | ||
|
|
||
| @Composable | ||
| fun HighlightsScreenSearchFilterBar( | ||
| sportList: List<Sport> | ||
| ) { | ||
| val focusManager = LocalFocusManager.current | ||
| var isFocused by remember { mutableStateOf(true) } //todo: should probably be handled by viewModel | ||
| Column(modifier = Modifier.fillMaxWidth()) { | ||
| Row( | ||
| modifier = Modifier | ||
| .padding(horizontal = 24.dp) | ||
| .clip(shape = RoundedCornerShape(100.dp)) | ||
| .onFocusChanged { focusState -> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if this ideal to have here or if we can just pass in some sort of onFocus function/logic to the search bar component |
||
| if (focusState.isFocused && !isFocused) { | ||
| /*todo clear the highlight rows and show recent searches*/ | ||
| } | ||
| }, | ||
| horizontalArrangement = Arrangement.spacedBy(12.dp), | ||
| verticalAlignment = Alignment.CenterVertically | ||
| ) { | ||
| HighlightsSearchBar( | ||
| onSearchClick = { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if this is needed here if we have the focus change detection in the search bar itself? Maybe you can pass in an onFocus function? |
||
| isFocused = true | ||
| }, | ||
| modifier = Modifier | ||
| .weight(1f) | ||
| .onFocusChanged { state -> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if this is necessary if we have the logic in the text field? |
||
| // When the search bar loses focus, hide cancel | ||
| if (!state.isFocused) { | ||
| isFocused = !isFocused | ||
| } | ||
| } | ||
| ) | ||
|
|
||
| AnimatedVisibility( | ||
| isFocused | ||
| ) { | ||
| Text( | ||
| "Cancel", | ||
| style = bodyMedium, | ||
| modifier = Modifier.clickable { | ||
| isFocused = true; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be false? |
||
| focusManager.clearFocus(force = true) | ||
| /*todo: clear the text in the search bar*/ | ||
| } | ||
| ) | ||
| } | ||
| } | ||
| Spacer(modifier = Modifier.height(16.dp)) | ||
| HighlightsFilterRow(sportList, {/*todo on filter selected*/ }) | ||
| } | ||
| } | ||
|
|
||
| @Preview | ||
| @Composable | ||
| private fun HighlightsScreenSearchFilterBarActivePreview() { | ||
| ScorePreview { | ||
| HighlightsScreenSearchFilterBar(sportList) | ||
| } | ||
| } | ||
|
|
||
| @Preview | ||
| @Composable | ||
| private fun HighlightsScreenSearchFilterBarInactivePreview() { | ||
| ScorePreview { | ||
| HighlightsScreenSearchFilterBar(sportList) | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.