Stub impl of preview image clip
this way sucks, later we will clip it with compose method
This commit is contained in:
1 parent
89b20b3cda
commit
7742b2c570
2 files changed
+24
-1
No files matched your search
@@ -200,6 +200,7 @@ dependencies {
|
||||
implementation("com.github.tachiyomiorg:DirectionalViewPager:1.0.0") // Dead Dependency
|
||||
// https://github.com/google/accompanist/releases
|
||||
implementation("com.google.accompanist:accompanist-themeadapter-material3:0.28.0")
|
||||
implementation("com.google.accompanist:accompanist-drawablepainter:0.28.0")
|
||||
implementation("com.google.android.material:material:1.8.0")
|
||||
|
||||
// https://square.github.io/okhttp/changelogs/changelog/
|
||||
|
||||
@@ -12,6 +12,8 @@ import androidx.compose.ui.platform.LocalContext
|
||||
import coil.compose.AsyncImage
|
||||
import coil.compose.AsyncImagePainter
|
||||
import coil.request.ImageRequest
|
||||
import com.google.accompanist.drawablepainter.DrawablePainter
|
||||
import com.hippo.drawable.PreciselyClipDrawable
|
||||
import com.hippo.ehviewer.client.data.GalleryPreview
|
||||
import com.hippo.ehviewer.coil.ehUrl
|
||||
|
||||
@@ -45,10 +47,30 @@ fun EhAsyncPreview(
|
||||
model = requestOf(model.imageUrl),
|
||||
contentDescription = "",
|
||||
modifier = modifier,
|
||||
transform = {
|
||||
if (it is AsyncImagePainter.State.Success) {
|
||||
model.run {
|
||||
if (offsetX == Int.MIN_VALUE) it
|
||||
else it.copy(
|
||||
painter = DrawablePainter(
|
||||
PreciselyClipDrawable(
|
||||
it.result.drawable,
|
||||
offsetX,
|
||||
offsetY,
|
||||
clipWidth,
|
||||
clipHeight
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
it
|
||||
}
|
||||
},
|
||||
onState = {
|
||||
if (it is AsyncImagePainter.State.Success) {
|
||||
it.result.drawable.run {
|
||||
if ((intrinsicWidth.toFloat() / intrinsicHeight) in 0.5..0.8) {
|
||||
if ((intrinsicWidth.toFloat() / intrinsicHeight) in 0.5..0.8 && model.offsetX == Int.MIN_VALUE) {
|
||||
if (contentScale == ContentScale.Fit) contentScale = ContentScale.Crop
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user