許多電視應用程式都含有內容詳細資料頁面,其中包含特定項目的相關中繼資料 內容片段 (例如特定電影)。詳細資料頁面可實作為 可組合函式,採用所選內容的中繼資料做為引數。
以下程式碼是詳細資料畫面的一般實作方式。這項服務 載入映像檔時 並附上電影名稱和說明使用者可以讓 就會轉換成播放器畫面,只要按一下 按鈕開始播放電影。您可以處理這個動作 轉換。
@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)
}
}
}
}