Many TV apps include content detail pages with relevant metadata for a given piece of content (i.e. a specific movie). Detail pages can be implemented as a composable function, taking metadata of the selected content as its argument.
The following code is a typical implementation of the details screen. It loads an image of the given movie with its title and description. The user's able to make a screen transition to the player screen, which can be triggered by clicking a button to start movie playback. You can handle this action to make the screen transition by setting a callback function.
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.unit.dp
import androidx.tv.material3.Button
import androidx.tv.material3.MaterialTheme
import androidx.tv.material3.Text
import coil.compose.AsyncImage
@Composable
fun DetailsScreen(
movie: Movie,
modifier: Modifier = Modifier,
onStartPlayback: (Movie) -> Unit = {}
) {
Box(modifier = modifier.fillMaxSize()){
AsyncImage(
modifier = Modifier.fillMaxSize()
model = movie.image,
contentDescription = null,
contentScale = ContentScale.Crop,
)
Column(modifier = Modifier.padding(32.dp)){
Text(
text = movie.title,
style = MaterialTheme.typeography.heading2
)
Text(text = movie.description)
Button(onClick = { onStartPlayBack(movie) }){
Text(text = R.string.startPlayback)
}
}
}
}