link trailers out to youtube + some poster tweaks

This commit is contained in:
Owen LeJeune
2022-11-07 16:39:10 -05:00
parent fe0b0538bd
commit 1d9888aeff
6 changed files with 42 additions and 49 deletions

View File

@@ -144,13 +144,13 @@ fun TwoLineImageTextCard(
Column(modifier = modifier) {
PosterItem(
width = 120.dp,
height = 180.dp,
onClick = onItemClicked,
url = imageUrl,
noDataImage = noDataImage,
placeholder = placeholder,
title = title,
elevation = 0.dp
elevation = 0.dp,
overrideShowTitle = false
)
MinLinesText(
modifier = Modifier

View File

@@ -1,5 +1,7 @@
package com.owenlejeune.tvtime.ui.components
import android.util.Log
import android.widget.Toast
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
@@ -19,6 +21,7 @@ import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntSize
@@ -39,7 +42,7 @@ import com.owenlejeune.tvtime.utils.TmdbUtils
import org.koin.java.KoinJavaComponent.get
private val POSTER_WIDTH = 120.dp
private val POSTER_HEIGHT = 190.dp
private val POSTER_HEIGHT = 180.dp
@Composable
fun PosterGrid(
@@ -167,7 +170,6 @@ fun PeoplePosterGrid(
fun PosterItem(
modifier: Modifier = Modifier,
width: Dp = POSTER_WIDTH,
height: Dp = POSTER_HEIGHT,
onClick: (id: Int) -> Unit = {},
elevation: Dp = 8.dp,
mediaItem: TmdbItem?
@@ -175,7 +177,6 @@ fun PosterItem(
PosterItem(
modifier = modifier,
width = width,
height = height,
onClick = {
mediaItem?.let {
onClick(mediaItem.id)
@@ -191,15 +192,12 @@ fun PosterItem(
fun PosterItem(
modifier: Modifier = Modifier,
width: Dp = POSTER_WIDTH,
height: Dp = POSTER_HEIGHT,
onClick: (id: Int) -> Unit = {},
elevation: Dp = 8.dp,
person: Person?
) {
PosterItem(
modifier = modifier,
width = width,
height = height,
onClick = {
person?.let {
onClick(person.id)
@@ -216,12 +214,12 @@ fun PosterItem(
url: String?,
modifier: Modifier = Modifier,
width: Dp = POSTER_WIDTH,
height: Dp = POSTER_HEIGHT,
onClick: () -> Unit = {},
noDataImage: Int = R.drawable.placeholder,
placeholder: Int = R.drawable.placeholder,
elevation: Dp = 8.dp,
title: String?,
overrideShowTitle: Boolean? = null,
preferences: AppPreferences = get(AppPreferences::class.java)
) {
Card(
@@ -249,6 +247,8 @@ fun PosterItem(
onClick = onClick
)
.onGloballyPositioned { sizeImage = it.size },
onError = { Log.d("Poster", "Error loading: $url") },
error = rememberAsyncImagePainter(model = noDataImage),
model = url,
placeholder = rememberAsyncImagePainter(model = placeholder),
contentDescription = title,
@@ -258,7 +258,7 @@ fun PosterItem(
Image(
modifier = Modifier
.width(width = width)
.wrapContentHeight()
.height(height = POSTER_HEIGHT)
.clip(RoundedCornerShape(5.dp))
.clickable(
onClick = onClick
@@ -270,7 +270,8 @@ fun PosterItem(
)
}
if (preferences.showPosterTitles) {
val showTitle = overrideShowTitle ?: preferences.showPosterTitles
if (showTitle) {
title?.let {
Box(
modifier = Modifier

View File

@@ -1,5 +1,7 @@
package com.owenlejeune.tvtime.ui.components
import android.content.Intent
import android.net.Uri
import android.widget.TextView
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.*
@@ -564,46 +566,34 @@ fun RoundedTextField(
@Composable
fun FullScreenThumbnailVideoPlayer(
key: String,
title: String,
modifier: Modifier = Modifier
) {
val context = LocalContext.current
val showFullscreenView = remember { mutableStateOf(false) }
AsyncImage(
modifier = modifier
.clickable(
onClick = { showFullscreenView.value = true }
),
model = "https://img.youtube.com/vi/${key}/hqdefault.jpg",
contentDescription = "",
placeholder = rememberAsyncImagePainter(model = R.drawable.placeholder)
)
if (showFullscreenView.value) {
Dialog(
onDismissRequest = { showFullscreenView.value = false },
properties = DialogProperties(usePlatformDefaultWidth = false)
) {
Surface(modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()) {
AndroidView(
modifier = Modifier
.wrapContentHeight()
.fillMaxWidth(),
factory = {
YouTubePlayerView(context).apply {
addYouTubePlayerListener(object : AbstractYouTubePlayerListener() {
override fun onReady(youTubePlayer: YouTubePlayer) {
youTubePlayer.loadVideo(key, 0f)
}
})
Column(
verticalArrangement = Arrangement.spacedBy(6.dp)
) {
AsyncImage(
modifier = modifier
.clickable(
onClick = {
val intent = Intent(Intent.ACTION_VIEW).apply {
data = Uri.parse("https://www.youtube.com/watch?v=$key")
}
context.startActivity(intent)
}
)
}
}
),
model = "https://img.youtube.com/vi/${key}/hqdefault.jpg",
contentDescription = "",
placeholder = rememberAsyncImagePainter(model = R.drawable.placeholder)
)
Text(
text = title,
color = MaterialTheme.colorScheme.onSurfaceVariant,
fontSize = 16.sp
)
}
}

View File

@@ -24,8 +24,8 @@ sealed class MediaTabNavItem(
override val name = resourceUtils.getString(stringRes)
companion object {
val MovieItems = listOf(Popular, NowPlaying, Upcoming, TopRated)
val TvItems = listOf(Popular, AiringToday, OnTheAir, TopRated)
val MovieItems = listOf(NowPlaying, Popular, Upcoming, TopRated)
val TvItems = listOf(OnTheAir, Popular, AiringToday, TopRated)
private val Items = listOf(NowPlaying, Popular, TopRated, Upcoming, AiringToday, OnTheAir)

View File

@@ -72,7 +72,8 @@ fun DetailHeader(
},
url = posterUrl,
title = posterContentDescription,
elevation = 20.dp
elevation = 20.dp,
overrideShowTitle = false
)
rating?.let {

View File

@@ -838,9 +838,10 @@ private fun VideoGroup(results: List<Video>, type: Video.Type, title: String) {
listItems(videos) { video ->
FullScreenThumbnailVideoPlayer(
key = video.key,
title = video.name,
modifier = Modifier
.width(posterWidth)
.height(90.dp)
.wrapContentHeight()
)
}
}