contacts: keep Navigation.kt to the Navigation composable
- Commit
36cbf26e170b6cb19b486d699334370a4b29605a- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-19 03:20 UTC (17 days ago)
- Parents
7767e31
PackageStructure lint requires the app-root Navigation.kt to contain only the top-level @Composable fun Navigation(...). contacts parked two start-route helpers in that file, which is now a fatal lint error. Move startTabFor and resolveStartRoute verbatim into the new ui/NavigationEntries.kt (package com.vayunmathur.contacts.ui). resolveStartRoute becomes internal so Navigation.kt can still call it across files; startTabFor stays private to the new file. Function names, signatures, and behaviour are unchanged; Navigation.kt imports resolveStartRoute from ui/. No screens moved and no navigation behaviour changed. Verified: ./gradlew :contacts:lintDev :contacts:testDevUnitTest both pass.
Diff
contacts/src/main/java/com/vayunmathur/contacts/Navigation.kt
diff --git a/contacts/src/main/java/com/vayunmathur/contacts/Navigation.kt b/contacts/src/main/java/com/vayunmathur/contacts/Navigation.ktindex 186ec3d06b..9d14805a21 100644--- a/contacts/src/main/java/com/vayunmathur/contacts/Navigation.kt+++ b/contacts/src/main/java/com/vayunmathur/contacts/Navigation.kt@@ -12,6 +12,7 @@ import com.vayunmathur.contacts.platform.ContactViewModel import com.vayunmathur.contacts.sync.CalendarWorker import com.vayunmathur.contacts.ui.NavGraphEntries import com.vayunmathur.contacts.ui.rememberTabsCallbacks+import com.vayunmathur.contacts.ui.resolveStartRoute import com.vayunmathur.contacts.ui.shouldPushOnto import com.vayunmathur.library.util.rememberNavBackStack import com.vayunmathur.library.ui.ExperimentalMaterial3Api@@ -89,27 +90,3 @@ fun Navigation( goBack = ::goBack, ) }--/**- * The tab a deep link starts on: App Info and Settings links start on- * Settings, a groups link on Groups, anything else on the Contacts home tab.- */-private fun startTabFor(initialRoute: Route?, launchedFromAppInfo: Boolean): Route = when {- launchedFromAppInfo || initialRoute is Route.Settings -> Route.Settings- initialRoute is Route.GroupsList -> Route.GroupsList()- initialRoute is Route.ContactsList -> Route.ContactsList- (initialRoute as? Route.GroupsList)?.expandGroupId != null -> Route.GroupsList()- else -> Route.ContactsList-}--/**- * The root route for [initialRoute]: tab routes start on their sibling tab,- * while non-tab deep links (detail/edit/import) keep their previous shape —- * the route itself is the root, with the bottom bar showing no tab selected.- */-private fun resolveStartRoute(initialRoute: Route?, launchedFromAppInfo: Boolean): Route =- when (initialRoute) {- is Route.ContactsList, is Route.GroupsList, is Route.Settings, null ->- startTabFor(initialRoute, launchedFromAppInfo)- else -> initialRoute- }
contacts/src/main/java/com/vayunmathur/contacts/ui/NavigationEntries.kt
diff --git a/contacts/src/main/java/com/vayunmathur/contacts/ui/NavigationEntries.kt b/contacts/src/main/java/com/vayunmathur/contacts/ui/NavigationEntries.ktnew file mode 100644index 0000000000..5b9f61f860--- /dev/null+++ b/contacts/src/main/java/com/vayunmathur/contacts/ui/NavigationEntries.kt@@ -0,0 +1,27 @@+package com.vayunmathur.contacts.ui++import com.vayunmathur.contacts.Route++/**+ * The tab a deep link starts on: App Info and Settings links start on+ * Settings, a groups link on Groups, anything else on the Contacts home tab.+ */+private fun startTabFor(initialRoute: Route?, launchedFromAppInfo: Boolean): Route = when {+ launchedFromAppInfo || initialRoute is Route.Settings -> Route.Settings+ initialRoute is Route.GroupsList -> Route.GroupsList()+ initialRoute is Route.ContactsList -> Route.ContactsList+ (initialRoute as? Route.GroupsList)?.expandGroupId != null -> Route.GroupsList()+ else -> Route.ContactsList+}++/**+ * The root route for [initialRoute]: tab routes start on their sibling tab,+ * while non-tab deep links (detail/edit/import) keep their previous shape —+ * the route itself is the root, with the bottom bar showing no tab selected.+ */+internal fun resolveStartRoute(initialRoute: Route?, launchedFromAppInfo: Boolean): Route =+ when (initialRoute) {+ is Route.ContactsList, is Route.GroupsList, is Route.Settings, null ->+ startTabFor(initialRoute, launchedFromAppInfo)+ else -> initialRoute+ }