Skip to content

Commit

Permalink
✨ added added stack shade to Deck composable
Browse files Browse the repository at this point in the history
  • Loading branch information
schachi5000 committed Nov 3, 2023
1 parent 8caaafe commit 102bd32
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import kotlin.coroutines.coroutineContext
// TODO convert to class and hide behind interface
object KtorCardDataSource {

private const val BASE_URL = "https://de.marvelcdb.com"
private const val BASE_URL = "https://de.marvelcdb.com/api/public"

private val httpClient = HttpClient {
install(ContentNegotiation) {
Expand All @@ -39,11 +39,11 @@ object KtorCardDataSource {
}

suspend fun getAllCardPacks() = httpClient
.get("$BASE_URL/api/public/packs")
.get("$BASE_URL/packs")
.body<List<Pack>>()

suspend fun getCardPack(packCode: String) = httpClient
.get("$BASE_URL/api/public/cards/$packCode")
.get("$BASE_URL/cards/$packCode")
.body<List<Card>>()

suspend fun getAllCards() = getAllCardPacks()
Expand All @@ -59,11 +59,11 @@ object KtorCardDataSource {
.flatten()

suspend fun getCard(cardCode: String) = httpClient
.get("$BASE_URL/api/public/card/$cardCode")
.get("$BASE_URL/card/$cardCode")
.body<Card>()

suspend fun getFeaturedDecksByDate(date: String, cardProvider: (String) -> Card?) = httpClient
.get("$BASE_URL/api/public/decklists/by_date/$date")
.get("$BASE_URL/decklists/by_date/$date")
.body<List<DeckDto>>()
.map {
Deck(
Expand All @@ -77,7 +77,7 @@ object KtorCardDataSource {
}

suspend fun getPublicDeckById(deckId: Int, cardProvider: (String) -> Card?) = httpClient
.get("$BASE_URL/api/public/deck/$deckId")
.get("$BASE_URL/deck/$deckId")
.body<DeckDto>()
.let {
Deck(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package net.schacher.mcc.shared.design.compose
import androidx.compose.foundation.background
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
Expand All @@ -12,23 +13,58 @@ 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.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import net.schacher.mcc.shared.model.Deck

@Composable
fun Deck(deck: Deck) {
Row(
modifier = Modifier.wrapContentHeight()
.fillMaxWidth()
.height(128.dp)
.clip(RoundedCornerShape(8.dp))
.background(MaterialTheme.colors.surface)
) {
Card(card = deck.heroCard)
Column {
DeckStack(modifier = Modifier.fillMaxWidth())
Spacer(Modifier.height(1.dp))
Row(
modifier = Modifier.wrapContentHeight()
.fillMaxWidth()
.height(128.dp)
.clip(RoundedCornerShape(8.dp))
.background(MaterialTheme.colors.surface)
) {
Card(card = deck.heroCard)

Column(modifier = Modifier.padding(8.dp)) {
Text(text = deck.name)
Column(modifier = Modifier.padding(8.dp)) {
Text(
text = deck.name,
maxLines = 1,
fontWeight = FontWeight.SemiBold
)
}
}
}
}
}

@Composable
private fun DeckStack(modifier: Modifier = Modifier) {
Column(modifier) {
Row(
Modifier.height(5.dp)
.padding(horizontal = 16.dp)
.alpha(0.3f)
.background(MaterialTheme.colors.onSurface, StackShape())
.fillMaxWidth()
) { }
Spacer(Modifier.height(1.dp))
Row(
Modifier.height(5.dp)
.padding(horizontal = 8.dp)
.alpha(0.2f)
.background(MaterialTheme.colors.onSurface, StackShape())
.fillMaxWidth()
) { }
}
}

private fun StackShape() = RoundedCornerShape(
topStart = 8.dp, topEnd = 8.dp
)

0 comments on commit 102bd32

Please sign in to comment.