Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.cornellappdev.score.components

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
Expand All @@ -12,7 +10,6 @@ import androidx.compose.material3.Text
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.graphics.ColorFilter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
Expand All @@ -23,11 +20,14 @@ import com.cornellappdev.score.theme.GrayMedium
import com.cornellappdev.score.theme.GrayPrimary
import com.cornellappdev.score.theme.Style.bodyNormal
import com.cornellappdev.score.theme.Style.heading2
import com.cornellappdev.score.theme.White

@Composable
fun EmptyStateMessage(modifier: Modifier = Modifier) {
Column(modifier = modifier.width(158.dp),
horizontalAlignment = Alignment.CenterHorizontally) {
Column(
modifier = modifier.width(158.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
Image(
painter = painterResource(id = R.drawable.ic_speaker),
contentDescription = "Speaker Icon",
Expand All @@ -52,8 +52,6 @@ fun EmptyStateMessage(modifier: Modifier = Modifier) {

@Preview
@Composable
private fun PreviewEmptyStateMessage() {
Box(modifier = Modifier.background(Color.White)) {
EmptyStateMessage()
}
private fun PreviewEmptyStateMessage() = ScorePreview {
EmptyStateMessage()
}
80 changes: 80 additions & 0 deletions app/src/main/java/com/cornellappdev/score/components/ErrorState.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.cornellappdev.score.components

import androidx.compose.foundation.Image
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.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.cornellappdev.score.R
import com.cornellappdev.score.theme.CrimsonPrimary
import com.cornellappdev.score.theme.GrayMedium
import com.cornellappdev.score.theme.GrayPrimary
import com.cornellappdev.score.theme.Style.bodyNormal
import com.cornellappdev.score.theme.Style.heading2

@Composable
fun ErrorState(
onRefresh: () -> Unit,
message: String,
modifier: Modifier = Modifier
) {
Column(
modifier = modifier
.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(100.dp)
) {
Spacer(modifier = Modifier.height(200.dp))
Column(
horizontalAlignment = Alignment.CenterHorizontally
Copy link
Collaborator

Choose a reason for hiding this comment

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

Redundant parameter here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i made a column for the feedback icon + text and nested that + the button within the main column, so i think both of these are necessary

) {
Image(
painter = painterResource(R.drawable.ic_feedback),
contentDescription = "feedback bubble"
)
Spacer(modifier = Modifier.height(16.dp))
Text(
text = message,
style = heading2.copy(color = GrayPrimary)
)
Spacer(modifier = Modifier.height(8.dp))
Text(
text = "Please try again later.",
style = bodyNormal.copy(color = GrayMedium)
)
}

Button(
colors = ButtonDefaults.buttonColors(containerColor = CrimsonPrimary),
onClick = onRefresh
) {
Row(
verticalAlignment = Alignment.CenterVertically
) {
Image(
painter = painterResource(R.drawable.ic_cached),
contentDescription = "refresh icon"
)
Text("Try again")
}
}
Spacer(modifier = Modifier.height(70.dp))
}
}

@Preview
@Composable
private fun ErrorStatePreview() = ScorePreview {
ErrorState({}, "Oops! Failed to load.")
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ fun FeaturedGameHeader(

@Preview
@Composable
private fun FeaturedGameCardPreview() {
private fun FeaturedGameCardPreview() = ScorePreview {
FeaturedGameHeader(
leftTeamLogo = painterResource(R.drawable.cornell_logo),
rightTeamLogo = "https://cornellbigred.com/images/logos/YALE_LOGO_2020.png?width=80&height=80&mode=max",
Expand Down Expand Up @@ -177,9 +177,9 @@ fun FeaturedGameCard(
}
}

@Preview(showBackground = true)
@Preview
@Composable
private fun GameScheduleScreen() {
private fun GameScheduleScreen() = ScorePreview {
FeaturedGameCard(
leftTeamLogo = painterResource(R.drawable.cornell_logo),
rightTeamLogo = "https://cornellbigred.com/images/logos/penn_200x200.png?width=80&height=80&mode=max",//painterResource(R.drawable.penn_logo),
Expand Down
18 changes: 7 additions & 11 deletions app/src/main/java/com/cornellappdev/score/components/GameCard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand All @@ -18,6 +17,7 @@ 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.layout.widthIn
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Card
Expand All @@ -36,21 +36,15 @@ 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.GameCardData
import com.cornellappdev.score.theme.AmbientColor
import com.cornellappdev.score.theme.GrayMedium
import com.cornellappdev.score.theme.GrayPrimary
import com.cornellappdev.score.theme.GrayStroke
import com.cornellappdev.score.theme.SpotColor
import com.cornellappdev.score.theme.Style.bodyNormal
import com.cornellappdev.score.theme.Style.dateText
import com.cornellappdev.score.theme.Style.heading2
import com.cornellappdev.score.theme.Style.labelsNormal
import com.cornellappdev.score.theme.Style.teamName
import com.cornellappdev.score.theme.Style.universityText
import com.cornellappdev.score.theme.saturatedGreen
import java.util.Date
import java.util.Locale

@Composable
fun GameCard(
Expand Down Expand Up @@ -94,7 +88,8 @@ fun GameCard(
)
)
}
).clickable { onClick(false) }
)
.clickable { onClick(false) }
) {
Column(
modifier = Modifier
Expand All @@ -107,7 +102,8 @@ fun GameCard(
modifier = Modifier.fillMaxWidth()
) {
Row(
verticalAlignment = Alignment.CenterVertically, modifier = Modifier.widthIn(0.dp, 250.dp)
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.widthIn(0.dp, 250.dp)
) {
AsyncImage(
model = teamLogo,
Expand Down Expand Up @@ -209,9 +205,9 @@ fun GameCard(
}
}

@Preview(showBackground = true)
@Preview
@Composable
private fun GameCardPreview() {
private fun GameCardPreview() = ScorePreview {
Column {
GameCard(
teamLogo = "https://cornellbigred.com/images/logos/penn_200x200.png?width=80&height=80&mode=max", //painterResource(id = R.drawable.penn_logo),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package com.cornellappdev.score.components

import androidx.compose.foundation.Canvas
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
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.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.material3.MaterialTheme.typography
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.cornellappdev.score.R
import com.cornellappdev.score.theme.GrayStroke
import com.cornellappdev.score.theme.LocalInfiniteLoading
import com.cornellappdev.score.theme.Stroke
import com.cornellappdev.score.theme.Wash
import com.cornellappdev.score.util.interpolateColorHSV

@Composable
fun GameDetailsLoadingScreen(
modifier: Modifier = Modifier
) {
val shimmerColor = interpolateColorHSV(Wash, Stroke, LocalInfiniteLoading.current)
Column(
modifier = modifier.fillMaxWidth()
) {
Row(
modifier = Modifier
.background(color = shimmerColor)
.fillMaxWidth()
.height(185.dp),
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically
) {
Canvas(
modifier = Modifier
.size(72.dp)
) {
drawCircle(color = shimmerColor)
}
Spacer(modifier = Modifier.width(24.dp))
LoadingStateBox(100, 33.dp, Modifier.width(100.dp))
Spacer(modifier = Modifier.width(24.dp))
Canvas(
modifier = Modifier
.size(72.dp)
) {
drawCircle(color = shimmerColor)
}
}
Column(
modifier = Modifier.padding(24.dp)
) {
LoadingStateBox(12, 16.dp, Modifier.width(100.dp))
Spacer(modifier = Modifier.height(12.dp))
LoadingStateBox(100, 32.dp, Modifier.width(200.dp))
Spacer(modifier = Modifier.height(16.dp))
LoadingStateBox(12, 16.dp)

Spacer(modifier = Modifier.height(24.dp))
LoadingStateBox(8, 125.dp)
Spacer(modifier = Modifier.height(24.dp))

Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = "Loading Score Summary",
color = GrayStroke,
style = typography.titleMedium,
modifier = Modifier.weight(1f)
)

Image(
painter = painterResource(R.drawable.ic_right_chevron),
contentDescription = "right chevron"
)
}

Spacer(modifier = Modifier.height(16.dp))
LoadingStateBox(8, 48.dp)
Spacer(modifier = Modifier.height(16.dp))
LoadingStateBox(8, 48.dp)
Spacer(modifier = Modifier.height(16.dp))
LoadingStateBox(8, 48.dp)
}
}
}

@Preview
@Composable
private fun GameDetailsLoadingStatePreview() = ScorePreview {
GameDetailsLoadingScreen()
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ fun GameScoreHeader(

@Preview
@Composable
private fun GameScoreHeaderPreview() {
private fun GameScoreHeaderPreview() = ScorePreview {
GameScoreHeader(
leftTeamLogo = painterResource(R.drawable.cornell_logo),
rightTeamLogo = painterResource(R.drawable.penn_logo),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.cornellappdev.score.theme.CrimsonPrimary
import com.cornellappdev.score.theme.GrayLight
import com.cornellappdev.score.theme.GrayPrimary
import com.cornellappdev.score.theme.Style.heading1
import com.cornellappdev.score.theme.White
import com.cornellappdev.score.util.gameList

@Composable
Expand Down Expand Up @@ -106,8 +107,8 @@ fun GamesCarousel(
}
}

@Preview(showBackground = true, widthDp = 360)
@Composable
private fun GamesCarouselPreview() {
@Preview
private fun GamesCarouselPreview() = ScorePreview {
GamesCarousel(gameList, GamesCarouselVariant.UPCOMING)
}
Loading