Skip to content

Back handlers and optimizations#19

Merged
kvietelaitis merged 4 commits intomainfrom
fix/bugs
Mar 26, 2026
Merged

Back handlers and optimizations#19
kvietelaitis merged 4 commits intomainfrom
fix/bugs

Conversation

@kvietelaitis
Copy link
Copy Markdown
Contributor

  • Added correct navigation for all transaction / document screens
  • Fixed permission prompts
  • Random optimizations

Copilot AI review requested due to automatic review settings March 26, 2026 23:00
Copy link
Copy Markdown
Contributor

@Nirmanas Nirmanas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors dashboard navigation and some UI/state handling, aiming to make the Documents/Transactions flows navigable as standalone back-stack screens and to streamline recent data rendering and permission prompting.

Changes:

  • Added dedicated navigation routes for Documents and Transactions and updated list screens to use back navigation via NavController.popBackStack().
  • Updated Home state/model to expose “recent” documents/transactions and a “has more” flag, moving list slicing/filtering into the ViewModel.
  • Adjusted Authenticate screen to request permissions before starting NFC engagement, plus assorted UI refactors/optimizations.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
app/src/main/java/com/k689/identid/ui/dashboard/transactions/list/TransactionsScreen.kt Switches back handling to popBackStack() and adopts ToolbarConfig title toolbar.
app/src/main/java/com/k689/identid/ui/dashboard/home/HomeViewModel.kt Adds recent docs/tx state + navigation events for “See all…”, and computes recent lists in ViewModel.
app/src/main/java/com/k689/identid/ui/dashboard/home/HomeScreen.kt Uses new recent state, refactors quick actions, and tweaks effect/permissions handling.
app/src/main/java/com/k689/identid/ui/dashboard/documents/list/DocumentsScreen.kt Switches to backable toolbar + popBackStack(), changes add-document sheet component usage.
app/src/main/java/com/k689/identid/ui/dashboard/dashboard/DashboardScreen.kt Removes/comment-outs bottom tab NavHost, leaving only HomeScreen rendered.
app/src/main/java/com/k689/identid/ui/dashboard/authenticate/AuthenticateScreen.kt Adds runtime BT permission request gating before enabling NFC engagement.
app/src/main/java/com/k689/identid/navigation/routes/dashboard/Graph.kt Registers new composable destinations for Documents and Transactions routes.
app/src/main/java/com/k689/identid/navigation/RouterContract.kt Adds DashboardScreens.Documents and DashboardScreens.Transactions.
app/src/main/java/com/k689/identid/interactor/dashboard/DocumentsInteractor.kt Optimizes revoked-document lookup by precomputing revoked IDs set.
GoogleSansFlex-VariableFont_GRAD,ROND,opsz,slnt,wdth,wght.ttf Adds a font asset.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

import com.k689.identid.extension.ui.finish
import com.k689.identid.extension.ui.openAppSettings
import com.k689.identid.extension.ui.openBleSettings
import com.k689.identid.navigation.DashboardScreens
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New DashboardScreens import appears unused in this file. Please remove it to avoid warnings (and potential build failures if warnings are treated as errors).

Suggested change
import com.k689.identid.navigation.DashboardScreens

Copilot uses AI. Check for mistakes.
Comment on lines 191 to 199
private fun handleNavigationEffect(
navigationEffect: Effect.Navigation,
navController: NavController,
context: Context,
) {
when (navigationEffect) {
is Effect.Navigation.Pop -> {
context.finish()
navController.popBackStack()
}
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handleNavigationEffect(...) no longer uses context after switching from context.finish() to navController.popBackStack(). Please remove the unused context parameter (and update call sites), and also drop the now-unused finish import in this file to keep compilation clean if warnings are treated as errors.

Copilot uses AI. Check for mistakes.
IconButton(onClick = onAuthenticateClick) {
Icon(
imageVector = Icons.Default.MobileFriendly,
contentDescription = "Authenticate",
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contentDescription is hardcoded ("Authenticate") even though there is a dedicated string resource (home_screen_content_description_authenticate). Please use stringResource(...) so accessibility text is localizable and consistent.

Suggested change
contentDescription = "Authenticate",
contentDescription = stringResource(R.string.home_screen_content_description_authenticate),

Copilot uses AI. Check for mistakes.
Comment on lines 106 to +123
@@ -129,8 +120,7 @@ internal fun DashboardScreen(
viewModel.setEvent(event)
},
)
}
}
}*/
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Large blocks of navigation code are currently commented out inside DashboardScreen. This makes the file hard to maintain and risks leaving dead logic (e.g., Effect.SwitchTab) behind. Please either restore the navigation host properly or remove the commented code and the associated unused dependencies/logic.

