Avoid displaying the back button when back should be handled by the system (#181)

After removing the home screen, displaying the back button on the camera screen didn't make sense anymore.
See #179.
This commit is contained in:
Pierre-Yves Nicolas
2026-05-18 14:00:08 +02:00
committed by GitHub
parent 6a3ccb854e
commit d9844be4de
4 changed files with 14 additions and 7 deletions

View File

@@ -486,6 +486,10 @@ class MainActivity : ComponentActivity() {
setResult(RESULT_CANCELED)
finish()
}
},
shouldDisplayBackButton = {
viewModel.currentScreen.value !is Screen.Main.Camera
|| launchMode == LaunchMode.EXTERNAL_SCAN_TO_PDF
}
)
}

View File

@@ -37,6 +37,7 @@ data class Navigation(
val toLibrariesScreen: () -> Unit,
val toSettingsScreen: (() -> Unit)?,
val back: () -> Unit,
val shouldDisplayBackButton: () -> Boolean,
)
@ConsistentCopyVisibility

View File

@@ -25,7 +25,7 @@ import org.fairscan.app.ui.state.PageThumbnail
import org.fairscan.imageprocessing.ColorMode
fun dummyNavigation(): Navigation {
return Navigation({}, {}, {}, {}, {}, {}, {}, {})
return Navigation({}, {}, {}, {}, {}, {}, {}, {}, { -> true})
}
fun fakeDocument(pageIds: ImmutableList<String>, context: Context): DocumentUiModel {

View File

@@ -85,12 +85,14 @@ fun MyScaffold(
}
}
}
BackButton(
navigation.back,
modifier = Modifier
.align(Alignment.TopStart)
.windowInsetsPadding(WindowInsets.safeDrawing)
)
if (navigation.shouldDisplayBackButton()) {
BackButton(
navigation.back,
modifier = Modifier
.align(Alignment.TopStart)
.windowInsetsPadding(WindowInsets.safeDrawing)
)
}
AppOverflowMenu(
navigation,
modifier = Modifier