-
Notifications
You must be signed in to change notification settings - Fork 0
Highlights Screen UI #86
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
17 commits
Select commit
Hold shift + click to select a range
9089e1b
Highlights Card UI
amjiao 2beedca
Added wide highlight card case and handled title line overflow
amjiao f953e24
filter button for highlights screen
amjiao b367869
made highlights filter button clickable
amjiao de67392
highlights screen
amjiao bd7b7fa
Some name changes
amjiao 5ed8edd
Abstracted EmptyState
amjiao b4f48a2
EmptyState.kt improvements + resulting syntax changes in other files
amjiao f20dda3
Address highlights card comments
amjiao bfe40c2
Fixes to highlight cards
amjiao ed96d5f
Fixed SportSelectorHeader scroll appearance
amjiao f60d60b
Highlights Card Fixes
amjiao 83c08e7
HighlightsFilter fixes
amjiao 7420656
Search Bar refactoring
amjiao cd1b24b
Utils
amjiao ec47aa6
Fix padding to match design
amjiao 707b6b4
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
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
133 changes: 133 additions & 0 deletions
133
app/src/main/java/com/cornellappdev/score/components/highlights/ArticleHighlightsCard.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,133 @@ | ||
| package com.cornellappdev.score.components.highlights | ||
|
|
||
| import androidx.compose.foundation.background | ||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.Box | ||
| import androidx.compose.foundation.layout.Column | ||
| import androidx.compose.foundation.layout.Row | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.height | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.layout.width | ||
| import androidx.compose.foundation.shape.RoundedCornerShape | ||
| import androidx.compose.foundation.text.BasicText | ||
| import androidx.compose.material3.Icon | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.draw.clip | ||
| import androidx.compose.ui.graphics.Color | ||
| import androidx.compose.ui.layout.ContentScale | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.text.LinkAnnotation | ||
| import androidx.compose.ui.text.SpanStyle | ||
| import androidx.compose.ui.text.TextLinkStyles | ||
| import androidx.compose.ui.text.buildAnnotatedString | ||
| import androidx.compose.ui.text.style.TextDecoration | ||
| import androidx.compose.ui.text.style.TextOverflow | ||
| import androidx.compose.ui.text.withLink | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import coil3.compose.AsyncImage | ||
| import com.cornellappdev.score.R | ||
| import com.cornellappdev.score.model.ArticleHighlightData | ||
| import com.cornellappdev.score.model.Sport | ||
| import com.cornellappdev.score.theme.Style.bodySemibold | ||
| import com.cornellappdev.score.theme.Style.heading2 | ||
| import com.cornellappdev.score.theme.Style.labelsNormal | ||
| import com.cornellappdev.score.theme.White | ||
|
|
||
| @Composable | ||
| fun ArticleHighlightCard( | ||
| articleHighlight: ArticleHighlightData, | ||
| isWideFormat: Boolean | ||
| ) { | ||
| Box( | ||
| modifier = Modifier | ||
| .then(if (isWideFormat) Modifier.fillMaxWidth() else Modifier.width(241.dp)) | ||
| .height(192.dp) | ||
| .clip(shape = RoundedCornerShape(12.dp)) | ||
| ) { | ||
| //todo: empty state if image doesn't load | ||
| AsyncImage( | ||
| model = articleHighlight.imageUrl, | ||
| contentDescription = "highlight image", | ||
| contentScale = ContentScale.Crop | ||
| ) | ||
| Box( | ||
| modifier = Modifier | ||
| .fillMaxSize() | ||
| .background(color = Color.Black.copy(alpha = 0.4f)) | ||
| ) | ||
| Column( | ||
| modifier = Modifier | ||
| .fillMaxSize() | ||
| .padding(12.dp), | ||
| verticalArrangement = Arrangement.SpaceBetween | ||
| ) { | ||
| Text( | ||
| style = heading2, | ||
| color = Color.White, | ||
| text = articleHighlight.title, | ||
| maxLines = 4, | ||
| overflow = TextOverflow.Ellipsis | ||
| ) | ||
|
|
||
| Row( | ||
| modifier = Modifier.fillMaxWidth(), | ||
| horizontalArrangement = Arrangement.SpaceBetween, | ||
| verticalAlignment = Alignment.CenterVertically | ||
| ) { | ||
| Row( | ||
| verticalAlignment = Alignment.CenterVertically | ||
| ) { | ||
| if (isWideFormat) { | ||
| Text("Read at ", color = White) | ||
| } | ||
| ExternalLink( | ||
| articleHighlight.articleUrl, | ||
| urlLabel = "Cornell Daily Sun", | ||
| linkColor = White | ||
| ) | ||
| } | ||
| Text( | ||
| color = Color.White, | ||
| style = labelsNormal, | ||
| text = articleHighlight.date | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Preview | ||
| @Composable | ||
| private fun ArticleHighlightCardPreview() { | ||
| ArticleHighlightCard( | ||
| ArticleHighlightData( | ||
| "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", | ||
| Sport.ICE_HOCKEY | ||
| ), | ||
| false | ||
| ) | ||
| } | ||
|
|
||
| @Preview | ||
| @Composable | ||
| private fun WideArticleHighlightCardPreview() { | ||
| ArticleHighlightCard( | ||
| ArticleHighlightData( | ||
| "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", | ||
| Sport.ICE_HOCKEY | ||
| ), | ||
| true | ||
| ) | ||
| } |
55 changes: 55 additions & 0 deletions
55
app/src/main/java/com/cornellappdev/score/components/highlights/ExternalLink.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,55 @@ | ||
| package com.cornellappdev.score.components.highlights | ||
|
|
||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.Row | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.text.BasicText | ||
| import androidx.compose.material3.Icon | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.graphics.Color | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.text.LinkAnnotation | ||
| import androidx.compose.ui.text.SpanStyle | ||
| import androidx.compose.ui.text.TextLinkStyles | ||
| import androidx.compose.ui.text.buildAnnotatedString | ||
| import androidx.compose.ui.text.font.FontWeight | ||
| import androidx.compose.ui.text.style.TextDecoration | ||
| import androidx.compose.ui.text.withLink | ||
| import com.cornellappdev.score.R | ||
|
|
||
| @Composable | ||
| fun ExternalLink( | ||
| url: String, | ||
| urlLabel: String, | ||
| linkColor: Color, | ||
| ) { | ||
| Row( | ||
| verticalAlignment = Alignment.CenterVertically | ||
| ) { | ||
| BasicText( | ||
| text = buildAnnotatedString { | ||
| withLink( | ||
| LinkAnnotation.Url( | ||
| url, | ||
| TextLinkStyles( | ||
| style = SpanStyle( | ||
| textDecoration = TextDecoration.Underline, | ||
| color = linkColor, | ||
| fontWeight = FontWeight.Bold | ||
| ) | ||
| ), | ||
| ) | ||
| ) { | ||
| append(urlLabel) | ||
| } | ||
| } | ||
| ) | ||
| Icon( | ||
| painter = painterResource(R.drawable.arrow_outward), | ||
| contentDescription = "external link arrow", | ||
| tint = linkColor | ||
| ) | ||
| } | ||
| } |
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.