mirror of
https://github.com/owenlejeune/TVTime.git
synced 2026-02-18 10:56:50 -05:00
update coil api
This commit is contained in:
@@ -13,16 +13,16 @@ import androidx.compose.material.Card
|
|||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.graphics.Brush
|
import androidx.compose.ui.graphics.Brush
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.layout.onGloballyPositioned
|
import androidx.compose.ui.layout.onGloballyPositioned
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.IntSize
|
import androidx.compose.ui.unit.IntSize
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.core.content.ContextCompat
|
import coil.compose.AsyncImage
|
||||||
import coil.compose.rememberImagePainter
|
|
||||||
import coil.transform.RoundedCornersTransformation
|
|
||||||
import com.google.accompanist.pager.ExperimentalPagerApi
|
import com.google.accompanist.pager.ExperimentalPagerApi
|
||||||
import com.google.accompanist.pager.HorizontalPager
|
import com.google.accompanist.pager.HorizontalPager
|
||||||
import com.google.accompanist.pager.rememberPagerState
|
import com.google.accompanist.pager.rememberPagerState
|
||||||
@@ -157,25 +157,30 @@ fun PosterItem(
|
|||||||
.size(width = width, height = height),
|
.size(width = width, height = height),
|
||||||
shape = RoundedCornerShape(5.dp)
|
shape = RoundedCornerShape(5.dp)
|
||||||
) {
|
) {
|
||||||
Image(
|
if (url != null) {
|
||||||
painter = if (url != null) {
|
AsyncImage(
|
||||||
rememberImagePainter(
|
modifier = Modifier
|
||||||
data = url ?: noDataImage,
|
.size(width = width, height = height)
|
||||||
builder = {
|
.clip(RoundedCornerShape(5f.dpToPx(context)))
|
||||||
transformations(RoundedCornersTransformation(5f.dpToPx(context)))
|
.clickable(
|
||||||
placeholder(placeholder)
|
onClick = onClick
|
||||||
}
|
),
|
||||||
)
|
model = url,
|
||||||
} else {
|
placeholder = painterResource(id = placeholder),
|
||||||
rememberImagePainter(ContextCompat.getDrawable(context, R.drawable.placeholder))
|
contentDescription = contentDescription
|
||||||
},
|
)
|
||||||
contentDescription = contentDescription,
|
} else {
|
||||||
modifier = Modifier
|
Image(
|
||||||
.size(width = width, height = height)
|
modifier = Modifier
|
||||||
.clickable(
|
.size(width = width, height = height)
|
||||||
onClick = onClick
|
.clip(RoundedCornerShape(5f.dpToPx(context)))
|
||||||
)
|
.clickable(
|
||||||
)
|
onClick = onClick
|
||||||
|
),
|
||||||
|
painter = painterResource(id = noDataImage),
|
||||||
|
contentDescription = contentDescription
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,36 +210,28 @@ fun BackdropImage(
|
|||||||
val pagerState = rememberPagerState()
|
val pagerState = rememberPagerState()
|
||||||
HorizontalPager(count = collection.backdrops.size, state = pagerState) { page ->
|
HorizontalPager(count = collection.backdrops.size, state = pagerState) { page ->
|
||||||
val backdrop = collection.backdrops[page]
|
val backdrop = collection.backdrops[page]
|
||||||
Image(
|
AsyncImage(
|
||||||
painter = rememberImagePainter(
|
model = TmdbUtils.getFullBackdropPath(backdrop),
|
||||||
data = TmdbUtils.getFullBackdropPath(backdrop),
|
placeholder = painterResource(id = R.drawable.placeholder),
|
||||||
builder = {
|
|
||||||
placeholder(R.drawable.placeholder)
|
|
||||||
}
|
|
||||||
),
|
|
||||||
contentDescription = "",
|
contentDescription = "",
|
||||||
modifier = Modifier.onGloballyPositioned {
|
modifier = Modifier.onGloballyPositioned { sizeImage = it.size }
|
||||||
sizeImage = it.size
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Image(
|
if (imageUrl != null) {
|
||||||
painter = if (imageUrl != null) {
|
AsyncImage(
|
||||||
rememberImagePainter(
|
model = imageUrl,
|
||||||
data = imageUrl,
|
placeholder = painterResource(id = R.drawable.placeholder),
|
||||||
builder = {
|
contentDescription = contentDescription,
|
||||||
placeholder(R.drawable.placeholder)
|
modifier = Modifier.onGloballyPositioned { sizeImage = it.size }
|
||||||
}
|
)
|
||||||
)
|
} else {
|
||||||
} else {
|
Image(
|
||||||
rememberImagePainter(ContextCompat.getDrawable(context, R.drawable.placeholder))
|
painter = painterResource(id = R.drawable.placeholder),
|
||||||
},
|
contentDescription = contentDescription,
|
||||||
contentDescription = contentDescription,
|
modifier = Modifier.onGloballyPositioned { sizeImage = it.size }
|
||||||
modifier = Modifier.onGloballyPositioned {
|
)
|
||||||
sizeImage = it.size
|
}
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|||||||
@@ -62,8 +62,7 @@ import androidx.compose.ui.viewinterop.AndroidView
|
|||||||
import androidx.compose.ui.window.Dialog
|
import androidx.compose.ui.window.Dialog
|
||||||
import androidx.compose.ui.window.DialogProperties
|
import androidx.compose.ui.window.DialogProperties
|
||||||
import androidx.core.text.HtmlCompat
|
import androidx.core.text.HtmlCompat
|
||||||
import coil.compose.rememberImagePainter
|
import coil.compose.AsyncImage
|
||||||
import coil.transform.CircleCropTransformation
|
|
||||||
import com.google.accompanist.flowlayout.FlowRow
|
import com.google.accompanist.flowlayout.FlowRow
|
||||||
import com.owenlejeune.tvtime.R
|
import com.owenlejeune.tvtime.R
|
||||||
import com.owenlejeune.tvtime.api.tmdb.api.v3.model.AuthorDetails
|
import com.owenlejeune.tvtime.api.tmdb.api.v3.model.AuthorDetails
|
||||||
@@ -545,20 +544,14 @@ fun FullScreenThumbnailVideoPlayer(
|
|||||||
|
|
||||||
val showFullscreenView = remember { mutableStateOf(false) }
|
val showFullscreenView = remember { mutableStateOf(false) }
|
||||||
|
|
||||||
Image(
|
AsyncImage(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.clickable(
|
.clickable(
|
||||||
onClick = {
|
onClick = { showFullscreenView.value = true }
|
||||||
showFullscreenView.value = true
|
|
||||||
}
|
|
||||||
),
|
),
|
||||||
painter = rememberImagePainter(
|
model = "https://img.youtube.com/vi/${key}/hqdefault.jpg",
|
||||||
data = "https://img.youtube.com/vi/${key}/hqdefault.jpg",
|
contentDescription = "",
|
||||||
builder = {
|
placeholder = painterResource(id = R.drawable.placeholder)
|
||||||
placeholder(R.drawable.placeholder)
|
|
||||||
}
|
|
||||||
),
|
|
||||||
contentDescription = ""
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if (showFullscreenView.value) {
|
if (showFullscreenView.value) {
|
||||||
@@ -694,14 +687,9 @@ fun AvatarImage(
|
|||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
if (author.avatarPath != null) {
|
if (author.avatarPath != null) {
|
||||||
Image(
|
AsyncImage(
|
||||||
modifier = modifier.size(size),
|
modifier = modifier.size(size).clip(CircleShape),
|
||||||
painter = rememberImagePainter(
|
model = TmdbUtils.getFullAvatarPath(author),
|
||||||
data = TmdbUtils.getFullAvatarPath(author),
|
|
||||||
builder = {
|
|
||||||
transformations(CircleCropTransformation())
|
|
||||||
}
|
|
||||||
),
|
|
||||||
contentDescription = ""
|
contentDescription = ""
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.owenlejeune.tvtime.ui.screens.tabs.bottom
|
package com.owenlejeune.tvtime.ui.screens.tabs.bottom
|
||||||
|
|
||||||
import androidx.compose.foundation.Image
|
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
@@ -23,7 +22,6 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import androidx.navigation.NavHostController
|
import androidx.navigation.NavHostController
|
||||||
import coil.compose.AsyncImage
|
import coil.compose.AsyncImage
|
||||||
import coil.compose.rememberImagePainter
|
|
||||||
import com.google.accompanist.pager.ExperimentalPagerApi
|
import com.google.accompanist.pager.ExperimentalPagerApi
|
||||||
import com.google.accompanist.pager.HorizontalPager
|
import com.google.accompanist.pager.HorizontalPager
|
||||||
import com.google.accompanist.pager.PagerState
|
import com.google.accompanist.pager.PagerState
|
||||||
@@ -208,13 +206,10 @@ private fun MediaItemRow(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
Image(
|
AsyncImage(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.width(60.dp)
|
.size(width = 60.dp, height = 80.dp),
|
||||||
.height(80.dp),
|
model = posterPath,
|
||||||
painter = rememberImagePainter(
|
|
||||||
data = posterPath
|
|
||||||
),
|
|
||||||
contentDescription = ""
|
contentDescription = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user