Move code for UI state to screen-specific packages
This commit is contained in:
@@ -53,10 +53,9 @@ import androidx.core.graphics.scale
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.compose.LocalLifecycleOwner
|
||||
import com.google.common.util.concurrent.ListenableFuture
|
||||
import org.fairscan.app.ui.components.CameraPermissionState
|
||||
import org.fairscan.app.ui.state.LiveAnalysisState
|
||||
import org.fairscan.app.domain.Point
|
||||
import org.fairscan.app.domain.scaledTo
|
||||
import org.fairscan.app.ui.components.CameraPermissionState
|
||||
import java.util.concurrent.ExecutorService
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
|
||||
@@ -93,19 +93,8 @@ import org.fairscan.app.ui.components.MyScaffold
|
||||
import org.fairscan.app.ui.components.pageCountText
|
||||
import org.fairscan.app.ui.dummyNavigation
|
||||
import org.fairscan.app.ui.fakeDocument
|
||||
import org.fairscan.app.ui.state.LiveAnalysisState
|
||||
import org.fairscan.app.ui.theme.FairScanTheme
|
||||
|
||||
data class CameraUiState(
|
||||
val pageCount: Int,
|
||||
val liveAnalysisState: LiveAnalysisState,
|
||||
val captureState: CaptureState,
|
||||
val showDetectionError: Boolean,
|
||||
val isLandscape: Boolean,
|
||||
val isDebugMode: Boolean,
|
||||
val isTorchEnabled: Boolean,
|
||||
)
|
||||
|
||||
const val CAPTURED_IMAGE_DISPLAY_DURATION = 1500L
|
||||
const val ANIMATION_DURATION = 200
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.fairscan.app.ui.state
|
||||
package org.fairscan.app.ui.screens.camera
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import androidx.compose.runtime.Immutable
|
||||
@@ -24,4 +24,14 @@ data class LiveAnalysisState(
|
||||
val binaryMask: Bitmap? = null,
|
||||
val documentQuad: Quad? = null,
|
||||
val timestamp: Long = System.currentTimeMillis(),
|
||||
)
|
||||
)
|
||||
|
||||
data class CameraUiState(
|
||||
val pageCount: Int,
|
||||
val liveAnalysisState: LiveAnalysisState,
|
||||
val captureState: CaptureState,
|
||||
val showDetectionError: Boolean,
|
||||
val isLandscape: Boolean,
|
||||
val isDebugMode: Boolean,
|
||||
val isTorchEnabled: Boolean,
|
||||
)
|
||||
@@ -33,7 +33,6 @@ import org.fairscan.app.AppContainer
|
||||
import org.fairscan.app.domain.detectDocumentQuad
|
||||
import org.fairscan.app.domain.extractDocument
|
||||
import org.fairscan.app.domain.scaledTo
|
||||
import org.fairscan.app.ui.state.LiveAnalysisState
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
sealed interface CameraEvent {
|
||||
|
||||
@@ -76,7 +76,6 @@ import org.fairscan.app.ui.components.NewDocumentDialog
|
||||
import org.fairscan.app.ui.components.isLandscape
|
||||
import org.fairscan.app.ui.components.pageCountText
|
||||
import org.fairscan.app.ui.dummyNavigation
|
||||
import org.fairscan.app.ui.state.PdfGenerationUiState
|
||||
import org.fairscan.app.ui.theme.FairScanTheme
|
||||
import java.io.File
|
||||
import java.text.SimpleDateFormat
|
||||
|
||||
@@ -12,11 +12,10 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.fairscan.app.ui.state
|
||||
package org.fairscan.app.ui.screens.export
|
||||
|
||||
import android.net.Uri
|
||||
import org.fairscan.app.data.GeneratedPdf
|
||||
import java.io.File
|
||||
|
||||
data class PdfGenerationUiState(
|
||||
val isGenerating: Boolean = false,
|
||||
@@ -28,9 +27,3 @@ data class PdfGenerationUiState(
|
||||
) {
|
||||
val hasSavedOrSharedPdf get() = savedFileUri != null || hasSharedPdf
|
||||
}
|
||||
|
||||
data class RecentDocumentUiState(
|
||||
val file: File,
|
||||
val saveTimestamp: Long,
|
||||
val pageCount: Int,
|
||||
)
|
||||
@@ -35,7 +35,6 @@ import org.fairscan.app.AppContainer
|
||||
import org.fairscan.app.data.GeneratedPdf
|
||||
import org.fairscan.app.data.PdfFileManager
|
||||
import org.fairscan.app.ui.screens.home.HomeViewModel
|
||||
import org.fairscan.app.ui.state.PdfGenerationUiState
|
||||
import java.io.File
|
||||
|
||||
private const val PDF_MIME_TYPE = "application/pdf"
|
||||
|
||||
@@ -59,7 +59,6 @@ import org.fairscan.app.ui.components.CameraPermissionState
|
||||
import org.fairscan.app.ui.Navigation
|
||||
import org.fairscan.app.R
|
||||
import org.fairscan.app.ui.components.rememberCameraPermissionState
|
||||
import org.fairscan.app.ui.state.RecentDocumentUiState
|
||||
import org.fairscan.app.ui.components.AboutScreenNavButton
|
||||
import org.fairscan.app.ui.components.formatDate
|
||||
import org.fairscan.app.ui.components.pageCountText
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2025 Pierre-Yves Nicolas
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option)
|
||||
* any later version.
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.fairscan.app.ui.screens.home
|
||||
|
||||
import java.io.File
|
||||
|
||||
data class RecentDocumentUiState(
|
||||
val file: File,
|
||||
val saveTimestamp: Long,
|
||||
val pageCount: Int,
|
||||
)
|
||||
@@ -23,7 +23,6 @@ import kotlinx.coroutines.flow.stateIn
|
||||
import kotlinx.coroutines.launch
|
||||
import org.fairscan.app.AppContainer
|
||||
import org.fairscan.app.RecentDocument
|
||||
import org.fairscan.app.ui.state.RecentDocumentUiState
|
||||
import java.io.File
|
||||
|
||||
class HomeViewModel(appContainer: AppContainer): ViewModel() {
|
||||
|
||||
Reference in New Issue
Block a user