-
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 19 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
88 changes: 88 additions & 0 deletions
88
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,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 | ||
amjiao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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( | ||
amjiao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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, "", highlightsList, | ||
| { HighlightsCardLazyColumnNumResultsHeader(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.
97 changes: 97 additions & 0 deletions
97
...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,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 -> | ||
amjiao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (focusState.isFocused && !isFocused) { | ||
| /*todo clear the highlight rows and show recent searches*/ | ||
| } | ||
| }, | ||
| horizontalArrangement = Arrangement.spacedBy(12.dp), | ||
| verticalAlignment = Alignment.CenterVertically | ||
| ) { | ||
| HighlightsSearchBar( | ||
| onSearchClick = { | ||
amjiao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| isFocused = true | ||
| }, | ||
| modifier = Modifier | ||
| .weight(1f) | ||
| .onFocusChanged { state -> | ||
amjiao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // When the search bar loses focus, hide cancel | ||
| if (!state.isFocused) { | ||
| isFocused = !isFocused | ||
| } | ||
| } | ||
| ) | ||
|
|
||
| AnimatedVisibility( | ||
| isFocused | ||
| ) { | ||
| Text( | ||
| "Cancel", | ||
| style = bodyMedium, | ||
| modifier = Modifier.clickable { | ||
| isFocused = true; | ||
amjiao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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) | ||
| } | ||
| } | ||
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.