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