-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
bce211d
Update build.gradle.kts
amjiao 6a04011
xml files
amjiao 7859639
Nav to HighlightsScreen
amjiao 289f4e4
components
amjiao de3f5f8
Screens
amjiao 82b1a32
pull results lazycolumn out into separate component
amjiao b8bab79
Clean up
amjiao 1b3d9ec
Focus on searchbar when HighlightsSearchScreen is launched
amjiao e34db06
Searchbar functionality fixes
amjiao cba8227
Merge branch 'main' into amy-highlights
amjiao 69eac9d
pr gradle fixes
amjiao a597341
pr RecentSearches fixes
amjiao 250559d
pr search bar fixes
amjiao edf83c0
recent search item padding fix
amjiao 1ad57cd
Parameterize previews
amjiao 91c976f
recentsearches UI fix
amjiao 5dc83ea
Abstract results lazy column
amjiao 917f1da
clean up app/gradle
amjiao b8dd80c
fix search bar clear icon animation
amjiao 3910d80
Animate recent searches to results
amjiao f2df140
Refactor search bar
amjiao 638cc52
add parameters for functionality
amjiao d2d881f
small fixes, address PR comments
amjiao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
146 changes: 146 additions & 0 deletions
146
app/src/main/java/com/cornellappdev/score/components/highlights/HighlightsCardLazyColumn.kt
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| package com.cornellappdev.score.components.highlights | ||
|
|
||
| import androidx.compose.animation.AnimatedContent | ||
| import androidx.compose.animation.fadeIn | ||
| import androidx.compose.animation.fadeOut | ||
| import androidx.compose.animation.slideInVertically | ||
| import androidx.compose.animation.slideOutVertically | ||
| import androidx.compose.animation.togetherWith | ||
| 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 | ||
|
|
||
| sealed interface SearchResultsState { | ||
| data object Recent : SearchResultsState | ||
| data class Results(val items: List<HighlightData>) : SearchResultsState | ||
| data object Empty : SearchResultsState | ||
| } | ||
|
|
||
| @Composable | ||
| fun HighlightsCardLazyColumn( | ||
| recentSearchList: List<String>, | ||
| query: String, | ||
| highlightsList: List<HighlightData>, | ||
| onItemClick: () -> Unit, | ||
| onCloseClick: () -> 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 | ||
| } | ||
|
|
||
|
|
||
| AnimatedContent( | ||
| targetState = resultsState, | ||
| transitionSpec = { | ||
| (fadeIn() + slideInVertically { it / 8 }) togetherWith | ||
| (fadeOut() + slideOutVertically { -it / 8 }) | ||
| }, | ||
| label = "SearchResultsAnimation" | ||
| ) { state -> | ||
|
|
||
| when (state) { | ||
| SearchResultsState.Recent -> { | ||
| RecentSearches( | ||
| recentSearchList, | ||
| onItemClick, | ||
| onCloseClick | ||
| ) | ||
| } | ||
|
|
||
| SearchResultsState.Empty -> { | ||
| EmptyStateBox( | ||
| icon = R.drawable.ic_kid_star, | ||
| title = "No results yet." | ||
| ) | ||
| } | ||
|
|
||
| is SearchResultsState.Results -> { | ||
| Column { | ||
| numResultsHeader?.invoke() | ||
|
|
||
| LazyColumn( | ||
| verticalArrangement = Arrangement.spacedBy(16.dp) | ||
| ) { | ||
| items(state.items) { 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 HighlightsCardLazyColumnResultsHeader( | ||
| size: Int | ||
| ) { | ||
| Column { | ||
| Text("$size Results", style = bodyNormal) | ||
| Spacer(Modifier.height(16.dp)) | ||
| } | ||
| } | ||
|
|
||
| @Preview | ||
| @Composable | ||
| private fun HighlightsCardLazyColumnSubScreenPreview() { | ||
| ScorePreview { | ||
| HighlightsCardLazyColumn(recentSearchList, "", highlightsList, {}, {}) | ||
| } | ||
| } | ||
|
|
||
| @Preview | ||
amjiao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @Composable | ||
| private fun HighlightsCardLazyColumnSearchResultsPreview() { | ||
| ScorePreview { | ||
| HighlightsCardLazyColumn( | ||
| recentSearchList, "hockey", highlightsList, {}, {}, | ||
| { HighlightsCardLazyColumnResultsHeader(highlightsList.size) }) | ||
| } | ||
| } | ||
52 changes: 0 additions & 52 deletions
52
app/src/main/java/com/cornellappdev/score/components/highlights/HighlightsScreenHeader.kt
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
...ain/java/com/cornellappdev/score/components/highlights/HighlightsScreenSearchFilterBar.kt
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package com.cornellappdev.score.components.highlights | ||
|
|
||
| import androidx.compose.foundation.layout.Column | ||
| 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.runtime.Composable | ||
| import androidx.compose.ui.Modifier | ||
| 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.util.sportList | ||
|
|
||
| @Composable | ||
| fun HighlightsScreenSearchFilterBar( | ||
| sportList: List<Sport> | ||
| ) { | ||
| Column(modifier = Modifier.fillMaxWidth()) { | ||
| HighlightsSearchBar(modifier = Modifier.padding(horizontal = 24.dp)) | ||
| Spacer(modifier = Modifier.height(16.dp)) | ||
| HighlightsFilterRow(sportList, {/*todo on filter selected*/ }) | ||
| } | ||
| } | ||
|
|
||
| @Preview | ||
| @Composable | ||
| private fun HighlightsScreenSearchFilterBarPreview() { | ||
| ScorePreview { | ||
| HighlightsScreenSearchFilterBar(sportList) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.