-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
254 additions
and
0 deletions.
There are no files selected for viewing
212 changes: 212 additions & 0 deletions
212
androidHyperskillApp/src/main/java/org/hyperskill/app/android/challenge/ui/ChallengeCard.kt
This file contains 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,212 @@ | ||
package org.hyperskill.app.android.challenge.ui | ||
|
||
import androidx.annotation.DrawableRes | ||
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.ColumnScope | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.res.colorResource | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import org.hyperskill.app.R | ||
import org.hyperskill.app.android.core.view.ui.widget.compose.HyperskillCard | ||
import org.hyperskill.app.android.core.view.ui.widget.compose.HyperskillTheme | ||
|
||
private object ChallengeCardDefault { | ||
val paddingValues: PaddingValues = PaddingValues(20.dp) | ||
} | ||
|
||
object ChallengeCardPreviewDefault { | ||
const val TITLE = "Advent Streak Challenge" | ||
const val DATE_TEXT = "6 Oct - 12 Oct" | ||
const val DESCRIPTION = "Get ready to push your limits! Thrilling daily programming competition designed to test your coding skills and problem-solving abilities. What to Expect" | ||
const val TIME_TITLE = "Start in" | ||
const val TIME_SUBTITLE = "6 hrs 27 mins" | ||
} | ||
|
||
@Composable | ||
fun AnnouncementChallengeCard( | ||
title: String, | ||
dateText: String, | ||
description: String, | ||
timeTitle: String, | ||
timeSubtitle: String | ||
) { | ||
ChallengeScaffold { | ||
ChallengeHeader( | ||
title = title, | ||
dateText = dateText, | ||
imageRes = org.hyperskill.app.android.R.drawable.img_challenge_announcment, | ||
modifier = Modifier.fillMaxWidth() | ||
) | ||
ChallengeDescription(description) | ||
ChallengeTimeText(title = timeTitle, subtitle = timeSubtitle) | ||
} | ||
} | ||
|
||
@Composable | ||
private fun ChallengeScaffold( | ||
modifier: Modifier = Modifier, | ||
content: @Composable ColumnScope.() -> Unit | ||
) { | ||
HyperskillCard( | ||
contentPadding = ChallengeCardDefault.paddingValues, | ||
onClick = {}, | ||
modifier = modifier | ||
) { | ||
Column( | ||
content = content, | ||
verticalArrangement = Arrangement.spacedBy(16.dp) | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
private fun ChallengeHeader( | ||
title: String, | ||
dateText: String, | ||
@DrawableRes imageRes: Int, | ||
modifier: Modifier = Modifier | ||
) { | ||
Row( | ||
modifier = modifier, | ||
horizontalArrangement = Arrangement.spacedBy(8.dp) | ||
) { | ||
Column( | ||
verticalArrangement = Arrangement.spacedBy(8.dp), | ||
modifier = Modifier.weight(1f) | ||
) { | ||
Text( | ||
text = title, | ||
style = MaterialTheme.typography.subtitle2 | ||
) | ||
DateLabel(dateText) | ||
} | ||
Image( | ||
painter = painterResource(id = imageRes), | ||
contentDescription = null | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
private fun DateLabel( | ||
text: String, | ||
modifier: Modifier = Modifier | ||
) { | ||
Text( | ||
text = text, | ||
modifier = modifier | ||
.clip(RoundedCornerShape(4.dp)) | ||
.background(colorResource(R.color.color_overlay_blue_alpha_12)) | ||
.padding(horizontal = 8.dp, vertical = 4.dp), | ||
style = MaterialTheme.typography.caption, | ||
color = colorResource(R.color.color_primary) | ||
) | ||
} | ||
|
||
@Composable | ||
private fun ChallengeDescription( | ||
description: String, | ||
modifier: Modifier = Modifier | ||
) { | ||
Text( | ||
text = description, | ||
modifier = modifier, | ||
style = MaterialTheme.typography.body1, | ||
color = colorResource(id = R.color.color_on_surface_alpha_60) | ||
) | ||
} | ||
|
||
@Composable | ||
private fun ChallengeTimeText( | ||
title: String, | ||
subtitle: String, | ||
modifier: Modifier = Modifier | ||
) { | ||
Row( | ||
horizontalArrangement = Arrangement.spacedBy(4.dp), | ||
modifier = modifier | ||
) { | ||
Text( | ||
text = title, | ||
style = MaterialTheme.typography.body1, | ||
fontSize = 14.sp, | ||
color = colorResource(id = R.color.color_on_surface_alpha_38) | ||
) | ||
Text( | ||
text = subtitle, | ||
style = MaterialTheme.typography.subtitle2, | ||
fontSize = 14.sp, | ||
color = colorResource(id = R.color.color_on_surface_alpha_38) | ||
) | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun DateLabelPreview() { | ||
HyperskillTheme { | ||
DateLabel("6 Oct - 12 Oct") | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun ChallengeHeaderPreview() { | ||
HyperskillTheme { | ||
ChallengeHeader( | ||
title = ChallengeCardPreviewDefault.TITLE, | ||
dateText = ChallengeCardPreviewDefault.DATE_TEXT, | ||
imageRes = org.hyperskill.app.android.R.drawable.img_challenge_announcment | ||
) | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun ChallengeDescriptionPreview() { | ||
HyperskillTheme { | ||
ChallengeDescription( | ||
description = ChallengeCardPreviewDefault.DESCRIPTION | ||
) | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun ChallengeTimeTextPreview() { | ||
HyperskillTheme { | ||
ChallengeTimeText( | ||
title = ChallengeCardPreviewDefault.TIME_TITLE, | ||
subtitle = ChallengeCardPreviewDefault.TIME_SUBTITLE | ||
) | ||
} | ||
} | ||
|
||
@Preview() | ||
@Composable | ||
private fun AnnouncementChallengeCardPreview() { | ||
HyperskillTheme { | ||
AnnouncementChallengeCard( | ||
title = ChallengeCardPreviewDefault.TITLE, | ||
dateText = ChallengeCardPreviewDefault.DATE_TEXT, | ||
description = ChallengeCardPreviewDefault.DESCRIPTION, | ||
timeTitle = ChallengeCardPreviewDefault.TIME_TITLE, | ||
timeSubtitle = ChallengeCardPreviewDefault.TIME_SUBTITLE | ||
) | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...pp/src/main/java/org/hyperskill/app/android/core/view/ui/widget/compose/HyperskillCard.kt
This file contains 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,42 @@ | ||
package org.hyperskill.app.android.core.view.ui.widget.compose | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.interaction.MutableInteractionSource | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.BoxScope | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.material.ripple.rememberRipple | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.res.dimensionResource | ||
import androidx.compose.ui.unit.Dp | ||
import org.hyperskill.app.android.R | ||
|
||
@Composable | ||
fun HyperskillCard( | ||
contentPadding: PaddingValues, | ||
modifier: Modifier = Modifier, | ||
cornerRadius: Dp = dimensionResource(id = R.dimen.corner_radius), | ||
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, | ||
onClick: () -> Unit, | ||
content: @Composable BoxScope.() -> Unit | ||
) { | ||
Box( | ||
modifier = modifier | ||
.clip(RoundedCornerShape(cornerRadius)) | ||
.background(MaterialTheme.colors.surface) | ||
.clickable( | ||
interactionSource = interactionSource, | ||
indication = rememberRipple(), | ||
onClick = onClick | ||
) | ||
.padding(contentPadding), | ||
content = content | ||
) | ||
} |
Binary file added
BIN
+3 KB
androidHyperskillApp/src/main/res/drawable-hdpi/img_challenge_announcment.webp
Binary file not shown.
Binary file added
BIN
+3.1 KB
androidHyperskillApp/src/main/res/drawable-hdpi/img_challenge_finished.webp
Binary file not shown.
Binary file added
BIN
+2.29 KB
androidHyperskillApp/src/main/res/drawable-hdpi/img_challenge_not_completed.webp
Binary file not shown.
Binary file added
BIN
+2.82 KB
androidHyperskillApp/src/main/res/drawable-hdpi/img_challenge_partly_finished.webp
Binary file not shown.
Binary file added
BIN
+2.47 KB
androidHyperskillApp/src/main/res/drawable-hdpi/img_challenge_progress.webp
Binary file not shown.
Binary file added
BIN
+2.11 KB
androidHyperskillApp/src/main/res/drawable-mdpi/img_challenge_announcment.webp
Binary file not shown.
Binary file added
BIN
+2.09 KB
androidHyperskillApp/src/main/res/drawable-mdpi/img_challenge_finished.webp
Binary file not shown.
Binary file added
BIN
+1.67 KB
androidHyperskillApp/src/main/res/drawable-mdpi/img_challenge_not_completed.webp
Binary file not shown.
Binary file added
BIN
+1.96 KB
androidHyperskillApp/src/main/res/drawable-mdpi/img_challenge_partly_finished.webp
Binary file not shown.
Binary file added
BIN
+1.72 KB
androidHyperskillApp/src/main/res/drawable-mdpi/img_challenge_progress.webp
Binary file not shown.
Binary file added
BIN
+3.78 KB
androidHyperskillApp/src/main/res/drawable-xhdpi/img_challenge_announcment.webp
Binary file not shown.
Binary file added
BIN
+4.17 KB
androidHyperskillApp/src/main/res/drawable-xhdpi/img_challenge_finished.webp
Binary file not shown.
Binary file added
BIN
+2.89 KB
androidHyperskillApp/src/main/res/drawable-xhdpi/img_challenge_not_completed.webp
Binary file not shown.
Binary file added
BIN
+3.71 KB
androidHyperskillApp/src/main/res/drawable-xhdpi/img_challenge_partly_finished.webp
Binary file not shown.
Binary file added
BIN
+2.94 KB
androidHyperskillApp/src/main/res/drawable-xhdpi/img_challenge_progress.webp
Binary file not shown.
Binary file added
BIN
+5.7 KB
androidHyperskillApp/src/main/res/drawable-xxhdpi/img_challenge_announcment.webp
Binary file not shown.
Binary file added
BIN
+6.76 KB
androidHyperskillApp/src/main/res/drawable-xxhdpi/img_challenge_finished.webp
Binary file not shown.
Binary file added
BIN
+4.32 KB
androidHyperskillApp/src/main/res/drawable-xxhdpi/img_challenge_not_completed.webp
Binary file not shown.
Binary file added
BIN
+5.79 KB
androidHyperskillApp/src/main/res/drawable-xxhdpi/img_challenge_partly_finished.webp
Binary file not shown.
Binary file added
BIN
+4.67 KB
androidHyperskillApp/src/main/res/drawable-xxhdpi/img_challenge_progress.webp
Binary file not shown.
Binary file added
BIN
+7.61 KB
androidHyperskillApp/src/main/res/drawable-xxxhdpi/img_challenge_announcment.webp
Binary file not shown.
Binary file added
BIN
+9.78 KB
androidHyperskillApp/src/main/res/drawable-xxxhdpi/img_challenge_finished.webp
Binary file not shown.
Binary file added
BIN
+5.59 KB
androidHyperskillApp/src/main/res/drawable-xxxhdpi/img_challenge_not_completed.webp
Binary file not shown.
Binary file added
BIN
+8.63 KB
androidHyperskillApp/src/main/res/drawable-xxxhdpi/img_challenge_partly_finished.webp
Binary file not shown.
Binary file added
BIN
+6.31 KB
androidHyperskillApp/src/main/res/drawable-xxxhdpi/img_challenge_progress.webp
Binary file not shown.