Reorg: move view to subpackages in ui
This commit is contained in:
@@ -47,13 +47,15 @@ import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.fairscan.app.data.GeneratedPdf
|
||||
import org.fairscan.app.ui.Navigation
|
||||
import org.fairscan.app.ui.Screen
|
||||
import org.fairscan.app.ui.theme.FairScanTheme
|
||||
import org.fairscan.app.view.AboutScreen
|
||||
import org.fairscan.app.view.CameraScreen
|
||||
import org.fairscan.app.view.DocumentScreen
|
||||
import org.fairscan.app.view.ExportScreenWrapper
|
||||
import org.fairscan.app.view.HomeScreen
|
||||
import org.fairscan.app.view.LibrariesScreen
|
||||
import org.fairscan.app.ui.screens.AboutScreen
|
||||
import org.fairscan.app.ui.screens.camera.CameraScreen
|
||||
import org.fairscan.app.ui.screens.DocumentScreen
|
||||
import org.fairscan.app.ui.screens.ExportScreenWrapper
|
||||
import org.fairscan.app.ui.screens.HomeScreen
|
||||
import org.fairscan.app.ui.screens.LibrariesScreen
|
||||
import org.opencv.android.OpenCVLoader
|
||||
|
||||
private const val PDF_MIME_TYPE = "application/pdf"
|
||||
|
||||
@@ -47,9 +47,12 @@ import org.fairscan.app.domain.ImageSegmentationService
|
||||
import org.fairscan.app.domain.detectDocumentQuad
|
||||
import org.fairscan.app.domain.extractDocument
|
||||
import org.fairscan.app.domain.scaledTo
|
||||
import org.fairscan.app.ui.PdfGenerationUiState
|
||||
import org.fairscan.app.ui.RecentDocumentUiState
|
||||
import org.fairscan.app.view.DocumentUiModel
|
||||
import org.fairscan.app.ui.NavigationState
|
||||
import org.fairscan.app.ui.state.PdfGenerationUiState
|
||||
import org.fairscan.app.ui.state.RecentDocumentUiState
|
||||
import org.fairscan.app.ui.Screen
|
||||
import org.fairscan.app.ui.state.DocumentUiModel
|
||||
import org.fairscan.app.ui.state.LiveAnalysisState
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.File
|
||||
|
||||
|
||||
@@ -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
|
||||
package org.fairscan.app.ui
|
||||
|
||||
sealed class Screen {
|
||||
sealed class Main : Screen() {
|
||||
@@ -12,13 +12,13 @@
|
||||
* 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.view
|
||||
package org.fairscan.app.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.BitmapFactory
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import org.fairscan.app.Navigation
|
||||
import org.fairscan.app.ui.state.DocumentUiModel
|
||||
|
||||
fun dummyNavigation(): Navigation {
|
||||
return Navigation({}, {}, {}, {}, {}, {}, {})
|
||||
@@ -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.view
|
||||
package org.fairscan.app.ui.components
|
||||
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.size
|
||||
@@ -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.view
|
||||
package org.fairscan.app.ui.components
|
||||
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Text
|
||||
@@ -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.view
|
||||
package org.fairscan.app.ui.components
|
||||
|
||||
import android.content.res.Configuration
|
||||
import android.graphics.Bitmap
|
||||
@@ -49,6 +49,7 @@ import androidx.compose.ui.unit.Density
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import org.fairscan.app.THUMBNAIL_SIZE_DP
|
||||
import org.fairscan.app.ui.state.DocumentUiModel
|
||||
import sh.calvin.reorderable.ReorderableItem
|
||||
import sh.calvin.reorderable.rememberReorderableLazyListState
|
||||
|
||||
@@ -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.view
|
||||
package org.fairscan.app.ui.components
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.background
|
||||
@@ -80,7 +80,7 @@ fun MyScaffold(
|
||||
|
||||
@Composable
|
||||
fun DocumentBar(
|
||||
pageListState: CommonPageListState,
|
||||
pageListState: CommonPageListState,
|
||||
buttonBar: @Composable () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
pageListButton: (@Composable () -> Unit)? = null,
|
||||
@@ -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.view
|
||||
package org.fairscan.app.ui.components
|
||||
|
||||
import android.content.Context
|
||||
import android.text.format.DateFormat
|
||||
@@ -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.view
|
||||
package org.fairscan.app.ui.screens
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.activity.compose.BackHandler
|
||||
@@ -64,6 +64,7 @@ import androidx.compose.ui.unit.dp
|
||||
import androidx.core.net.toUri
|
||||
import org.fairscan.app.BuildConfig
|
||||
import org.fairscan.app.R
|
||||
import org.fairscan.app.ui.components.BackButton
|
||||
import org.fairscan.app.ui.theme.FairScanTheme
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@@ -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.view
|
||||
package org.fairscan.app.ui.screens
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.Image
|
||||
@@ -55,8 +55,16 @@ import androidx.compose.ui.unit.dp
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import net.engawapg.lib.zoomable.ZoomState
|
||||
import net.engawapg.lib.zoomable.zoomable
|
||||
import org.fairscan.app.Navigation
|
||||
import org.fairscan.app.ui.Navigation
|
||||
import org.fairscan.app.R
|
||||
import org.fairscan.app.ui.components.CommonPageListState
|
||||
import org.fairscan.app.ui.components.ConfirmationDialog
|
||||
import org.fairscan.app.ui.components.MainActionButton
|
||||
import org.fairscan.app.ui.components.MyScaffold
|
||||
import org.fairscan.app.ui.components.SecondaryActionButton
|
||||
import org.fairscan.app.ui.dummyNavigation
|
||||
import org.fairscan.app.ui.fakeDocument
|
||||
import org.fairscan.app.ui.state.DocumentUiModel
|
||||
import org.fairscan.app.ui.theme.FairScanTheme
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@@ -112,7 +120,8 @@ fun DocumentScreen(
|
||||
currentPageIndex,
|
||||
{ showDeletePageDialog.value = true },
|
||||
onRotateImage,
|
||||
modifier)
|
||||
modifier
|
||||
)
|
||||
if (showDeletePageDialog.value) {
|
||||
ConfirmationDialog(
|
||||
title = stringResource(R.string.delete_page),
|
||||
@@ -230,7 +239,8 @@ fun DocumentScreenPreview() {
|
||||
DocumentScreen(
|
||||
fakeDocument(
|
||||
listOf(1, 2).map { "gallica.bnf.fr-bpt6k5530456s-$it.jpg" }.toImmutableList(),
|
||||
LocalContext.current),
|
||||
LocalContext.current
|
||||
),
|
||||
initialPage = 1,
|
||||
navigation = dummyNavigation(),
|
||||
onDeleteImage = { _ -> },
|
||||
@@ -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.view
|
||||
package org.fairscan.app.ui.screens
|
||||
|
||||
import android.content.Context
|
||||
import android.text.format.Formatter
|
||||
@@ -67,10 +67,17 @@ import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.net.toUri
|
||||
import org.fairscan.app.data.GeneratedPdf
|
||||
import org.fairscan.app.Navigation
|
||||
import org.fairscan.app.ui.Navigation
|
||||
import org.fairscan.app.PdfGenerationActions
|
||||
import org.fairscan.app.R
|
||||
import org.fairscan.app.ui.PdfGenerationUiState
|
||||
import org.fairscan.app.ui.state.PdfGenerationUiState
|
||||
import org.fairscan.app.ui.components.AboutScreenNavButton
|
||||
import org.fairscan.app.ui.components.BackButton
|
||||
import org.fairscan.app.ui.components.MainActionButton
|
||||
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.theme.FairScanTheme
|
||||
import java.io.File
|
||||
import java.text.SimpleDateFormat
|
||||
@@ -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.view
|
||||
package org.fairscan.app.ui.screens
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.clickable
|
||||
@@ -56,10 +56,16 @@ import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import org.fairscan.app.CameraPermissionState
|
||||
import org.fairscan.app.Navigation
|
||||
import org.fairscan.app.ui.Navigation
|
||||
import org.fairscan.app.R
|
||||
import org.fairscan.app.rememberCameraPermissionState
|
||||
import org.fairscan.app.ui.RecentDocumentUiState
|
||||
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
|
||||
import org.fairscan.app.ui.dummyNavigation
|
||||
import org.fairscan.app.ui.fakeDocument
|
||||
import org.fairscan.app.ui.state.DocumentUiModel
|
||||
import org.fairscan.app.ui.theme.FairScanTheme
|
||||
import java.io.File
|
||||
|
||||
@@ -286,7 +292,8 @@ fun HomeScreenPreviewWithCurrentDocument() {
|
||||
cameraPermission = rememberCameraPermissionState(),
|
||||
currentDocument = fakeDocument(
|
||||
persistentListOf("gallica.bnf.fr-bpt6k5530456s-1.jpg"),
|
||||
LocalContext.current),
|
||||
LocalContext.current
|
||||
),
|
||||
navigation = dummyNavigation(),
|
||||
onClearScan = {},
|
||||
recentDocuments = listOf(),
|
||||
@@ -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.view
|
||||
package org.fairscan.app.ui.screens
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
@@ -31,6 +31,7 @@ import com.mikepenz.aboutlibraries.ui.compose.LibraryDefaults
|
||||
import com.mikepenz.aboutlibraries.ui.compose.android.rememberLibraries
|
||||
import com.mikepenz.aboutlibraries.ui.compose.m3.LibrariesContainer
|
||||
import org.fairscan.app.R
|
||||
import org.fairscan.app.ui.components.BackButton
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
@@ -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.view
|
||||
package org.fairscan.app.ui.screens.camera
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.util.Log
|
||||
@@ -54,7 +54,7 @@ import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.compose.LocalLifecycleOwner
|
||||
import com.google.common.util.concurrent.ListenableFuture
|
||||
import org.fairscan.app.CameraPermissionState
|
||||
import org.fairscan.app.LiveAnalysisState
|
||||
import org.fairscan.app.ui.state.LiveAnalysisState
|
||||
import org.fairscan.app.domain.Point
|
||||
import org.fairscan.app.domain.scaledTo
|
||||
import java.util.concurrent.ExecutorService
|
||||
@@ -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.view
|
||||
package org.fairscan.app.ui.screens.camera
|
||||
|
||||
import android.content.res.Configuration
|
||||
import android.graphics.Bitmap
|
||||
@@ -83,12 +83,18 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.delay
|
||||
import org.fairscan.app.CameraPermissionState
|
||||
import org.fairscan.app.LiveAnalysisState
|
||||
import org.fairscan.app.ui.state.LiveAnalysisState
|
||||
import org.fairscan.app.MainViewModel
|
||||
import org.fairscan.app.MainViewModel.CaptureState
|
||||
import org.fairscan.app.Navigation
|
||||
import org.fairscan.app.ui.Navigation
|
||||
import org.fairscan.app.R
|
||||
import org.fairscan.app.Screen
|
||||
import org.fairscan.app.ui.Screen
|
||||
import org.fairscan.app.ui.components.CommonPageListState
|
||||
import org.fairscan.app.ui.components.MainActionButton
|
||||
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.theme.FairScanTheme
|
||||
|
||||
data class CameraUiState(
|
||||
@@ -230,14 +236,14 @@ private fun CameraScreenScaffold(
|
||||
pageListState = pageListState,
|
||||
onBack = navigation.back,
|
||||
bottomBar = { Bar(cameraUiState.pageCount, onFinalizePressed) }
|
||||
) {
|
||||
modifier ->
|
||||
CameraPreviewBox(
|
||||
cameraPreview,
|
||||
cameraUiState,
|
||||
onCapture,
|
||||
onTorchSwitched,
|
||||
modifier.clickable(onClick = onPageCountClick))
|
||||
) { modifier ->
|
||||
CameraPreviewBox(
|
||||
cameraPreview,
|
||||
cameraUiState,
|
||||
onCapture,
|
||||
onTorchSwitched,
|
||||
modifier.clickable(onClick = onPageCountClick)
|
||||
)
|
||||
}
|
||||
if (cameraUiState.captureState is CaptureState.CapturePreview) {
|
||||
CapturedImage(cameraUiState.captureState.processed.asImageBitmap(), thumbnailCoords)
|
||||
@@ -502,7 +508,7 @@ private fun ScreenPreview(captureState: CaptureState, rotationDegrees: Float = 0
|
||||
.toImmutableList(),
|
||||
LocalContext.current),
|
||||
onPageClick = {},
|
||||
onPageReorder = { _,_ -> },
|
||||
onPageReorder = { _, _ -> },
|
||||
listState = LazyListState(),
|
||||
),
|
||||
cameraUiState = CameraUiState(pageCount = 4, LiveAnalysisState(), captureState,
|
||||
@@ -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.view
|
||||
package org.fairscan.app.ui.state
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
@@ -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
|
||||
package org.fairscan.app.ui.state
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import androidx.compose.runtime.Immutable
|
||||
@@ -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
|
||||
package org.fairscan.app.ui.state
|
||||
|
||||
import android.net.Uri
|
||||
import org.fairscan.app.data.GeneratedPdf
|
||||
@@ -12,15 +12,15 @@
|
||||
* 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
|
||||
package org.fairscan.app.ui
|
||||
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.fairscan.app.Screen.Main.Camera
|
||||
import org.fairscan.app.Screen.Main.Document
|
||||
import org.fairscan.app.Screen.Main.Export
|
||||
import org.fairscan.app.Screen.Main.Home
|
||||
import org.fairscan.app.Screen.Overlay.About
|
||||
import org.fairscan.app.Screen.Overlay.Libraries
|
||||
import org.fairscan.app.ui.Screen.Main.Camera
|
||||
import org.fairscan.app.ui.Screen.Main.Document
|
||||
import org.fairscan.app.ui.Screen.Main.Export
|
||||
import org.fairscan.app.ui.Screen.Main.Home
|
||||
import org.fairscan.app.ui.Screen.Overlay.About
|
||||
import org.fairscan.app.ui.Screen.Overlay.Libraries
|
||||
import org.junit.Test
|
||||
|
||||
class NavigationTest {
|
||||
Reference in New Issue
Block a user