-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
7 changed files
with
280 additions
and
112 deletions.
There are no files selected for viewing
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
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
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
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
101 changes: 101 additions & 0 deletions
101
...kotlin/dev/datlag/burningseries/shared/ui/screen/initial/favorite/component/SeriesCard.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,101 @@ | ||
package dev.datlag.burningseries.shared.ui.screen.initial.favorite.component | ||
|
||
import androidx.compose.animation.animateColorAsState | ||
import androidx.compose.foundation.layout.* | ||
import androidx.compose.material3.Card | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.rememberCoroutineScope | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.layout.ContentScale | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.text.style.TextOverflow | ||
import androidx.compose.ui.unit.dp | ||
import dev.datlag.burningseries.database.Series | ||
import dev.datlag.burningseries.database.common.allTitles | ||
import dev.datlag.burningseries.database.common.bestTitle | ||
import dev.datlag.burningseries.database.common.mainTitle | ||
import dev.datlag.burningseries.database.common.subTitle | ||
import dev.datlag.burningseries.model.BSUtil | ||
import dev.datlag.burningseries.shared.common.bottomShadowBrush | ||
import dev.datlag.burningseries.shared.ui.custom.Cover | ||
import dev.datlag.burningseries.shared.ui.theme.SchemeTheme | ||
import dev.datlag.burningseries.shared.ui.theme.rememberSchemeThemeDominantColorState | ||
|
||
@Composable | ||
fun SeriesCard( | ||
series: Series, | ||
modifier: Modifier = Modifier, | ||
onClick: (Series) -> Unit | ||
) { | ||
SchemeTheme( | ||
key = series.hrefPrimary | ||
) { | ||
Card( | ||
modifier = modifier, | ||
onClick = { | ||
onClick(series) | ||
} | ||
) { | ||
Box( | ||
modifier = Modifier.fillMaxSize() | ||
) { | ||
val scope = rememberCoroutineScope() | ||
val colorState = rememberSchemeThemeDominantColorState( | ||
key = series.hrefPrimary, | ||
applyMinContrast = true, | ||
minContrastBackgroundColor = MaterialTheme.colorScheme.surfaceVariant | ||
) | ||
val animatedColor by animateColorAsState( | ||
targetValue = colorState.color | ||
) | ||
|
||
Cover( | ||
key = series.coverHref, | ||
data = series.coverHref?.let { BSUtil.getBurningSeriesLink(it) }, | ||
contentDescription = series.bestTitle, | ||
modifier = Modifier.fillMaxSize(), | ||
contentScale = ContentScale.Crop, | ||
onSuccess = { state -> | ||
SchemeTheme.update( | ||
key = series.hrefPrimary, | ||
input = state.painter, | ||
scope = scope | ||
) | ||
} | ||
) | ||
|
||
Column( | ||
modifier = Modifier | ||
.align(Alignment.BottomStart) | ||
.fillMaxWidth() | ||
.bottomShadowBrush(animatedColor) | ||
.padding(16.dp) | ||
.padding(top = 16.dp), | ||
verticalArrangement = Arrangement.spacedBy(8.dp, Alignment.CenterVertically) | ||
) { | ||
Text( | ||
text = series.mainTitle, | ||
style = MaterialTheme.typography.titleLarge, | ||
maxLines = 2, | ||
fontWeight = FontWeight.Bold, | ||
overflow = TextOverflow.Ellipsis, | ||
modifier = Modifier.fillMaxWidth(), | ||
color = colorState.onColor | ||
) | ||
series.subTitle?.let { | ||
Text( | ||
text = it, | ||
modifier = Modifier.fillMaxWidth(), | ||
color = colorState.onColor, | ||
maxLines = 2 | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.