fooddelivery: keep Navigation.kt to the Navigation composable
- Commit
fe4c2fcafb00b0c34169864bb75c817988236d1a- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-19 03:32 UTC (17 days ago)
- Parents
22e8328
PackageStructure lint requires the app-root Navigation.kt to contain only the top-level @Composable fun Navigation(...). fooddelivery parked its detail-entry builder in that file, which is now a fatal lint error. Move detailEntries verbatim into the new ui/NavigationEntries.kt (package com.vayunmathur.fooddelivery.ui), keeping the tab/detail doc comments with it. detailEntries becomes internal so Navigation.kt can still call it across files. Function name, signature, and behaviour are unchanged; Navigation.kt imports detailEntries from ui/ and drops the imports only the moved builder used. No screens moved and no navigation behaviour changed. Verified: ./gradlew :fooddelivery:lintDev :fooddelivery:testDevUnitTest both pass.
Diff
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/Navigation.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/Navigation.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/Navigation.ktindex aec92146ec..bb2b9c5f4d 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/Navigation.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/Navigation.kt@@ -4,22 +4,16 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.platform.LocalContext import com.vayunmathur.fooddelivery.data.CartItem import com.vayunmathur.fooddelivery.data.CartStore-import com.vayunmathur.fooddelivery.platform.canAddFromSameMerchant import com.vayunmathur.fooddelivery.platform.pushDetail import com.vayunmathur.fooddelivery.ui.AccountScreen import com.vayunmathur.fooddelivery.ui.CartScreen-import com.vayunmathur.fooddelivery.ui.CheckoutScreen import com.vayunmathur.fooddelivery.ui.DealsScreen-import com.vayunmathur.fooddelivery.ui.EmailVerificationScreen+import com.vayunmathur.fooddelivery.ui.detailEntries import com.vayunmathur.fooddelivery.ui.FoodDeliveryTabs import com.vayunmathur.fooddelivery.ui.HomeScreen-import com.vayunmathur.fooddelivery.ui.OrderTrackingScreen import com.vayunmathur.fooddelivery.ui.OrdersScreen-import com.vayunmathur.fooddelivery.ui.RestaurantScreen-import com.vayunmathur.library.util.ListDetailPage import com.vayunmathur.library.util.ListPage import com.vayunmathur.library.util.MainNavigation-import com.vayunmathur.library.util.MorphPage import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.library.util.SiblingPage @@ -71,60 +65,3 @@ fun Navigation( } } -/**- * The five bottom-nav tabs as sibling routes (see the route-backed- * [TabbedPagerScaffold] overload). Selecting a tab resets the back stack to- * that tab's route; each tab entry renders this scaffold with its own screen- * as [content], so detail routes (Restaurant, Checkout, OrderTracking) pushed- * over a tab keep the tab as their list pane on wide layouts. Per-tab- * `rememberSaveable` state lives in each route's navigation entry.- */--/** The pushed (non-tab) destinations: restaurant, checkout, tracking, verification. */-private fun com.vayunmathur.library.util.EntryProviderScope<Route>.detailEntries(- backStack: NavBackStack<Route>,- cart: androidx.compose.runtime.snapshots.SnapshotStateList<CartItem>,- context: android.content.Context,- onPendingCartItem: (CartItem) -> Unit,-) {- entry<Route.Restaurant>(metadata = ListDetailPage() + MorphPage()) { route ->- RestaurantScreen(- merchantId = route.id,- onBack = { backStack.pop() },- onAddToCart = { item ->- if (cart.canAddFromSameMerchant(item)) {- cart.add(item)- CartStore.save(context, cart)- } else {- onPendingCartItem(item)- }- },- )- }- // Checkout is a flow step, not a detail of the tab list.- entry<Route.Checkout>(metadata = ListDetailPage()) {- CheckoutScreen(- items = cart,- onBack = { backStack.pop() },- onOrderPlaced = {- backStack.reset(Route.Orders)- },- onOrderCompleted = {- cart.clear()- CartStore.clear(context)- },- )- }- // The brief keeps order-tracking full-screen custom; metadata still marks it a detail- // so medium widths show it two-pane instead of covering the list.- entry<Route.OrderTracking>(metadata = ListDetailPage() + MorphPage()) { route ->- OrderTrackingScreen(orderId = route.orderId, onBack = { backStack.pop() })- }- entry<Route.EmailVerification>(metadata = ListDetailPage()) { route ->- EmailVerificationScreen(- customerId = route.customerId,- token = route.token,- onDone = { backStack.pop() },- )- }-}
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/NavigationEntries.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/NavigationEntries.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/NavigationEntries.ktnew file mode 100644index 0000000000..ad4e5f11f7--- /dev/null+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/NavigationEntries.kt@@ -0,0 +1,68 @@+package com.vayunmathur.fooddelivery.ui++import com.vayunmathur.fooddelivery.Route+import com.vayunmathur.fooddelivery.data.CartItem+import com.vayunmathur.fooddelivery.data.CartStore+import com.vayunmathur.fooddelivery.platform.canAddFromSameMerchant+import com.vayunmathur.library.util.EntryProviderScope+import com.vayunmathur.library.util.ListDetailPage+import com.vayunmathur.library.util.MorphPage+import com.vayunmathur.library.util.NavBackStack++/**+ * The five bottom-nav tabs as sibling routes (see the route-backed+ * [TabbedPagerScaffold] overload). Selecting a tab resets the back stack to+ * that tab's route; each tab entry renders this scaffold with its own screen+ * as [content], so detail routes (Restaurant, Checkout, OrderTracking) pushed+ * over a tab keep the tab as their list pane on wide layouts. Per-tab+ * `rememberSaveable` state lives in each route's navigation entry.+ */++/** The pushed (non-tab) destinations: restaurant, checkout, tracking, verification. */+internal fun EntryProviderScope<Route>.detailEntries(+ backStack: NavBackStack<Route>,+ cart: androidx.compose.runtime.snapshots.SnapshotStateList<CartItem>,+ context: android.content.Context,+ onPendingCartItem: (CartItem) -> Unit,+) {+ entry<Route.Restaurant>(metadata = ListDetailPage() + MorphPage()) { route ->+ RestaurantScreen(+ merchantId = route.id,+ onBack = { backStack.pop() },+ onAddToCart = { item ->+ if (cart.canAddFromSameMerchant(item)) {+ cart.add(item)+ CartStore.save(context, cart)+ } else {+ onPendingCartItem(item)+ }+ },+ )+ }+ // Checkout is a flow step, not a detail of the tab list.+ entry<Route.Checkout>(metadata = ListDetailPage()) {+ CheckoutScreen(+ items = cart,+ onBack = { backStack.pop() },+ onOrderPlaced = {+ backStack.reset(Route.Orders)+ },+ onOrderCompleted = {+ cart.clear()+ CartStore.clear(context)+ },+ )+ }+ // The brief keeps order-tracking full-screen custom; metadata still marks it a detail+ // so medium widths show it two-pane instead of covering the list.+ entry<Route.OrderTracking>(metadata = ListDetailPage() + MorphPage()) { route ->+ OrderTrackingScreen(orderId = route.orderId, onBack = { backStack.pop() })+ }+ entry<Route.EmailVerification>(metadata = ListDetailPage()) { route ->+ EmailVerificationScreen(+ customerId = route.customerId,+ token = route.token,+ onDone = { backStack.pop() },+ )+ }+}