Move Document screen out of default scan process
This commit is contained in:
@@ -131,6 +131,20 @@ class MainActivity : ComponentActivity() {
|
||||
|
||||
FairScanTheme {
|
||||
val navigation = navigation(viewModel, launchMode)
|
||||
val onExportClick = if (launchMode == LaunchMode.EXTERNAL_SCAN_TO_PDF) {
|
||||
{
|
||||
lifecycleScope.launch {
|
||||
val result = exportViewModel.generatePdfForExternalCall()
|
||||
sendActivityResult(result)
|
||||
viewModel.startNewDocument()
|
||||
finish()
|
||||
}
|
||||
Unit
|
||||
}
|
||||
} else {
|
||||
navigation.toExportScreen
|
||||
}
|
||||
|
||||
when (val screen = currentScreen) {
|
||||
is Screen.Main.Home -> {
|
||||
val recentDocs by homeViewModel.recentDocuments.collectAsStateWithLifecycle()
|
||||
@@ -150,7 +164,7 @@ class MainActivity : ComponentActivity() {
|
||||
navigation,
|
||||
liveAnalysisState,
|
||||
onImageAnalyzed = { image -> cameraViewModel.liveAnalysis(image) },
|
||||
onFinalizePressed = navigation.toDocumentScreen,
|
||||
onFinalizePressed = onExportClick,
|
||||
cameraPermission = cameraPermission
|
||||
)
|
||||
}
|
||||
@@ -159,19 +173,7 @@ class MainActivity : ComponentActivity() {
|
||||
document = document,
|
||||
initialPage = screen.initialPage,
|
||||
navigation = navigation,
|
||||
onExportClick = if (launchMode == LaunchMode.EXTERNAL_SCAN_TO_PDF) {
|
||||
{
|
||||
lifecycleScope.launch {
|
||||
val result = exportViewModel.generatePdfForExternalCall()
|
||||
sendActivityResult(result)
|
||||
viewModel.startNewDocument()
|
||||
finish()
|
||||
}
|
||||
Unit
|
||||
}
|
||||
} else {
|
||||
navigation.toExportScreen
|
||||
},
|
||||
onExportClick = onExportClick,
|
||||
onDeleteImage = { id -> viewModel.deletePage(id) },
|
||||
onRotateImage = { id, clockwise -> viewModel.rotateImage(id, clockwise) },
|
||||
onPageReorder = { id, newIndex -> viewModel.movePage(id, newIndex) },
|
||||
|
||||
@@ -73,7 +73,7 @@ data class NavigationState private constructor(val stack: List<Screen>, val root
|
||||
is Screen.Main.Home -> this // Back handled by system
|
||||
is Screen.Main.Camera -> copy(stack = listOf(Screen.Main.Home))
|
||||
is Screen.Main.Document -> copy(stack = listOf(Screen.Main.Camera))
|
||||
is Screen.Main.Export -> copy(stack = listOf(Screen.Main.Document()))
|
||||
is Screen.Main.Export -> copy(stack = listOf(Screen.Main.Camera))
|
||||
is Screen.Overlay -> copy(stack = stack.dropLast(1))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.RotateLeft
|
||||
import androidx.compose.material.icons.automirrored.filled.RotateRight
|
||||
import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.material.icons.filled.Description
|
||||
import androidx.compose.material.icons.filled.Done
|
||||
import androidx.compose.material.icons.outlined.Delete
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
@@ -227,7 +227,7 @@ private fun BottomBar(
|
||||
) {
|
||||
MainActionButton(
|
||||
onClick = onExportClick,
|
||||
icon = Icons.Default.Description,
|
||||
icon = Icons.Default.Done,
|
||||
text = stringResource(R.string.export),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user