chore: replace view library with equivalent compose library
Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
parent
233d2b73a2
commit
46bb2d69bf
|
|
@ -239,7 +239,6 @@ dependencies {
|
||||||
|
|
||||||
// Libraries used for legacy View-based UI
|
// Libraries used for legacy View-based UI
|
||||||
implementation "androidx.constraintlayout:constraintlayout:2.2.0-alpha13"
|
implementation "androidx.constraintlayout:constraintlayout:2.2.0-alpha13"
|
||||||
implementation 'com.github.MikeOrtiz:TouchImageView:3.3'
|
|
||||||
implementation "androidx.appcompat:appcompat:1.7.0-alpha03"
|
implementation "androidx.appcompat:appcompat:1.7.0-alpha03"
|
||||||
implementation 'com.google.android.material:material:1.10.0'
|
implementation 'com.google.android.material:material:1.10.0'
|
||||||
|
|
||||||
|
|
@ -252,12 +251,13 @@ dependencies {
|
||||||
// Markdown
|
// Markdown
|
||||||
implementation "com.github.discord:SimpleAST:2.7.0"
|
implementation "com.github.discord:SimpleAST:2.7.0"
|
||||||
|
|
||||||
// AndroidX Media3 w/ ExoPlayer
|
|
||||||
implementation "androidx.media3:media3-exoplayer:$media3_version"
|
implementation "androidx.media3:media3-exoplayer:$media3_version"
|
||||||
implementation "androidx.media3:media3-exoplayer-hls:$media3_version"
|
implementation "androidx.media3:media3-exoplayer-hls:$media3_version"
|
||||||
implementation "androidx.media3:media3-datasource-okhttp:$media3_version"
|
implementation "androidx.media3:media3-datasource-okhttp:$media3_version"
|
||||||
implementation "androidx.media3:media3-ui:$media3_version"
|
implementation "androidx.media3:media3-ui:$media3_version"
|
||||||
|
|
||||||
// Colour picker
|
// Compose libraries
|
||||||
implementation "com.github.skydoves:colorpicker-compose:1.0.5"
|
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"
|
||||||
}
|
}
|
||||||
|
|
@ -38,7 +38,6 @@ import androidx.compose.ui.graphics.RectangleShape
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.viewinterop.AndroidView
|
|
||||||
import androidx.core.view.WindowCompat
|
import androidx.core.view.WindowCompat
|
||||||
import chat.revolt.R
|
import chat.revolt.R
|
||||||
import chat.revolt.api.REVOLT_FILES
|
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.components.generic.PageHeader
|
||||||
import chat.revolt.provider.getAttachmentContentUri
|
import chat.revolt.provider.getAttachmentContentUri
|
||||||
import chat.revolt.ui.theme.RevoltTheme
|
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.request.get
|
||||||
import io.ktor.client.statement.readBytes
|
import io.ktor.client.statement.readBytes
|
||||||
import kotlinx.coroutines.launch
|
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() {
|
class ImageViewActivity : ComponentActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
|
@ -79,6 +82,7 @@ class ImageViewActivity : ComponentActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalGlideComposeApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun ImageViewScreen(resource: AutumnResource, onClose: () -> Unit = {}) {
|
fun ImageViewScreen(resource: AutumnResource, onClose: () -> Unit = {}) {
|
||||||
val resourceUrl = "$REVOLT_FILES/attachments/${resource.id}/${resource.filename}"
|
val resourceUrl = "$REVOLT_FILES/attachments/${resource.id}/${resource.filename}"
|
||||||
|
|
@ -260,19 +264,16 @@ fun ImageViewScreen(resource: AutumnResource, onClose: () -> Unit = {}) {
|
||||||
.clip(RectangleShape)
|
.clip(RectangleShape)
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
) {
|
) {
|
||||||
AndroidView(
|
ZoomableGlideImage(
|
||||||
factory = { context ->
|
model = resourceUrl,
|
||||||
com.ortiz.touchview.TouchImageView(context).apply {
|
contentDescription = null,
|
||||||
maxZoom = 10f
|
state = rememberZoomableImageState(
|
||||||
doubleTapScale = 3f
|
rememberZoomableState(
|
||||||
}
|
zoomSpec = ZoomSpec(maxZoomFactor = 10f)
|
||||||
},
|
)
|
||||||
update = {
|
),
|
||||||
Glide.with(it).load(resourceUrl).into(it)
|
|
||||||
},
|
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.background(MaterialTheme.colorScheme.background)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue