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