Copilot uses AI. Check for mistakes.
},
toolBarConfig =
ToolbarConfig(
title = stringResource(R.string.documents_screen_title),
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By removing the custom TopBar(...) from ContentScreen and switching to a plain ToolbarConfig(title=...), the UI no longer exposes the + action that triggers Event.AddDocumentPressed (the only place that event is sent is inside the old TopBar). This makes it impossible to open the “Add document” bottom sheet from the Documents screen. Please reintroduce an add action (e.g., via ToolbarConfig.actions or by keeping the custom top bar).

Suggested change
title = stringResource(R.string.documents_screen_title),
title = stringResource(R.string.documents_screen_title),
actions =
listOf {
WrapIconButton(
icon = AppIcons.Add,
contentDescription = stringResource(R.string.documents_screen_title),
onClick = { viewModel.setEvent(Event.AddDocumentPressed) },
)
},

Copilot uses AI. Check for mistakes.
Comment on lines 553 to 556
),
onEventSent = onEventSent,
hostTab = BottomNavigationItem.Documents.route.lowercase(),
// hostTab = BottomNavigationItem.Documents.route.lowercase(),
)
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is commented-out code (hostTab = BottomNavigationItem.Documents...) left in this call. Since BottomNavigationItem is now only referenced in a comment, it also leaves an effectively-unused import. Please remove the commented line and the unused import, or reintroduce the needed parameter in the bottom-sheet API if it’s still required.

Copilot uses AI. Check for mistakes.
Comment on lines 338 to +345
private fun handleNavigationEffect(
navigationEffect: Effect.Navigation,
navController: NavController,
context: Context,
) {
when (navigationEffect) {
is Effect.Navigation.Pop -> {
context.finish()
navController.popBackStack()
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handleNavigationEffect(...) still takes a context: Context parameter, but after changing Pop to navController.popBackStack() the context is unused. Please remove the unused parameter (and update call sites) and drop the now-unused finish import to keep the file warning-free.

Copilot uses AI. Check for mistakes.
IconButton(onClick = onSignDocumentClick) {
Icon(
imageVector = Icons.Default.Edit,
contentDescription = "Sign document",
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contentDescription is hardcoded ("Sign document") even though there is a dedicated string resource (home_screen_content_description_sign_document). Please use stringResource(...) so accessibility text is localizable and consistent.

Suggested change
contentDescription = "Sign document",
contentDescription = stringResource(R.string.home_screen_content_description_sign_document),

Copilot uses AI. Check for mistakes.
Comment on lines +90 to 103
DisposableEffect(context, permissionsState.allPermissionsGranted) {
val activity = context as? ComponentActivity
activity?.let {
viewModel.setEvent(Event.NfcEngagement(it, true))

// ONLY start NFC engagement if permissions are granted
if (permissionsState.allPermissionsGranted && activity != null) {
viewModel.setEvent(Event.NfcEngagement(activity, true))
}

onDispose {
activity?.let {
viewModel.setEvent(Event.NfcEngagement(it, false))
}
}
}
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NFC engagement is toggled via DisposableEffect(...), so it will remain enabled when the app is backgrounded while this composable stays in composition (no onDispose), which is inconsistent with how other NFC engagement screens are handled. Consider switching to lifecycle-driven toggling (enable on ON_RESUME, disable on ON_PAUSE) like ProximityQRScreen does (ui/proximity/qr/ProximityQRScreen.kt:108-130), and keep the permission gating in the resume handler.

Copilot uses AI. Check for mistakes.
Comment on lines +99 to +106
HomeScreen(
hostNavController,
homeViewModel,
onDashboardEventSent = { event ->
viewModel.setEvent(event)
},
)
/* composable(BottomNavigationItem.Documents.route) {
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NavHost/composable(...) setup for bottomNavigationController was removed (and destinations are now commented out). This means bottomNavigationController never gets a graph, so any later bottomNavigationController.navigate(...) calls (e.g., from Effect.SwitchTab) will throw IllegalStateException: NavController graph has not been set or become a no-op. Either restore the NavHost with the tab destinations, or remove the bottomNavigationController + Effect.SwitchTab handling and migrate all tab switching to hostNavController routes.

Copilot uses AI. Check for mistakes.
@kvietelaitis kvietelaitis merged commit 675914d into main Mar 26, 2026
5 checks passed
@kvietelaitis kvietelaitis deleted the fix/bugs branch March 26, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants