DocumentScreen: reset zoom after rotation so that all areas are reachable (#152)
This commit is contained in:
@@ -85,7 +85,7 @@ class MainViewModel(val imageRepository: ImageRepository, launchMode: LaunchMode
|
||||
page?.let {
|
||||
val isLoading = (it.id == loadingId)
|
||||
val bitmap = imageRepository.jpegBytes(it.key())?.toBitmap()
|
||||
CurrentPageUiState(it.id, bitmap, it.colorMode, isLoading)
|
||||
CurrentPageUiState(it.key(), bitmap, it.colorMode, isLoading)
|
||||
}
|
||||
}
|
||||
.flowOn(Dispatchers.IO)
|
||||
|
||||
@@ -73,6 +73,8 @@ import kotlinx.collections.immutable.toImmutableList
|
||||
import net.engawapg.lib.zoomable.ZoomState
|
||||
import net.engawapg.lib.zoomable.zoomable
|
||||
import org.fairscan.app.R
|
||||
import org.fairscan.app.domain.PageViewKey
|
||||
import org.fairscan.app.domain.Rotation
|
||||
import org.fairscan.app.ui.Navigation
|
||||
import org.fairscan.app.ui.components.CommonPageListState
|
||||
import org.fairscan.app.ui.components.ConfirmationDialog
|
||||
@@ -160,10 +162,10 @@ private fun DocumentPreview(
|
||||
modifier = Modifier.fillMaxSize()
|
||||
) {
|
||||
val bitmap = uiState.currentPage?.bitmap
|
||||
val pageId = uiState.currentPage?.id
|
||||
if (bitmap != null && pageId != null) {
|
||||
val pageKey = uiState.currentPage?.key
|
||||
if (bitmap != null && pageKey != null) {
|
||||
val imageBitmap = bitmap.asImageBitmap()
|
||||
val zoomState = remember(pageId) {
|
||||
val zoomState = remember(pageKey) {
|
||||
ZoomState(
|
||||
contentSize = Size(bitmap.width.toFloat(), bitmap.height.toFloat())
|
||||
)
|
||||
@@ -344,8 +346,9 @@ fun DocumentScreenPreview() {
|
||||
listOf(1, 2).map { "gallica.bnf.fr-bpt6k5530456s-$it" }.toImmutableList(),
|
||||
LocalContext.current
|
||||
)
|
||||
val key = PageViewKey("123", Rotation.R0, null)
|
||||
DocumentScreen(
|
||||
uiState = DocumentUiState(1, CurrentPageUiState("123",image, COLOR), document),
|
||||
uiState = DocumentUiState(1, CurrentPageUiState(key,image, COLOR), document),
|
||||
navigation = dummyNavigation(),
|
||||
onExportClick = {},
|
||||
onDeleteImage = { },
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package org.fairscan.app.ui.screens.document
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import org.fairscan.app.domain.PageViewKey
|
||||
import org.fairscan.app.ui.state.DocumentUiModel
|
||||
import org.fairscan.imageprocessing.ColorMode
|
||||
|
||||
@@ -25,7 +26,7 @@ data class DocumentUiState(
|
||||
)
|
||||
|
||||
data class CurrentPageUiState(
|
||||
val id: String,
|
||||
val key: PageViewKey,
|
||||
val bitmap: Bitmap?,
|
||||
val colorMode: ColorMode?,
|
||||
val isLoading: Boolean = false,
|
||||
|
||||
Reference in New Issue
Block a user