chore: replace view library with equivalent compose library

Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
Infi 2023-12-09 19:57:49 +01:00
parent 233d2b73a2
commit 46bb2d69bf
2 changed files with 17 additions and 16 deletions

View File

@ -239,7 +239,6 @@ dependencies {
// Libraries used for legacy View-based UI
implementation "androidx.constraintlayout:constraintlayout:2.2.0-alpha13"
implementation 'com.github.MikeOrtiz:TouchImageView:3.3'
implementation "androidx.appcompat:appcompat:1.7.0-alpha03"
implementation 'com.google.android.material:material:1.10.0'
@ -252,12 +251,13 @@ dependencies {
// Markdown
implementation "com.github.discord:SimpleAST:2.7.0"
// AndroidX Media3 w/ ExoPlayer
implementation "androidx.media3:media3-exoplayer:$media3_version"
implementation "androidx.media3:media3-exoplayer-hls:$media3_version"
implementation "androidx.media3:media3-datasource-okhttp:$media3_version"
implementation "androidx.media3:media3-ui:$media3_version"
// Colour picker
// Compose libraries
implementation "com.github.skydoves:colorpicker-compose:1.0.5"
implementation "me.saket.telephoto:zoomable-image:1.0.0-alpha02"
implementation "me.saket.telephoto:zoomable-image-glide:1.0.0-alpha02"
}

View File

@ -38,7 +38,6 @@ import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.viewinterop.AndroidView
import androidx.core.view.WindowCompat
import chat.revolt.R
import chat.revolt.api.REVOLT_FILES
@ -49,10 +48,14 @@ import chat.revolt.api.settings.SyncedSettings
import chat.revolt.components.generic.PageHeader
import chat.revolt.provider.getAttachmentContentUri
import chat.revolt.ui.theme.RevoltTheme
import com.bumptech.glide.Glide
import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi
import io.ktor.client.request.get
import io.ktor.client.statement.readBytes
import kotlinx.coroutines.launch
import me.saket.telephoto.zoomable.ZoomSpec
import me.saket.telephoto.zoomable.glide.ZoomableGlideImage
import me.saket.telephoto.zoomable.rememberZoomableImageState
import me.saket.telephoto.zoomable.rememberZoomableState
class ImageViewActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
@ -79,6 +82,7 @@ class ImageViewActivity : ComponentActivity() {
}
}
@OptIn(ExperimentalGlideComposeApi::class)
@Composable
fun ImageViewScreen(resource: AutumnResource, onClose: () -> Unit = {}) {
val resourceUrl = "$REVOLT_FILES/attachments/${resource.id}/${resource.filename}"
@ -260,19 +264,16 @@ fun ImageViewScreen(resource: AutumnResource, onClose: () -> Unit = {}) {
.clip(RectangleShape)
.fillMaxSize()
) {
AndroidView(
factory = { context ->
com.ortiz.touchview.TouchImageView(context).apply {
maxZoom = 10f
doubleTapScale = 3f
}
},
update = {
Glide.with(it).load(resourceUrl).into(it)
},
ZoomableGlideImage(
model = resourceUrl,
contentDescription = null,
state = rememberZoomableImageState(
rememberZoomableState(
zoomSpec = ZoomSpec(maxZoomFactor = 10f)
)
),
modifier = Modifier
.fillMaxSize()
.background(MaterialTheme.colorScheme.background)
)
}
}