Skip to content
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

display something better #1527

Open
github-actions bot opened this issue Sep 10, 2023 · 0 comments
Open

display something better #1527

github-actions bot opened this issue Sep 10, 2023 · 0 comments
Labels

Comments

@github-actions
Copy link
Contributor

https://api.github.com/chrisbanes/tivi/blob/2077e586b8052169f9b05c1ded35587d51e923a1/common/ui/compose/src/commonMain/kotlin/app/tivi/common/compose/ui/BackdropCard.kt#L85


// Copyright 2021, Google LLC, Christopher Banes and the Tivi project contributors
// SPDX-License-Identifier: Apache-2.0

package app.tivi.common.compose.ui

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Card
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.unit.dp
import app.tivi.common.compose.LocalStrings
import app.tivi.common.compose.theme.TiviTheme
import app.tivi.data.imagemodels.asImageModel
import app.tivi.data.models.ImageType
import app.tivi.data.models.TiviShow

@Composable
fun BackdropCard(
    show: TiviShow,
    modifier: Modifier = Modifier,
) {
    Card(
        shape = MaterialTheme.shapes.extraLarge,
        modifier = modifier,
    ) {
        TiviTheme(useDarkColors = true) {
            BackdropCardContent(show = show)
        }
    }
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun BackdropCard(
    show: TiviShow,
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
) {
    Card(
        onClick = onClick,
        shape = MaterialTheme.shapes.extraLarge,
        modifier = modifier,
    ) {
        TiviTheme(useDarkColors = true) {
            BackdropCardContent(show = show)
        }
    }
}

@Composable
private fun BackdropCardContent(show: TiviShow) {
    Box(modifier = Modifier.fillMaxSize()) {
        AsyncImage(
            model = show.asImageModel(ImageType.BACKDROP),
            contentDescription = LocalStrings.current.cdShowPosterImage(show.title ?: "show"),
            modifier = Modifier
                .fillMaxSize()
                .drawForegroundGradientScrim(MaterialTheme.colorScheme.surface),
            contentScale = ContentScale.Crop,
        )
        Text(
            text = show.title ?: "No title",
            style = MaterialTheme.typography.labelLarge,
            color = MaterialTheme.colorScheme.onSurface,
            modifier = Modifier
                .padding(16.dp)
                .align(Alignment.BottomStart),
        )
    }
}

@Composable
fun PlaceholderBackdropCard(
    modifier: Modifier = Modifier,
) {
    Card(modifier = modifier) {
        Box {
            // TODO: display something better
        }
    }
}

@github-actions github-actions bot added the todo label Sep 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

0 participants