mirror of
https://github.com/owenlejeune/TVTime.git
synced 2025-11-20 10:40:53 -05:00
link trailers out to youtube + some poster tweaks
This commit is contained in:
@@ -144,13 +144,13 @@ fun TwoLineImageTextCard(
|
|||||||
Column(modifier = modifier) {
|
Column(modifier = modifier) {
|
||||||
PosterItem(
|
PosterItem(
|
||||||
width = 120.dp,
|
width = 120.dp,
|
||||||
height = 180.dp,
|
|
||||||
onClick = onItemClicked,
|
onClick = onItemClicked,
|
||||||
url = imageUrl,
|
url = imageUrl,
|
||||||
noDataImage = noDataImage,
|
noDataImage = noDataImage,
|
||||||
placeholder = placeholder,
|
placeholder = placeholder,
|
||||||
title = title,
|
title = title,
|
||||||
elevation = 0.dp
|
elevation = 0.dp,
|
||||||
|
overrideShowTitle = false
|
||||||
)
|
)
|
||||||
MinLinesText(
|
MinLinesText(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.owenlejeune.tvtime.ui.components
|
package com.owenlejeune.tvtime.ui.components
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.background
|
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.graphics.Color
|
||||||
import androidx.compose.ui.layout.ContentScale
|
import androidx.compose.ui.layout.ContentScale
|
||||||
import androidx.compose.ui.layout.onGloballyPositioned
|
import androidx.compose.ui.layout.onGloballyPositioned
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.IntSize
|
import androidx.compose.ui.unit.IntSize
|
||||||
@@ -39,7 +42,7 @@ import com.owenlejeune.tvtime.utils.TmdbUtils
|
|||||||
import org.koin.java.KoinJavaComponent.get
|
import org.koin.java.KoinJavaComponent.get
|
||||||
|
|
||||||
private val POSTER_WIDTH = 120.dp
|
private val POSTER_WIDTH = 120.dp
|
||||||
private val POSTER_HEIGHT = 190.dp
|
private val POSTER_HEIGHT = 180.dp
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun PosterGrid(
|
fun PosterGrid(
|
||||||
@@ -167,7 +170,6 @@ fun PeoplePosterGrid(
|
|||||||
fun PosterItem(
|
fun PosterItem(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
width: Dp = POSTER_WIDTH,
|
width: Dp = POSTER_WIDTH,
|
||||||
height: Dp = POSTER_HEIGHT,
|
|
||||||
onClick: (id: Int) -> Unit = {},
|
onClick: (id: Int) -> Unit = {},
|
||||||
elevation: Dp = 8.dp,
|
elevation: Dp = 8.dp,
|
||||||
mediaItem: TmdbItem?
|
mediaItem: TmdbItem?
|
||||||
@@ -175,7 +177,6 @@ fun PosterItem(
|
|||||||
PosterItem(
|
PosterItem(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
width = width,
|
width = width,
|
||||||
height = height,
|
|
||||||
onClick = {
|
onClick = {
|
||||||
mediaItem?.let {
|
mediaItem?.let {
|
||||||
onClick(mediaItem.id)
|
onClick(mediaItem.id)
|
||||||
@@ -191,15 +192,12 @@ fun PosterItem(
|
|||||||
fun PosterItem(
|
fun PosterItem(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
width: Dp = POSTER_WIDTH,
|
width: Dp = POSTER_WIDTH,
|
||||||
height: Dp = POSTER_HEIGHT,
|
|
||||||
onClick: (id: Int) -> Unit = {},
|
onClick: (id: Int) -> Unit = {},
|
||||||
elevation: Dp = 8.dp,
|
|
||||||
person: Person?
|
person: Person?
|
||||||
) {
|
) {
|
||||||
PosterItem(
|
PosterItem(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
width = width,
|
width = width,
|
||||||
height = height,
|
|
||||||
onClick = {
|
onClick = {
|
||||||
person?.let {
|
person?.let {
|
||||||
onClick(person.id)
|
onClick(person.id)
|
||||||
@@ -216,12 +214,12 @@ fun PosterItem(
|
|||||||
url: String?,
|
url: String?,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
width: Dp = POSTER_WIDTH,
|
width: Dp = POSTER_WIDTH,
|
||||||
height: Dp = POSTER_HEIGHT,
|
|
||||||
onClick: () -> Unit = {},
|
onClick: () -> Unit = {},
|
||||||
noDataImage: Int = R.drawable.placeholder,
|
noDataImage: Int = R.drawable.placeholder,
|
||||||
placeholder: Int = R.drawable.placeholder,
|
placeholder: Int = R.drawable.placeholder,
|
||||||
elevation: Dp = 8.dp,
|
elevation: Dp = 8.dp,
|
||||||
title: String?,
|
title: String?,
|
||||||
|
overrideShowTitle: Boolean? = null,
|
||||||
preferences: AppPreferences = get(AppPreferences::class.java)
|
preferences: AppPreferences = get(AppPreferences::class.java)
|
||||||
) {
|
) {
|
||||||
Card(
|
Card(
|
||||||
@@ -249,6 +247,8 @@ fun PosterItem(
|
|||||||
onClick = onClick
|
onClick = onClick
|
||||||
)
|
)
|
||||||
.onGloballyPositioned { sizeImage = it.size },
|
.onGloballyPositioned { sizeImage = it.size },
|
||||||
|
onError = { Log.d("Poster", "Error loading: $url") },
|
||||||
|
error = rememberAsyncImagePainter(model = noDataImage),
|
||||||
model = url,
|
model = url,
|
||||||
placeholder = rememberAsyncImagePainter(model = placeholder),
|
placeholder = rememberAsyncImagePainter(model = placeholder),
|
||||||
contentDescription = title,
|
contentDescription = title,
|
||||||
@@ -258,7 +258,7 @@ fun PosterItem(
|
|||||||
Image(
|
Image(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.width(width = width)
|
.width(width = width)
|
||||||
.wrapContentHeight()
|
.height(height = POSTER_HEIGHT)
|
||||||
.clip(RoundedCornerShape(5.dp))
|
.clip(RoundedCornerShape(5.dp))
|
||||||
.clickable(
|
.clickable(
|
||||||
onClick = onClick
|
onClick = onClick
|
||||||
@@ -270,7 +270,8 @@ fun PosterItem(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preferences.showPosterTitles) {
|
val showTitle = overrideShowTitle ?: preferences.showPosterTitles
|
||||||
|
if (showTitle) {
|
||||||
title?.let {
|
title?.let {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.owenlejeune.tvtime.ui.components
|
package com.owenlejeune.tvtime.ui.components
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.net.Uri
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.compose.animation.core.animateFloatAsState
|
import androidx.compose.animation.core.animateFloatAsState
|
||||||
import androidx.compose.foundation.*
|
import androidx.compose.foundation.*
|
||||||
@@ -564,47 +566,35 @@ fun RoundedTextField(
|
|||||||
@Composable
|
@Composable
|
||||||
fun FullScreenThumbnailVideoPlayer(
|
fun FullScreenThumbnailVideoPlayer(
|
||||||
key: String,
|
key: String,
|
||||||
|
title: String,
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|
||||||
val showFullscreenView = remember { mutableStateOf(false) }
|
Column(
|
||||||
|
verticalArrangement = Arrangement.spacedBy(6.dp)
|
||||||
|
) {
|
||||||
AsyncImage(
|
AsyncImage(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.clickable(
|
.clickable(
|
||||||
onClick = { showFullscreenView.value = true }
|
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",
|
model = "https://img.youtube.com/vi/${key}/hqdefault.jpg",
|
||||||
contentDescription = "",
|
contentDescription = "",
|
||||||
placeholder = rememberAsyncImagePainter(model = R.drawable.placeholder)
|
placeholder = rememberAsyncImagePainter(model = R.drawable.placeholder)
|
||||||
)
|
)
|
||||||
|
|
||||||
if (showFullscreenView.value) {
|
Text(
|
||||||
Dialog(
|
text = title,
|
||||||
onDismissRequest = { showFullscreenView.value = false },
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
properties = DialogProperties(usePlatformDefaultWidth = false)
|
fontSize = 16.sp
|
||||||
) {
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ sealed class MediaTabNavItem(
|
|||||||
override val name = resourceUtils.getString(stringRes)
|
override val name = resourceUtils.getString(stringRes)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val MovieItems = listOf(Popular, NowPlaying, Upcoming, TopRated)
|
val MovieItems = listOf(NowPlaying, Popular, Upcoming, TopRated)
|
||||||
val TvItems = listOf(Popular, AiringToday, OnTheAir, TopRated)
|
val TvItems = listOf(OnTheAir, Popular, AiringToday, TopRated)
|
||||||
|
|
||||||
private val Items = listOf(NowPlaying, Popular, TopRated, Upcoming, AiringToday, OnTheAir)
|
private val Items = listOf(NowPlaying, Popular, TopRated, Upcoming, AiringToday, OnTheAir)
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,8 @@ fun DetailHeader(
|
|||||||
},
|
},
|
||||||
url = posterUrl,
|
url = posterUrl,
|
||||||
title = posterContentDescription,
|
title = posterContentDescription,
|
||||||
elevation = 20.dp
|
elevation = 20.dp,
|
||||||
|
overrideShowTitle = false
|
||||||
)
|
)
|
||||||
|
|
||||||
rating?.let {
|
rating?.let {
|
||||||
|
|||||||
@@ -838,9 +838,10 @@ private fun VideoGroup(results: List<Video>, type: Video.Type, title: String) {
|
|||||||
listItems(videos) { video ->
|
listItems(videos) { video ->
|
||||||
FullScreenThumbnailVideoPlayer(
|
FullScreenThumbnailVideoPlayer(
|
||||||
key = video.key,
|
key = video.key,
|
||||||
|
title = video.name,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.width(posterWidth)
|
.width(posterWidth)
|
||||||
.height(90.dp)
|
.wrapContentHeight()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user