fooddelivery: fix all lint findings
- Commit
6c72253aa83a1efbee7f49fe029e433b334d29fa- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-17 05:04 UTC (19 days ago)
- Parents
2a3ca9c
Fix every lint warning reported for the fooddelivery module's own sources by :fooddelivery:lintDev, now 0 errors / 0 warnings for fooddelivery/** (remaining report entries are transitive library findings owned by other clusters).
PackageStructure: api/ moved to network/ (7 files + test sources), ipc/OrderLookupContract to intents/, and MainActivity.kt now holds only MainActivity — Route to Route.kt, the nav graph to Navigation.kt, FoodDeliveryApp/PendingCartDialog/FoodDeliveryTabs to ui/, navigation helpers to platform/NavigationHelpers.kt, deep-link extensions to platform/DeepLinks.kt. RawScaffoldInApp (6): the account/cart/deals/home/orders/restaurant screens use AppScaffold(topBar = {}) with identical chrome and padding passthrough. OneComposablePerFile: HomeContent and RestaurantContent split into own files (rewritten whole after the scripted split truncated them on default-param lambdas; MerchantCard and FILTER_DEBOUNCE_MS widened to internal). ExtraTranslation: deleted 15 locale-only orphans (action_cancel, email, call across nine locales). PluralsCandidate: deal_progress is a real plurals resource (default + et + sv) read with pluralStringResource. Two AutoboxingStateCreation hints fixed with mutableIntStateOf.
No @SuppressLint added; no lint config or baseline changed.
Verified: ./gradlew :fooddelivery:lintDev (0 own-module errors/warnings) and :fooddelivery:testDevUnitTest green.Diff
fooddelivery/src/androidTest/java/com/vayunmathur/fooddelivery/FoodDeliveryDeviceTest.kt
diff --git a/fooddelivery/src/androidTest/java/com/vayunmathur/fooddelivery/FoodDeliveryDeviceTest.kt b/fooddelivery/src/androidTest/java/com/vayunmathur/fooddelivery/FoodDeliveryDeviceTest.ktindex 87b8032fbf..1634cb3a83 100644--- a/fooddelivery/src/androidTest/java/com/vayunmathur/fooddelivery/FoodDeliveryDeviceTest.kt+++ b/fooddelivery/src/androidTest/java/com/vayunmathur/fooddelivery/FoodDeliveryDeviceTest.kt@@ -9,7 +9,7 @@ import android.os.Looper import android.os.ResultReceiver import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.platform.app.InstrumentationRegistry-import com.vayunmathur.fooddelivery.api.BitesCore+import com.vayunmathur.fooddelivery.network.BitesCore import com.vayunmathur.fooddelivery.intents.OrderLookupIntent import com.vayunmathur.fooddelivery.platform.AppInit import com.vayunmathur.library.network.SimpleResponse
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/MainActivity.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/MainActivity.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/MainActivity.ktindex cc4cf20977..ad8eb0c809 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/MainActivity.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/MainActivity.kt@@ -6,108 +6,16 @@ import android.content.pm.PackageManager import android.os.Build import androidx.activity.result.contract.ActivityResultContracts import androidx.compose.runtime.Composable-import androidx.compose.runtime.LaunchedEffect-import androidx.compose.runtime.MutableState-import androidx.compose.runtime.getValue-import androidx.compose.runtime.mutableStateListOf import androidx.compose.runtime.mutableStateOf-import androidx.compose.runtime.remember-import androidx.compose.runtime.setValue-import androidx.compose.ui.platform.LocalContext import androidx.core.content.ContextCompat import com.stripe.android.PaymentConfiguration import com.vayunmathur.fooddelivery.platform.AppInit+import com.vayunmathur.fooddelivery.platform.emailVerificationOrNull+import com.vayunmathur.fooddelivery.platform.isCheckoutDeepLink+import com.vayunmathur.fooddelivery.platform.restaurantIdOrNull+import com.vayunmathur.fooddelivery.platform.trackOrderIdOrNull+import com.vayunmathur.fooddelivery.ui.FoodDeliveryApp import com.vayunmathur.library.ui.MaActivity-import com.vayunmathur.library.ui.IconHome-import com.vayunmathur.library.ui.IconLocalOffer-import com.vayunmathur.library.ui.IconPackage-import com.vayunmathur.library.ui.IconPerson-import com.vayunmathur.library.ui.IconShoppingCart-import com.vayunmathur.library.ui.AlertDialog-import com.vayunmathur.library.ui.Button-import com.vayunmathur.library.ui.RouteTab-import com.vayunmathur.library.ui.TabbedPagerScaffold-import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.TextButton-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.NavKey-import com.vayunmathur.library.util.SiblingPage-import com.vayunmathur.library.util.rememberNavBackStack-import com.vayunmathur.fooddelivery.data.CartItem-import com.vayunmathur.fooddelivery.data.CartStore-import com.vayunmathur.fooddelivery.ipc.OrderLookupContract-import com.vayunmathur.fooddelivery.notifications.OrderLiveUpdate-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.HomeScreen-import com.vayunmathur.fooddelivery.ui.OrderTrackingScreen-import com.vayunmathur.fooddelivery.ui.OrdersScreen-import com.vayunmathur.fooddelivery.ui.RestaurantScreen-import kotlinx.serialization.Serializable--/**- * Re-tapping into the same destination class replaces the detail instead of stacking it.- *- * On a two-pane layout the list stays visible under its detail, so tapping a second- * restaurant (or order) would otherwise pile Restaurant on Restaurant; back would then- * step through stale details instead of leaving.- */-internal fun NavBackStack<Route>.pushDetail(route: Route) {- if (backStack.isNotEmpty() && last()::class == route::class) setLast(route) else add(route)-}--/**- * Checkout posts every cart line to a single merchant's endpoint- * (`/merchants/{id}/checkout`, keyed off the first line's merchant), so a cart may- * only ever hold one merchant's items. A line with no merchant (0) carries no- * evidence against the cart's merchant and is allowed through.- */-internal fun List<CartItem>.canAddFromSameMerchant(item: CartItem): Boolean {- val cartMerchant = firstOrNull()?.merchantId ?: return true- return cartMerchant == 0 || item.merchantId == 0 || cartMerchant == item.merchantId-}--/** Navigation destinations for browsing, checkout, order tracking, and email verification. */-sealed interface Route : NavKey {- /** The Home tab (restaurant browse). Sibling of the other tab routes. */- @Serializable data object Home : Route- /** The Cart tab. Sibling of the other tab routes. */- @Serializable data object Cart : Route- /** The Deals tab. Sibling of the other tab routes. */- @Serializable data object Deals : Route- /** The Orders tab. Sibling of the other tab routes. */- @Serializable data object Orders : Route- /** The Account tab. Sibling of the other tab routes. */- @Serializable data object Account : Route- /** The menu page for the restaurant identified by [id]. */- @Serializable data class Restaurant(val id: Int) : Route- /** The checkout flow for the current cart. */- @Serializable data object Checkout : Route- /** Live tracking for the order identified by [orderId]. */- @Serializable data class OrderTracking(val orderId: Int) : Route- /** Email-verification screen for [customerId] carrying its verification [token]. */- @Serializable data class EmailVerification(val customerId: String, val token: String) : Route-}--/**- * The tab route for a legacy `initialTab` index (0=Home, 1=Cart, 2=Deals,- * 3=Orders, 4=Account), coerced into range. Tabs are sibling routes now, so- * an initial tab is simply the back stack's start route.- */-internal fun tabRouteFor(initialTab: Int): Route = when (initialTab.coerceIn(0, 4)) {- 0 -> Route.Home- 1 -> Route.Cart- 2 -> Route.Deals- 3 -> Route.Orders- else -> Route.Account-} /** Entry activity that initialises Stripe and app state and routes notification and deep-link intents into the UI. */ class MainActivity : MaActivity() {@@ -174,258 +82,3 @@ class MainActivity : MaActivity() { if (!granted) requestNotificationPermission.launch(Manifest.permission.POST_NOTIFICATIONS) } }--private fun Intent.trackOrderIdOrNull(): Int? =- getIntExtra(OrderLiveUpdate.EXTRA_TRACK_ORDER_ID, -1).takeIf { it > 0 }--// fooddelivery://restaurant/<id> — the cross-app "open this restaurant's order-// page" deep link (see OrderLookupContract). Returns null for anything else.-private fun Intent.restaurantIdOrNull(): Int? {- val uri = data ?: return null- if (uri.scheme != OrderLookupContract.DEEP_LINK_SCHEME) return null- if (uri.host != OrderLookupContract.DEEP_LINK_HOST) return null- return uri.lastPathSegment?.toIntOrNull()?.takeIf { it > 0 }-}--// fooddelivery://checkout — opens Route.Checkout for the current cart (the-// assistant's order handoff; payment still happens in-app via Stripe).-internal fun Intent.isCheckoutDeepLink(): Boolean {- val uri = data ?: return false- return uri.scheme == OrderLookupContract.DEEP_LINK_SCHEME &&- uri.host == OrderLookupContract.DEEP_LINK_CHECKOUT_HOST-}--private const val EMAIL_VERIFICATION = "email-verification"--// Both segments end up in an API path, so only plain id characters are let through.-private val LINK_SEGMENT = Regex("[A-Za-z0-9_-]{1,256}")--/**- * com.deliverycollective.storefront://email-verification/<customerId>/<token> or- * https://withbites.com/email-verification/<customerId>/<token> — the same two forms the- * official Bites app handles. Returns null for anything else.- */-private fun Intent.emailVerificationOrNull(): Route.EmailVerification? {- val uri = data ?: return null- val segments = when {- uri.scheme == "com.deliverycollective.storefront" && uri.host == EMAIL_VERIFICATION ->- uri.pathSegments- uri.scheme == "https" && uri.pathSegments.firstOrNull() == EMAIL_VERIFICATION ->- uri.pathSegments.drop(1)- else -> return null- }- if (segments.size != 2 || !segments.all { LINK_SEGMENT.matches(it) }) return null- return Route.EmailVerification(customerId = segments[0], token = segments[1])-}--@Composable-private fun FoodDeliveryApp(- trackOrderId: MutableState<Int?>,- openRestaurantId: MutableState<Int?>,- openCheckout: MutableState<Boolean>,- verifyEmail: MutableState<Route.EmailVerification?>,-) {- val context = LocalContext.current- val backStack = rememberNavBackStack<Route>(Route.Home)-- // A notification tap deep-links to that order's tracking screen.- LaunchedEffect(trackOrderId.value) {- val id = trackOrderId.value ?: return@LaunchedEffect- backStack.add(Route.OrderTracking(id))- trackOrderId.value = null- }-- // A fooddelivery://restaurant/<id> deep link opens that restaurant's page.- LaunchedEffect(openRestaurantId.value) {- val id = openRestaurantId.value ?: return@LaunchedEffect- backStack.add(Route.Restaurant(id))- openRestaurantId.value = null- }-- // A fooddelivery://checkout deep link opens checkout for the current cart.- LaunchedEffect(openCheckout.value) {- if (!openCheckout.value) return@LaunchedEffect- backStack.add(Route.Checkout)- openCheckout.value = false- }-- LaunchedEffect(verifyEmail.value) {- val route = verifyEmail.value ?: return@LaunchedEffect- backStack.add(route)- verifyEmail.value = null- }- // Restoring the cart is a prefs read plus a JSON decode, so it happens off the main- // thread rather than in the remember initialiser. Anything added while the read was in- // flight stays in the cart, and is re-persisted alongside the restored lines.- val cart = remember { mutableStateListOf<CartItem>() }- // An item from a second restaurant, held until the user decides whether it- // replaces the cart they already have (checkout can only order from one).- var pendingCartItem by remember { mutableStateOf<CartItem?>(null) }- pendingCartItem?.let { pending ->- PendingCartDialog(- cart = cart,- pending = pending,- onDismiss = { pendingCartItem = null },- onConfirm = {- cart.clear()- cart.add(pending)- CartStore.save(context, cart)- pendingCartItem = null- },- )- }- LaunchedEffect(Unit) {- val saved = CartStore.getAll(context)- if (saved.isEmpty()) return@LaunchedEffect- val addedMeanwhile = cart.isNotEmpty()- cart.addAll(0, saved)- if (addedMeanwhile) CartStore.save(context, cart)- }-- FoodDeliveryNavigation(- backStack = backStack,- cart = cart,- onPendingCartItem = { pendingCartItem = it },- )--}--@Composable-private fun PendingCartDialog(- cart: androidx.compose.runtime.snapshots.SnapshotStateList<CartItem>,- pending: CartItem,- onDismiss: () -> Unit,- onConfirm: () -> Unit,-) {- val currentName = cart.firstOrNull()?.merchantName?.ifBlank { "another restaurant" }- ?: "another restaurant"- val newName = pending.merchantName.ifBlank { "a different restaurant" }- AlertDialog(- onDismissRequest = onDismiss,- title = { Text("Start a new cart?") },- text = {- Text(- "Your cart has items from $currentName. Ordering is from one " +- "restaurant at a time, so adding from $newName will clear it."- )- },- confirmButton = {- Button(onClick = onConfirm) { Text("Start new cart") }- },- dismissButton = {- TextButton(onClick = onDismiss) { Text("Keep my cart") }- },- )-}--@Composable-private fun FoodDeliveryNavigation(- backStack: NavBackStack<Route>,- cart: androidx.compose.runtime.snapshots.SnapshotStateList<CartItem>,- onPendingCartItem: (CartItem) -> Unit,-) {- val context = LocalContext.current- MainNavigation(backStack) {- entry<Route.Home>(metadata = ListPage() + SiblingPage()) {- FoodDeliveryTabs(backStack) {- HomeScreen(onMerchantClick = { id -> backStack.pushDetail(Route.Restaurant(id)) })- }- }- entry<Route.Cart>(metadata = ListPage() + SiblingPage()) {- FoodDeliveryTabs(backStack) {- CartScreen(- items = cart,- onRemoveItem = {- cart.removeAt(it)- CartStore.save(context, cart)- },- onCheckout = { backStack.add(Route.Checkout) },- onEditModifiers = { index, modifiers ->- cart[index] = cart[index].copy(selectedModifiers = modifiers)- CartStore.save(context, cart)- },- )- }- }- entry<Route.Deals>(metadata = ListPage() + SiblingPage()) {- FoodDeliveryTabs(backStack) {- DealsScreen(onMerchantClick = { id -> backStack.pushDetail(Route.Restaurant(id)) })- }- }- entry<Route.Orders>(metadata = ListPage() + SiblingPage()) {- FoodDeliveryTabs(backStack) {- OrdersScreen(onTrackOrder = { id -> backStack.pushDetail(Route.OrderTracking(id)) })- }- }- entry<Route.Account>(metadata = ListPage() + SiblingPage()) {- FoodDeliveryTabs(backStack) {- AccountScreen()- }- }- 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() },- )- }- }-}--/**- * 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.- */-@Composable-private fun FoodDeliveryTabs(- backStack: NavBackStack<Route>,- content: @Composable () -> Unit,-) {- val tabs = remember {- listOf<RouteTab<Route>>(- RouteTab(Route.Home, "Home", { IconHome() }),- RouteTab(Route.Cart, "Cart", { IconShoppingCart() }),- RouteTab(Route.Deals, "Deals", { IconLocalOffer() }),- RouteTab(Route.Orders, "Orders", { IconPackage() }),- RouteTab(Route.Account, "Account", { IconPerson() }),- )- }- TabbedPagerScaffold(backStack = backStack, tabs = tabs) { content() }-}
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.ktnew file mode 100644index 0000000000..b70d72846e--- /dev/null+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/Navigation.kt@@ -0,0 +1,120 @@+package com.vayunmathur.fooddelivery++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.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++@Composable+fun Navigation(+ backStack: NavBackStack<Route>,+ cart: androidx.compose.runtime.snapshots.SnapshotStateList<CartItem>,+ onPendingCartItem: (CartItem) -> Unit,+) {+ val context = LocalContext.current+ MainNavigation(backStack) {+ entry<Route.Home>(metadata = ListPage() + SiblingPage()) {+ FoodDeliveryTabs(backStack) {+ HomeScreen(onMerchantClick = { id -> backStack.pushDetail(Route.Restaurant(id)) })+ }+ }+ entry<Route.Cart>(metadata = ListPage() + SiblingPage()) {+ FoodDeliveryTabs(backStack) {+ CartScreen(+ items = cart,+ onRemoveItem = {+ cart.removeAt(it)+ CartStore.save(context, cart)+ },+ onCheckout = { backStack.add(Route.Checkout) },+ onEditModifiers = { index, modifiers ->+ cart[index] = cart[index].copy(selectedModifiers = modifiers)+ CartStore.save(context, cart)+ },+ )+ }+ }+ entry<Route.Deals>(metadata = ListPage() + SiblingPage()) {+ FoodDeliveryTabs(backStack) {+ DealsScreen(onMerchantClick = { id -> backStack.pushDetail(Route.Restaurant(id)) })+ }+ }+ entry<Route.Orders>(metadata = ListPage() + SiblingPage()) {+ FoodDeliveryTabs(backStack) {+ OrdersScreen(onTrackOrder = { id -> backStack.pushDetail(Route.OrderTracking(id)) })+ }+ }+ entry<Route.Account>(metadata = ListPage() + SiblingPage()) {+ FoodDeliveryTabs(backStack) {+ AccountScreen()+ }+ }+ 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() },+ )+ }+ }+}++/**+ * 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.+ */
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/Route.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/Route.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/Route.ktnew file mode 100644index 0000000000..d0f20488eb--- /dev/null+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/Route.kt@@ -0,0 +1,26 @@+package com.vayunmathur.fooddelivery++import com.vayunmathur.library.util.NavKey+import kotlinx.serialization.Serializable++/** Navigation destinations for browsing, checkout, order tracking, and email verification. */+sealed interface Route : NavKey {+ /** The Home tab (restaurant browse). Sibling of the other tab routes. */+ @Serializable data object Home : Route+ /** The Cart tab. Sibling of the other tab routes. */+ @Serializable data object Cart : Route+ /** The Deals tab. Sibling of the other tab routes. */+ @Serializable data object Deals : Route+ /** The Orders tab. Sibling of the other tab routes. */+ @Serializable data object Orders : Route+ /** The Account tab. Sibling of the other tab routes. */+ @Serializable data object Account : Route+ /** The menu page for the restaurant identified by [id]. */+ @Serializable data class Restaurant(val id: Int) : Route+ /** The checkout flow for the current cart. */+ @Serializable data object Checkout : Route+ /** Live tracking for the order identified by [orderId]. */+ @Serializable data class OrderTracking(val orderId: Int) : Route+ /** Email-verification screen for [customerId] carrying its verification [token]. */+ @Serializable data class EmailVerification(val customerId: String, val token: String) : Route+}
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/intents/FoodAssistantBackend.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/intents/FoodAssistantBackend.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/intents/FoodAssistantBackend.ktindex e8bea45773..1c6f1d81e2 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/intents/FoodAssistantBackend.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/intents/FoodAssistantBackend.kt@@ -1,8 +1,8 @@ package com.vayunmathur.fooddelivery.intents import android.content.Context-import com.vayunmathur.fooddelivery.api.BitesMerchants-import com.vayunmathur.fooddelivery.api.BitesOrders+import com.vayunmathur.fooddelivery.network.BitesMerchants+import com.vayunmathur.fooddelivery.network.BitesOrders import com.vayunmathur.fooddelivery.data.AddressStore import com.vayunmathur.fooddelivery.data.CartItem import com.vayunmathur.fooddelivery.data.CartStore
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/intents/OrderLookupContract.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ipc/OrderLookupContract.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/intents/OrderLookupContract.ktsimilarity index 96%rename from fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ipc/OrderLookupContract.ktrename to fooddelivery/src/main/java/com/vayunmathur/fooddelivery/intents/OrderLookupContract.ktindex ef6377bf15..c791ba97e4 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ipc/OrderLookupContract.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/intents/OrderLookupContract.kt@@ -1,4 +1,4 @@-package com.vayunmathur.fooddelivery.ipc+package com.vayunmathur.fooddelivery.intents /** * Wire contract for the `fooddelivery://restaurant/<id>` cross-app deep link that opens a specific
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/intents/OrderLookupIntent.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/intents/OrderLookupIntent.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/intents/OrderLookupIntent.ktindex 85de27543e..8cbd20e932 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/intents/OrderLookupIntent.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/intents/OrderLookupIntent.kt@@ -1,8 +1,8 @@ package com.vayunmathur.fooddelivery.intents -import com.vayunmathur.fooddelivery.api.BitesMerchants+import com.vayunmathur.fooddelivery.network.BitesMerchants import com.vayunmathur.fooddelivery.data.Merchant-import com.vayunmathur.fooddelivery.ipc.OrderLookupContract+import com.vayunmathur.fooddelivery.intents.OrderLookupContract import com.vayunmathur.fooddelivery.platform.AppInit import com.vayunmathur.library.intents.fooddelivery.OrderLookupRequest import com.vayunmathur.library.intents.fooddelivery.OrderLookupResult
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesAuth.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/api/BitesAuth.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesAuth.ktsimilarity index 98%rename from fooddelivery/src/main/java/com/vayunmathur/fooddelivery/api/BitesAuth.ktrename to fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesAuth.ktindex 81152ac08b..687f438845 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/api/BitesAuth.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesAuth.kt@@ -1,4 +1,4 @@-package com.vayunmathur.fooddelivery.api+package com.vayunmathur.fooddelivery.network import com.vayunmathur.library.log.Log import com.vayunmathur.fooddelivery.data.AuthToken
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesCore.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/api/BitesCore.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesCore.ktsimilarity index 99%rename from fooddelivery/src/main/java/com/vayunmathur/fooddelivery/api/BitesCore.ktrename to fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesCore.ktindex fbc0937110..96a1312c5a 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/api/BitesCore.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesCore.kt@@ -1,4 +1,4 @@-package com.vayunmathur.fooddelivery.api+package com.vayunmathur.fooddelivery.network import com.vayunmathur.library.log.Log import com.vayunmathur.fooddelivery.BuildConfig
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesCustomers.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/api/BitesCustomers.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesCustomers.ktsimilarity index 99%rename from fooddelivery/src/main/java/com/vayunmathur/fooddelivery/api/BitesCustomers.ktrename to fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesCustomers.ktindex e67932b2c0..3c07afbb5a 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/api/BitesCustomers.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesCustomers.kt@@ -1,4 +1,4 @@-package com.vayunmathur.fooddelivery.api+package com.vayunmathur.fooddelivery.network import com.vayunmathur.library.log.Log import com.vayunmathur.fooddelivery.data.Customer
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesDeals.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/api/BitesDeals.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesDeals.ktsimilarity index 98%rename from fooddelivery/src/main/java/com/vayunmathur/fooddelivery/api/BitesDeals.ktrename to fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesDeals.ktindex eff2cce38d..0d14acc1ab 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/api/BitesDeals.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesDeals.kt@@ -1,4 +1,4 @@-package com.vayunmathur.fooddelivery.api+package com.vayunmathur.fooddelivery.network import com.vayunmathur.fooddelivery.data.Deal import com.vayunmathur.fooddelivery.data.DealProgress
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesMerchants.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/api/BitesMerchants.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesMerchants.ktsimilarity index 98%rename from fooddelivery/src/main/java/com/vayunmathur/fooddelivery/api/BitesMerchants.ktrename to fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesMerchants.ktindex b172313e22..8e47712d0f 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/api/BitesMerchants.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesMerchants.kt@@ -1,4 +1,4 @@-package com.vayunmathur.fooddelivery.api+package com.vayunmathur.fooddelivery.network import com.vayunmathur.library.log.Log import com.vayunmathur.fooddelivery.data.CheckoutAddress
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesOrders.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/api/BitesOrders.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesOrders.ktsimilarity index 99%rename from fooddelivery/src/main/java/com/vayunmathur/fooddelivery/api/BitesOrders.ktrename to fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesOrders.ktindex 09fdd9c2a2..8008174701 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/api/BitesOrders.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesOrders.kt@@ -1,4 +1,4 @@-package com.vayunmathur.fooddelivery.api+package com.vayunmathur.fooddelivery.network import com.vayunmathur.library.log.Log import com.vayunmathur.fooddelivery.data.CheckoutRequest
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesRewards.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/api/BitesRewards.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesRewards.ktsimilarity index 96%rename from fooddelivery/src/main/java/com/vayunmathur/fooddelivery/api/BitesRewards.ktrename to fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesRewards.ktindex a3b7f94c88..c06b412ab2 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/api/BitesRewards.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/network/BitesRewards.kt@@ -1,4 +1,4 @@-package com.vayunmathur.fooddelivery.api+package com.vayunmathur.fooddelivery.network import com.vayunmathur.fooddelivery.data.MerchantRewards import com.vayunmathur.fooddelivery.data.PlatformSavings
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/notifications/OrderTrackingService.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/notifications/OrderTrackingService.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/notifications/OrderTrackingService.ktindex 71cdd8f869..8c43af9518 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/notifications/OrderTrackingService.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/notifications/OrderTrackingService.kt@@ -9,7 +9,7 @@ import android.os.Build import android.os.IBinder import com.vayunmathur.library.log.Log import androidx.core.app.NotificationManagerCompat-import com.vayunmathur.fooddelivery.api.BitesOrders+import com.vayunmathur.fooddelivery.network.BitesOrders import com.vayunmathur.fooddelivery.data.Order import com.vayunmathur.fooddelivery.platform.AppInit import kotlinx.coroutines.CoroutineScope
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/platform/AppInit.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/platform/AppInit.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/platform/AppInit.ktindex 7f0f90b7bc..e382c530d5 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/platform/AppInit.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/platform/AppInit.kt@@ -5,7 +5,7 @@ import com.vayunmathur.fooddelivery.data.RemoteImageFetchers import com.vayunmathur.library.image.ImageLoader import com.vayunmathur.library.log.Log import androidx.core.content.edit-import com.vayunmathur.fooddelivery.api.BitesAuth+import com.vayunmathur.fooddelivery.network.BitesAuth import com.vayunmathur.library.network.NetworkClient import com.vayunmathur.library.network.TrustBundle import kotlinx.coroutines.CompletableDeferred
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/platform/DeepLinks.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/platform/DeepLinks.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/platform/DeepLinks.ktnew file mode 100644index 0000000000..6ba90efd2d--- /dev/null+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/platform/DeepLinks.kt@@ -0,0 +1,49 @@+package com.vayunmathur.fooddelivery.platform++import android.content.Intent+import com.vayunmathur.fooddelivery.Route+import com.vayunmathur.fooddelivery.intents.OrderLookupContract+import com.vayunmathur.fooddelivery.notifications.OrderLiveUpdate++internal fun Intent.trackOrderIdOrNull(): Int? =+ getIntExtra(OrderLiveUpdate.EXTRA_TRACK_ORDER_ID, -1).takeIf { it > 0 }++// fooddelivery://restaurant/<id> — the cross-app "open this restaurant's order+// page" deep link (see OrderLookupContract). Returns null for anything else.+internal fun Intent.restaurantIdOrNull(): Int? {+ val uri = data ?: return null+ if (uri.scheme != OrderLookupContract.DEEP_LINK_SCHEME) return null+ if (uri.host != OrderLookupContract.DEEP_LINK_HOST) return null+ return uri.lastPathSegment?.toIntOrNull()?.takeIf { it > 0 }+}++// fooddelivery://checkout — opens Route.Checkout for the current cart (the+// assistant's order handoff; payment still happens in-app via Stripe).+internal fun Intent.isCheckoutDeepLink(): Boolean {+ val uri = data ?: return false+ return uri.scheme == OrderLookupContract.DEEP_LINK_SCHEME &&+ uri.host == OrderLookupContract.DEEP_LINK_CHECKOUT_HOST+}++private const val EMAIL_VERIFICATION = "email-verification"++// Both segments end up in an API path, so only plain id characters are let through.+private val LINK_SEGMENT = Regex("[A-Za-z0-9_-]{1,256}")++/**+ * com.deliverycollective.storefront://email-verification/<customerId>/<token> or+ * https://withbites.com/email-verification/<customerId>/<token> — the same two forms the+ * official Bites app handles. Returns null for anything else.+ */+internal fun Intent.emailVerificationOrNull(): Route.EmailVerification? {+ val uri = data ?: return null+ val segments = when {+ uri.scheme == "com.deliverycollective.storefront" && uri.host == EMAIL_VERIFICATION ->+ uri.pathSegments+ uri.scheme == "https" && uri.pathSegments.firstOrNull() == EMAIL_VERIFICATION ->+ uri.pathSegments.drop(1)+ else -> return null+ }+ if (segments.size != 2 || !segments.all { LINK_SEGMENT.matches(it) }) return null+ return Route.EmailVerification(customerId = segments[0], token = segments[1])+}
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/platform/NavigationHelpers.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/platform/NavigationHelpers.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/platform/NavigationHelpers.ktnew file mode 100644index 0000000000..769d964e4e--- /dev/null+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/platform/NavigationHelpers.kt@@ -0,0 +1,41 @@+package com.vayunmathur.fooddelivery.platform++import com.vayunmathur.fooddelivery.Route+import com.vayunmathur.fooddelivery.data.CartItem+import com.vayunmathur.library.util.NavBackStack++/**+ * Re-tapping into the same destination class replaces the detail instead of stacking it.+ *+ * On a two-pane layout the list stays visible under its detail, so tapping a second+ * restaurant (or order) would otherwise pile Restaurant on Restaurant; back would then+ * step through stale details instead of leaving.+ */+internal fun NavBackStack<Route>.pushDetail(route: Route) {+ if (backStack.isNotEmpty() && last()::class == route::class) setLast(route) else add(route)+}++/**+ * Checkout posts every cart line to a single merchant's endpoint+ * (`/merchants/{id}/checkout`, keyed off the first line's merchant), so a cart may+ * only ever hold one merchant's items. A line with no merchant (0) carries no+ * evidence against the cart's merchant and is allowed through.+ */+internal fun List<CartItem>.canAddFromSameMerchant(item: CartItem): Boolean {+ val cartMerchant = firstOrNull()?.merchantId ?: return true+ return cartMerchant == 0 || item.merchantId == 0 || cartMerchant == item.merchantId+}+++/**+ * The tab route for a legacy `initialTab` index (0=Home, 1=Cart, 2=Deals,+ * 3=Orders, 4=Account), coerced into range. Tabs are sibling routes now, so+ * an initial tab is simply the back stack's start route.+ */+internal fun tabRouteFor(initialTab: Int): Route = when (initialTab.coerceIn(0, 4)) {+ 0 -> Route.Home+ 1 -> Route.Cart+ 2 -> Route.Deals+ 3 -> Route.Orders+ else -> Route.Account+}
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/AccountScreen.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/AccountScreen.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/AccountScreen.ktindex 3fa9c32ab3..342961243a 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/AccountScreen.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/AccountScreen.kt@@ -28,9 +28,9 @@ import androidx.compose.ui.unit.dp import androidx.core.content.edit import com.vayunmathur.fooddelivery.R import com.vayunmathur.library.ui.R as UiR-import com.vayunmathur.fooddelivery.api.BitesAuth-import com.vayunmathur.fooddelivery.api.BitesCustomers-import com.vayunmathur.fooddelivery.api.BitesRewards+import com.vayunmathur.fooddelivery.network.BitesAuth+import com.vayunmathur.fooddelivery.network.BitesCustomers+import com.vayunmathur.fooddelivery.network.BitesRewards import com.vayunmathur.fooddelivery.data.AddressStore import com.vayunmathur.fooddelivery.data.Customer import com.vayunmathur.fooddelivery.data.CustomerSavings@@ -46,7 +46,7 @@ import com.vayunmathur.library.ui.IconAdd import com.vayunmathur.library.ui.IconButton import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.OutlinedButton-import com.vayunmathur.library.ui.Scaffold+import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.TextButton import androidx.compose.ui.platform.LocalContext@@ -108,7 +108,7 @@ fun AccountScreen() { } } - Scaffold { padding ->+ AppScaffold(topBar = {}) { padding -> Column( Modifier.fillMaxSize().padding(padding) .verticalScroll(rememberScrollState()).padding(16.dp),
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/CartScreen.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/CartScreen.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/CartScreen.ktindex 676fe8a17e..22f3e97869 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/CartScreen.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/CartScreen.kt@@ -33,7 +33,7 @@ import com.vayunmathur.library.ui.IconDelete import com.vayunmathur.library.ui.IconEdit import com.vayunmathur.library.ui.IconShoppingCart import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.Scaffold+import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.Text import com.vayunmathur.fooddelivery.data.CartItem import com.vayunmathur.fooddelivery.data.SelectedModifier@@ -63,7 +63,7 @@ fun CartScreen( } } - Scaffold { padding ->+ AppScaffold(topBar = {}) { padding -> if (items.isEmpty()) { Box(Modifier.fillMaxSize().padding(padding), contentAlignment = Alignment.Center) { Column(horizontalAlignment = Alignment.CenterHorizontally) {
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/CheckoutScreen.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/CheckoutScreen.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/CheckoutScreen.ktindex c79eb17889..ee28fe71a5 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/CheckoutScreen.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/CheckoutScreen.kt@@ -29,9 +29,9 @@ import com.stripe.android.paymentsheet.PaymentSheetResult import com.stripe.android.paymentsheet.rememberPaymentSheet import com.vayunmathur.fooddelivery.BuildConfig import com.vayunmathur.fooddelivery.R-import com.vayunmathur.fooddelivery.api.BitesCustomers-import com.vayunmathur.fooddelivery.api.BitesDeals-import com.vayunmathur.fooddelivery.api.BitesOrders+import com.vayunmathur.fooddelivery.network.BitesCustomers+import com.vayunmathur.fooddelivery.network.BitesDeals+import com.vayunmathur.fooddelivery.network.BitesOrders import com.vayunmathur.fooddelivery.data.AddressStore import com.vayunmathur.fooddelivery.data.CartItem import com.vayunmathur.fooddelivery.data.CheckoutAddress
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/DealsScreen.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/DealsScreen.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/DealsScreen.ktindex 3e574d12b2..483a0b3dfd 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/DealsScreen.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/DealsScreen.kt@@ -25,6 +25,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.layout.ContentScale+import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp@@ -36,11 +37,11 @@ import com.vayunmathur.library.ui.EmptyState import com.vayunmathur.library.ui.IconEmojiEvents import com.vayunmathur.library.ui.LinearProgressIndicator import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.Scaffold+import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.Text import com.vayunmathur.library.util.sharedText import com.vayunmathur.fooddelivery.R-import com.vayunmathur.fooddelivery.api.BitesDeals+import com.vayunmathur.fooddelivery.network.BitesDeals import com.vayunmathur.fooddelivery.data.Deal import com.vayunmathur.fooddelivery.data.DealProgress import com.vayunmathur.fooddelivery.platform.AppInit@@ -77,7 +78,7 @@ fun DealsScreen(onMerchantClick: (Int) -> Unit) { } } - Scaffold { padding ->+ AppScaffold(topBar = {}) { padding -> when { loading -> Box( Modifier.fillMaxSize().padding(padding),@@ -166,7 +167,7 @@ private fun DealCard(deal: Deal, progress: DealProgress?, onClick: () -> Unit) { Spacer(Modifier.height(4.dp)) Text( if (p.isUnlocked(needed)) stringResource(R.string.deal_unlocked)- else stringResource(R.string.deal_progress, p.ordersCount, needed),+ else pluralStringResource(R.plurals.deal_progress, needed, p.ordersCount, needed), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, )
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/EmailVerificationScreen.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/EmailVerificationScreen.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/EmailVerificationScreen.ktindex f3564e6c94..cea287295d 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/EmailVerificationScreen.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/EmailVerificationScreen.kt@@ -20,7 +20,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import com.vayunmathur.fooddelivery.R-import com.vayunmathur.fooddelivery.api.BitesCustomers+import com.vayunmathur.fooddelivery.network.BitesCustomers import com.vayunmathur.fooddelivery.platform.AppInit import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.Button
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/FoodDeliveryApp.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/FoodDeliveryApp.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/FoodDeliveryApp.ktnew file mode 100644index 0000000000..a2ffbfa2b6--- /dev/null+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/FoodDeliveryApp.kt@@ -0,0 +1,122 @@+package com.vayunmathur.fooddelivery.ui++import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.MutableState+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateListOf+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.runtime.snapshots.SnapshotStateList+import androidx.compose.ui.platform.LocalContext+import com.vayunmathur.fooddelivery.Navigation+import com.vayunmathur.fooddelivery.Route+import com.vayunmathur.fooddelivery.data.CartItem+import com.vayunmathur.fooddelivery.data.CartStore+import com.vayunmathur.library.ui.AlertDialog+import com.vayunmathur.library.ui.Button+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton+import com.vayunmathur.library.util.rememberNavBackStack++@Composable+internal fun FoodDeliveryApp(+ trackOrderId: MutableState<Int?>,+ openRestaurantId: MutableState<Int?>,+ openCheckout: MutableState<Boolean>,+ verifyEmail: MutableState<Route.EmailVerification?>,+) {+ val context = LocalContext.current+ val backStack = rememberNavBackStack<Route>(Route.Home)++ // A notification tap deep-links to that order's tracking screen.+ LaunchedEffect(trackOrderId.value) {+ val id = trackOrderId.value ?: return@LaunchedEffect+ backStack.add(Route.OrderTracking(id))+ trackOrderId.value = null+ }++ // A fooddelivery://restaurant/<id> deep link opens that restaurant's page.+ LaunchedEffect(openRestaurantId.value) {+ val id = openRestaurantId.value ?: return@LaunchedEffect+ backStack.add(Route.Restaurant(id))+ openRestaurantId.value = null+ }++ // A fooddelivery://checkout deep link opens checkout for the current cart.+ LaunchedEffect(openCheckout.value) {+ if (!openCheckout.value) return@LaunchedEffect+ backStack.add(Route.Checkout)+ openCheckout.value = false+ }++ LaunchedEffect(verifyEmail.value) {+ val route = verifyEmail.value ?: return@LaunchedEffect+ backStack.add(route)+ verifyEmail.value = null+ }+ // Restoring the cart is a prefs read plus a JSON decode, so it happens off the main+ // thread rather than in the remember initialiser. Anything added while the read was in+ // flight stays in the cart, and is re-persisted alongside the restored lines.+ val cart = remember { mutableStateListOf<CartItem>() }+ // An item from a second restaurant, held until the user decides whether it+ // replaces the cart they already have (checkout can only order from one).+ var pendingCartItem by remember { mutableStateOf<CartItem?>(null) }+ pendingCartItem?.let { pending ->+ PendingCartDialog(+ cart = cart,+ pending = pending,+ onDismiss = { pendingCartItem = null },+ onConfirm = {+ cart.clear()+ cart.add(pending)+ CartStore.save(context, cart)+ pendingCartItem = null+ },+ )+ }+ LaunchedEffect(Unit) {+ val saved = CartStore.getAll(context)+ if (saved.isEmpty()) return@LaunchedEffect+ val addedMeanwhile = cart.isNotEmpty()+ cart.addAll(0, saved)+ if (addedMeanwhile) CartStore.save(context, cart)+ }++ Navigation(+ backStack = backStack,+ cart = cart,+ onPendingCartItem = { pendingCartItem = it },+ )++}+++@Composable+private fun PendingCartDialog(+ cart: androidx.compose.runtime.snapshots.SnapshotStateList<CartItem>,+ pending: CartItem,+ onDismiss: () -> Unit,+ onConfirm: () -> Unit,+) {+ val currentName = cart.firstOrNull()?.merchantName?.ifBlank { "another restaurant" }+ ?: "another restaurant"+ val newName = pending.merchantName.ifBlank { "a different restaurant" }+ AlertDialog(+ onDismissRequest = onDismiss,+ title = { Text("Start a new cart?") },+ text = {+ Text(+ "Your cart has items from $currentName. Ordering is from one " ++ "restaurant at a time, so adding from $newName will clear it."+ )+ },+ confirmButton = {+ Button(onClick = onConfirm) { Text("Start new cart") }+ },+ dismissButton = {+ TextButton(onClick = onDismiss) { Text("Keep my cart") }+ },+ )+}
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/FoodDeliveryTabs.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/FoodDeliveryTabs.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/FoodDeliveryTabs.ktnew file mode 100644index 0000000000..28f73da495--- /dev/null+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/FoodDeliveryTabs.kt@@ -0,0 +1,30 @@+package com.vayunmathur.fooddelivery.ui++import androidx.compose.runtime.Composable+import androidx.compose.runtime.remember+import com.vayunmathur.fooddelivery.Route+import com.vayunmathur.library.ui.IconHome+import com.vayunmathur.library.ui.IconLocalOffer+import com.vayunmathur.library.ui.IconPackage+import com.vayunmathur.library.ui.IconPerson+import com.vayunmathur.library.ui.IconShoppingCart+import com.vayunmathur.library.ui.RouteTab+import com.vayunmathur.library.ui.TabbedPagerScaffold+import com.vayunmathur.library.util.NavBackStack++@Composable+internal fun FoodDeliveryTabs(+ backStack: NavBackStack<Route>,+ content: @Composable () -> Unit,+) {+ val tabs = remember {+ listOf<RouteTab<Route>>(+ RouteTab(Route.Home, "Home", { IconHome() }),+ RouteTab(Route.Cart, "Cart", { IconShoppingCart() }),+ RouteTab(Route.Deals, "Deals", { IconLocalOffer() }),+ RouteTab(Route.Orders, "Orders", { IconPackage() }),+ RouteTab(Route.Account, "Account", { IconPerson() }),+ )+ }+ TabbedPagerScaffold(backStack = backStack, tabs = tabs) { content() }+}
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/HomeContent.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/HomeContent.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/HomeContent.ktnew file mode 100644index 0000000000..1d628a144b--- /dev/null+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/HomeContent.kt@@ -0,0 +1,109 @@+package com.vayunmathur.fooddelivery.ui+import androidx.compose.ui.res.stringResource+import com.vayunmathur.fooddelivery.R+import android.content.Context+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.PaddingValues+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.Spacer+import androidx.compose.foundation.layout.aspectRatio+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.height+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.lazy.grid.GridCells+import androidx.compose.foundation.lazy.grid.LazyVerticalGrid+import androidx.compose.foundation.lazy.grid.items+import androidx.compose.foundation.shape.CircleShape+import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.layout.ContentScale+import androidx.compose.ui.platform.LocalContext+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.unit.dp+import com.vayunmathur.library.image.compose.AsyncImage+import com.vayunmathur.library.ui.Button+import com.vayunmathur.library.ui.Card+import com.vayunmathur.library.ui.CircularProgressIndicator+import com.vayunmathur.library.ui.IconHome+import com.vayunmathur.library.ui.IconStar+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.util.sharedContainer+import com.vayunmathur.library.util.sharedText+import com.vayunmathur.fooddelivery.network.BitesMerchants+import com.vayunmathur.fooddelivery.data.AddressStore+import com.vayunmathur.fooddelivery.data.Merchant+import com.vayunmathur.fooddelivery.platform.AppInit++/**+ * The nearby-restaurant list, with no API call or address lookup of its own so it can be+ * rendered from a `@Preview` — see `src/screenshotTest`, which is where the store listing+ * images come from.+ */+@Composable+fun HomeContent(+ merchants: List<Merchant>,+ loading: Boolean = false,+ noAddress: Boolean = false,+ onMerchantClick: (Int) -> Unit = {},+) {+ AppScaffold(topBar = {}) { padding ->+ if (loading) {+ Box(Modifier.fillMaxSize().padding(padding), contentAlignment = Alignment.Center) {+ CircularProgressIndicator()+ }+ } else if (noAddress) {+ Box(Modifier.fillMaxSize().padding(padding), contentAlignment = Alignment.Center) {+ Column(horizontalAlignment = Alignment.CenterHorizontally) {+ IconHome(modifier = Modifier.size(48.dp),+ tint = MaterialTheme.colorScheme.onSurfaceVariant)+ Spacer(Modifier.height(12.dp))+ Text(stringResource(R.string.set_your_address), style = MaterialTheme.typography.titleMedium)+ Spacer(Modifier.height(4.dp))+ Text(stringResource(R.string.add_an_address_in_account_to_see_nearby),+ style = MaterialTheme.typography.bodyMedium,+ color = MaterialTheme.colorScheme.onSurfaceVariant)+ }+ }+ } else if (merchants.isEmpty()) {+ Box(Modifier.fillMaxSize().padding(padding), contentAlignment = Alignment.Center) {+ Column(horizontalAlignment = Alignment.CenterHorizontally) {+ Text(stringResource(R.string.no_restaurants_found), style = MaterialTheme.typography.titleMedium)+ Spacer(Modifier.height(8.dp))+ Text(stringResource(R.string.check_your_connection_or_try_again_later),+ style = MaterialTheme.typography.bodyMedium,+ color = MaterialTheme.colorScheme.onSurfaceVariant)+ }+ }+ } else {+ LazyVerticalGrid(+ columns = GridCells.Adaptive(minSize = 300.dp),+ contentPadding = PaddingValues(16.dp),+ verticalArrangement = Arrangement.spacedBy(12.dp),+ horizontalArrangement = Arrangement.spacedBy(12.dp),+ modifier = Modifier.padding(padding)+ ) {+ // Deliberately unkeyed: /merchants/all/stores can return several store rows+ // per merchant and Merchant has no id-independent identity, so a key risks the+ // duplicate-key crash. It would buy nothing anyway — `merchants` is assigned+ // once and never replaced while the grid is on screen.+ items(merchants) { merchant ->+ MerchantCard(merchant) { onMerchantClick(merchant.id) }+ }+ }+ }+ }+}
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/HomeScreen.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/HomeScreen.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/HomeScreen.ktindex 87a79d4a8e..214e1099f3 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/HomeScreen.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/HomeScreen.kt@@ -40,11 +40,10 @@ import com.vayunmathur.library.ui.CircularProgressIndicator import com.vayunmathur.library.ui.IconHome import com.vayunmathur.library.ui.IconStar import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.Scaffold import com.vayunmathur.library.ui.Text import com.vayunmathur.library.util.sharedContainer import com.vayunmathur.library.util.sharedText-import com.vayunmathur.fooddelivery.api.BitesMerchants+import com.vayunmathur.fooddelivery.network.BitesMerchants import com.vayunmathur.fooddelivery.data.AddressStore import com.vayunmathur.fooddelivery.data.Merchant import com.vayunmathur.fooddelivery.platform.AppInit@@ -82,68 +81,9 @@ fun HomeScreen(onMerchantClick: (Int) -> Unit) { ) } -/**- * The nearby-restaurant list, with no API call or address lookup of its own so it can be- * rendered from a `@Preview` — see `src/screenshotTest`, which is where the store listing- * images come from.- */-@Composable-fun HomeContent(- merchants: List<Merchant>,- loading: Boolean = false,- noAddress: Boolean = false,- onMerchantClick: (Int) -> Unit = {},-) {- Scaffold { padding ->- if (loading) {- Box(Modifier.fillMaxSize().padding(padding), contentAlignment = Alignment.Center) {- CircularProgressIndicator()- }- } else if (noAddress) {- Box(Modifier.fillMaxSize().padding(padding), contentAlignment = Alignment.Center) {- Column(horizontalAlignment = Alignment.CenterHorizontally) {- IconHome(modifier = Modifier.size(48.dp),- tint = MaterialTheme.colorScheme.onSurfaceVariant)- Spacer(Modifier.height(12.dp))- Text(stringResource(R.string.set_your_address), style = MaterialTheme.typography.titleMedium)- Spacer(Modifier.height(4.dp))- Text(stringResource(R.string.add_an_address_in_account_to_see_nearby),- style = MaterialTheme.typography.bodyMedium,- color = MaterialTheme.colorScheme.onSurfaceVariant)- }- }- } else if (merchants.isEmpty()) {- Box(Modifier.fillMaxSize().padding(padding), contentAlignment = Alignment.Center) {- Column(horizontalAlignment = Alignment.CenterHorizontally) {- Text(stringResource(R.string.no_restaurants_found), style = MaterialTheme.typography.titleMedium)- Spacer(Modifier.height(8.dp))- Text(stringResource(R.string.check_your_connection_or_try_again_later),- style = MaterialTheme.typography.bodyMedium,- color = MaterialTheme.colorScheme.onSurfaceVariant)- }- }- } else {- LazyVerticalGrid(- columns = GridCells.Adaptive(minSize = 300.dp),- contentPadding = PaddingValues(16.dp),- verticalArrangement = Arrangement.spacedBy(12.dp),- horizontalArrangement = Arrangement.spacedBy(12.dp),- modifier = Modifier.padding(padding)- ) {- // Deliberately unkeyed: /merchants/all/stores can return several store rows- // per merchant and Merchant has no id-independent identity, so a key risks the- // duplicate-key crash. It would buy nothing anyway — `merchants` is assigned- // once and never replaced while the grid is on screen.- items(merchants) { merchant ->- MerchantCard(merchant) { onMerchantClick(merchant.id) }- }- }- }- }-} @Composable-private fun MerchantCard(merchant: Merchant, onClick: () -> Unit) {+internal fun MerchantCard(merchant: Merchant, onClick: () -> Unit) { Card(onClick = onClick, modifier = Modifier.fillMaxWidth()) { Column { if (merchant.displayImage.isNotEmpty()) {
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrderTrackingScreen.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrderTrackingScreen.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrderTrackingScreen.ktindex 738498e3c2..b8911e85e3 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrderTrackingScreen.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrderTrackingScreen.kt@@ -58,7 +58,7 @@ import com.vayunmathur.library.util.sharedText import com.vayunmathur.library.log.Log import com.vayunmathur.fooddelivery.R import com.vayunmathur.library.ui.R as UiR-import com.vayunmathur.fooddelivery.api.BitesOrders+import com.vayunmathur.fooddelivery.network.BitesOrders import com.vayunmathur.fooddelivery.data.Order import com.vayunmathur.fooddelivery.data.OrderStage import com.vayunmathur.fooddelivery.notifications.OrderTrackingService
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrdersScreen.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrdersScreen.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrdersScreen.ktindex 1d6407a380..a4a29ecbaf 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrdersScreen.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrdersScreen.kt@@ -24,6 +24,7 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.setValue import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope@@ -46,13 +47,13 @@ import com.vayunmathur.library.ui.IconStar import com.vayunmathur.library.ui.OutlinedButton import com.vayunmathur.library.ui.OutlinedTextField import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.Scaffold+import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.Surface import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.TextButton import com.vayunmathur.library.util.sharedText-import com.vayunmathur.fooddelivery.api.BitesAuth-import com.vayunmathur.fooddelivery.api.BitesOrders+import com.vayunmathur.fooddelivery.network.BitesAuth+import com.vayunmathur.fooddelivery.network.BitesOrders import com.vayunmathur.fooddelivery.data.FeedbackRequest import com.vayunmathur.fooddelivery.data.Order import com.vayunmathur.fooddelivery.platform.AppInit@@ -111,7 +112,7 @@ fun OrdersScreen(onTrackOrder: (Int) -> Unit = {}) { loading = false } - Scaffold { padding ->+ AppScaffold(topBar = {}) { padding -> if (loading) { Box(Modifier.fillMaxSize().padding(padding), contentAlignment = Alignment.Center) { CircularProgressIndicator()@@ -292,9 +293,9 @@ private fun FeedbackDialog( onDismiss: () -> Unit, onSubmit: (rating: Int, note: String, extraTipCents: Int) -> Unit, ) {- var rating by remember { mutableStateOf(5) }+ var rating by remember { mutableIntStateOf(5) } var note by remember { mutableStateOf("") }- var extraTip by remember { mutableStateOf(0) }+ var extraTip by remember { mutableIntStateOf(0) } AlertDialog( onDismissRequest = onDismiss,
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/RestaurantContent.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/RestaurantContent.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/RestaurantContent.ktnew file mode 100644index 0000000000..c42734de6d--- /dev/null+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/RestaurantContent.kt@@ -0,0 +1,266 @@+package com.vayunmathur.fooddelivery.ui+import androidx.compose.ui.res.stringResource+import com.vayunmathur.fooddelivery.R+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.PaddingValues+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.Spacer+import androidx.compose.foundation.layout.aspectRatio+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.height+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.lazy.LazyColumn+import androidx.compose.foundation.lazy.items+import androidx.compose.foundation.rememberScrollState+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.foundation.verticalScroll+import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateMapOf+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.runtime.snapshotFlow+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.layout.ContentScale+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.text.style.TextOverflow+import androidx.compose.ui.unit.dp+import com.vayunmathur.library.image.compose.AsyncImage+import com.vayunmathur.library.ui.EmptyState+import com.vayunmathur.library.ui.AlertDialog+import com.vayunmathur.library.ui.Button+import com.vayunmathur.library.ui.Card+import com.vayunmathur.library.ui.Checkbox+import com.vayunmathur.library.ui.CircularProgressIndicator+import com.vayunmathur.library.ui.HorizontalDivider+import com.vayunmathur.library.ui.IconAdd+import com.vayunmathur.library.ui.IconBack+import com.vayunmathur.library.ui.IconButton+import com.vayunmathur.library.ui.IconClose+import com.vayunmathur.library.ui.IconSearch+import com.vayunmathur.library.ui.IconStar+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.OutlinedButton+import com.vayunmathur.library.ui.OutlinedTextField+import com.vayunmathur.library.ui.RadioButton+import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton+import com.vayunmathur.library.util.sharedContainer+import com.vayunmathur.library.util.sharedText+import com.vayunmathur.fooddelivery.network.BitesCustomers+import com.vayunmathur.fooddelivery.network.BitesMerchants+import com.vayunmathur.fooddelivery.network.BitesRewards+import com.vayunmathur.fooddelivery.data.CartItem+import com.vayunmathur.fooddelivery.data.MerchantDetail+import com.vayunmathur.fooddelivery.data.MenuItem+import com.vayunmathur.fooddelivery.data.MerchantRewards+import com.vayunmathur.fooddelivery.data.SelectedModifier+import com.vayunmathur.fooddelivery.platform.AppInit+import androidx.compose.runtime.rememberCoroutineScope+import kotlinx.coroutines.FlowPreview+import kotlinx.coroutines.flow.debounce+import kotlinx.coroutines.launch++/**+ * The menu, with no API call of its own so it can be rendered from a `@Preview` — see+ * `src/screenshotTest`, which is where the store listing images come from.+ */+@OptIn(FlowPreview::class)+@Composable+fun RestaurantContent(+ merchant: MerchantDetail?,+ loading: Boolean = false,+ rewards: MerchantRewards? = null,+ onJoinLoyalty: (String) -> Unit = {},+ onLeaveLoyalty: () -> Unit = {},+ onBack: () -> Unit = {},+ onAddItem: (MenuItem, List<SelectedModifier>) -> Unit = { _, _ -> },+) {+ var customizeItem by remember { mutableStateOf<MenuItem?>(null) }+ var query by remember { mutableStateOf("") }+ // The field itself stays instant; the menu is only re-filtered once typing settles, so a+ // keystroke no longer re-walks and re-sorts every category.+ var appliedQuery by remember { mutableStateOf("") }+ LaunchedEffect(Unit) {+ snapshotFlow { query }.debounce(FILTER_DEBOUNCE_MS).collect { appliedQuery = it }+ }++ customizeItem?.let { item ->+ ModifierDialog(+ item = item,+ onDismiss = { customizeItem = null },+ onConfirm = { selectedModifiers ->+ onAddItem(item, selectedModifiers)+ customizeItem = null+ }+ )+ }++ AppScaffold(topBar = {}) { padding ->+ if (loading) {+ Box(Modifier.fillMaxSize().padding(padding), contentAlignment = Alignment.Center) {+ CircularProgressIndicator()+ }+ } else if (merchant == null) {+ EmptyState(+ title = stringResource(R.string.restaurant_not_found),+ modifier = Modifier.fillMaxSize().padding(padding),+ )+ } else {+ val m = merchant+ val q = appliedQuery.trim()+ // Rebuilding the id index and the filtered menu on every recomposition is what made+ // typing in the search field lag, so both are kept until their inputs change.+ val itemsById = remember(m.items) { m.items.associateBy { it.id } }+ val activeCategories = remember(m.categories) {+ m.categories.filter { it.isActive }.sortedBy { it.sortOrder }+ }+ val sections = remember(m.items, m.categories, q) {+ activeCategories.mapNotNull { category ->+ val categoryItems = category.itemIds.mapNotNull { itemsById[it] }+ .filter {+ it.isAvailable && it.isInStock && (q.isEmpty() ||+ it.name.contains(q, ignoreCase = true) ||+ it.description.contains(q, ignoreCase = true))+ }+ if (categoryItems.isEmpty()) null else category to categoryItems+ }+ }++ LazyColumn(+ contentPadding = PaddingValues(bottom = 16.dp),+ modifier = Modifier.padding(padding)+ ) {+ if (m.imageUrl.isNotEmpty()) {+ item {+ Box {+ AsyncImage(+ model = m.imageUrl,+ contentDescription = m.name,+ contentScale = ContentScale.Crop,+ modifier = Modifier+ .fillMaxWidth()+ .aspectRatio(16f / 9f)+ .sharedContainer("food-merchant-${m.id}")+ )+ IconButton(onClick = onBack,+ modifier = Modifier.padding(4.dp)) {+ IconBack()+ }+ }+ }+ } else {+ item {+ IconButton(onClick = onBack,+ modifier = Modifier.padding(4.dp)) {+ IconBack()+ }+ }+ }+ item {+ Column(Modifier.padding(16.dp)) {+ Text(m.name, style = MaterialTheme.typography.headlineSmall,+ fontWeight = FontWeight.Bold,+ modifier = Modifier.sharedText("food-merchant-name-${m.id}"))+ if (m.merchantTags.isNotEmpty()) {+ Spacer(Modifier.height(4.dp))+ Text(m.merchantTags.joinToString(" · "),+ style = MaterialTheme.typography.bodyMedium,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ modifier = Modifier.sharedText("food-merchant-tags-${m.id}"))+ }+ Spacer(Modifier.height(8.dp))+ Row(horizontalArrangement = Arrangement.spacedBy(16.dp)) {+ if ((m.averageRating ?: 0.0) > 0) {+ Row(verticalAlignment = Alignment.CenterVertically) {+ IconStar(Modifier.size(16.dp),+ tint = MaterialTheme.colorScheme.primary)+ Spacer(Modifier.width(2.dp))+ Text("%.1f (%d)".format(m.averageRating, m.totalRatings ?: 0),+ style = MaterialTheme.typography.bodySmall)+ }+ }+ if (m.nextOpenWindow.isNotEmpty()) {+ Text(m.nextOpenWindow, style = MaterialTheme.typography.bodySmall,+ color = MaterialTheme.colorScheme.primary)+ }+ if ((m.rewardsPercentage ?: 0.0) > 0) {+ Text(stringResource(R.string.back, (m.rewardsPercentage?.toInt()).toString()),+ style = MaterialTheme.typography.bodySmall,+ color = MaterialTheme.colorScheme.primary)+ }+ }+ }+ }++ item {+ MerchantRewardsCard(+ rewards = rewards,+ onJoin = onJoinLoyalty,+ onLeave = onLeaveLoyalty,+ )+ }++ item {+ OutlinedTextField(+ value = query,+ onValueChange = { query = it },+ label = { Text(stringResource(R.string.search_menu)) },+ singleLine = true,+ leadingIcon = { IconSearch() },+ trailingIcon = {+ if (query.isNotEmpty()) {+ IconButton(onClick = { query = "" }) { IconClose() }+ }+ },+ modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 8.dp),+ )+ }++ if (sections.isEmpty()) {+ item {+ Text(+ stringResource(R.string.no_menu_items_match, q),+ style = MaterialTheme.typography.bodyMedium,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ modifier = Modifier.padding(16.dp),+ )+ }+ }++ sections.forEach { (category, categoryItems) ->+ item {+ HorizontalDivider(Modifier.padding(horizontal = 16.dp))+ Spacer(Modifier.height(12.dp))+ Text(category.name,+ style = MaterialTheme.typography.titleMedium,+ fontWeight = FontWeight.Bold,+ modifier = Modifier.padding(horizontal = 16.dp))+ Spacer(Modifier.height(8.dp))+ }+ // An item can sit in more than one category, so the key has to include the+ // category to stay unique across the whole list.+ items(categoryItems, key = { "${category.id}-${it.id}" }) { menuItem ->+ MenuItemRow(menuItem) {+ if (menuItem.modifierGroups.isNotEmpty()) {+ customizeItem = menuItem+ } else {+ onAddItem(menuItem, emptyList())+ }+ }+ }+ }+ }+ }+ }+}
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/RestaurantScreen.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/RestaurantScreen.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/RestaurantScreen.ktindex 1e513c3787..defa44dae5 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/RestaurantScreen.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/RestaurantScreen.kt@@ -53,14 +53,13 @@ import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.OutlinedButton import com.vayunmathur.library.ui.OutlinedTextField import com.vayunmathur.library.ui.RadioButton-import com.vayunmathur.library.ui.Scaffold import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.TextButton import com.vayunmathur.library.util.sharedContainer import com.vayunmathur.library.util.sharedText-import com.vayunmathur.fooddelivery.api.BitesCustomers-import com.vayunmathur.fooddelivery.api.BitesMerchants-import com.vayunmathur.fooddelivery.api.BitesRewards+import com.vayunmathur.fooddelivery.network.BitesCustomers+import com.vayunmathur.fooddelivery.network.BitesMerchants+import com.vayunmathur.fooddelivery.network.BitesRewards import com.vayunmathur.fooddelivery.data.CartItem import com.vayunmathur.fooddelivery.data.MerchantDetail import com.vayunmathur.fooddelivery.data.MenuItem@@ -73,7 +72,7 @@ import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.launch /** How long typing has to settle before the menu is re-filtered. */-private const val FILTER_DEBOUNCE_MS = 150L+internal const val FILTER_DEBOUNCE_MS = 150L @Composable fun RestaurantScreen(@@ -123,199 +122,6 @@ fun RestaurantScreen( ) } -/**- * The menu, with no API call of its own so it can be rendered from a `@Preview` — see- * `src/screenshotTest`, which is where the store listing images come from.- */-@OptIn(FlowPreview::class)-@Composable-fun RestaurantContent(- merchant: MerchantDetail?,- loading: Boolean = false,- rewards: MerchantRewards? = null,- onJoinLoyalty: (String) -> Unit = {},- onLeaveLoyalty: () -> Unit = {},- onBack: () -> Unit = {},- onAddItem: (MenuItem, List<SelectedModifier>) -> Unit = { _, _ -> },-) {- var customizeItem by remember { mutableStateOf<MenuItem?>(null) }- var query by remember { mutableStateOf("") }- // The field itself stays instant; the menu is only re-filtered once typing settles, so a- // keystroke no longer re-walks and re-sorts every category.- var appliedQuery by remember { mutableStateOf("") }- LaunchedEffect(Unit) {- snapshotFlow { query }.debounce(FILTER_DEBOUNCE_MS).collect { appliedQuery = it }- }-- customizeItem?.let { item ->- ModifierDialog(- item = item,- onDismiss = { customizeItem = null },- onConfirm = { selectedModifiers ->- onAddItem(item, selectedModifiers)- customizeItem = null- }- )- }-- Scaffold { padding ->- if (loading) {- Box(Modifier.fillMaxSize().padding(padding), contentAlignment = Alignment.Center) {- CircularProgressIndicator()- }- } else if (merchant == null) {- EmptyState(- title = stringResource(R.string.restaurant_not_found),- modifier = Modifier.fillMaxSize().padding(padding),- )- } else {- val m = merchant- val q = appliedQuery.trim()- // Rebuilding the id index and the filtered menu on every recomposition is what made- // typing in the search field lag, so both are kept until their inputs change.- val itemsById = remember(m.items) { m.items.associateBy { it.id } }- val activeCategories = remember(m.categories) {- m.categories.filter { it.isActive }.sortedBy { it.sortOrder }- }- val sections = remember(m.items, m.categories, q) {- activeCategories.mapNotNull { category ->- val categoryItems = category.itemIds.mapNotNull { itemsById[it] }- .filter {- it.isAvailable && it.isInStock && (q.isEmpty() ||- it.name.contains(q, ignoreCase = true) ||- it.description.contains(q, ignoreCase = true))- }- if (categoryItems.isEmpty()) null else category to categoryItems- }- }-- LazyColumn(- contentPadding = PaddingValues(bottom = 16.dp),- modifier = Modifier.padding(padding)- ) {- if (m.imageUrl.isNotEmpty()) {- item {- Box {- AsyncImage(- model = m.imageUrl,- contentDescription = m.name,- contentScale = ContentScale.Crop,- modifier = Modifier- .fillMaxWidth()- .aspectRatio(16f / 9f)- .sharedContainer("food-merchant-${m.id}")- )- IconButton(onClick = onBack,- modifier = Modifier.padding(4.dp)) {- IconBack()- }- }- }- } else {- item {- IconButton(onClick = onBack,- modifier = Modifier.padding(4.dp)) {- IconBack()- }- }- }- item {- Column(Modifier.padding(16.dp)) {- Text(m.name, style = MaterialTheme.typography.headlineSmall,- fontWeight = FontWeight.Bold,- modifier = Modifier.sharedText("food-merchant-name-${m.id}"))- if (m.merchantTags.isNotEmpty()) {- Spacer(Modifier.height(4.dp))- Text(m.merchantTags.joinToString(" · "),- style = MaterialTheme.typography.bodyMedium,- color = MaterialTheme.colorScheme.onSurfaceVariant,- modifier = Modifier.sharedText("food-merchant-tags-${m.id}"))- }- Spacer(Modifier.height(8.dp))- Row(horizontalArrangement = Arrangement.spacedBy(16.dp)) {- if ((m.averageRating ?: 0.0) > 0) {- Row(verticalAlignment = Alignment.CenterVertically) {- IconStar(Modifier.size(16.dp),- tint = MaterialTheme.colorScheme.primary)- Spacer(Modifier.width(2.dp))- Text("%.1f (%d)".format(m.averageRating, m.totalRatings ?: 0),- style = MaterialTheme.typography.bodySmall)- }- }- if (m.nextOpenWindow.isNotEmpty()) {- Text(m.nextOpenWindow, style = MaterialTheme.typography.bodySmall,- color = MaterialTheme.colorScheme.primary)- }- if ((m.rewardsPercentage ?: 0.0) > 0) {- Text(stringResource(R.string.back, (m.rewardsPercentage?.toInt()).toString()),- style = MaterialTheme.typography.bodySmall,- color = MaterialTheme.colorScheme.primary)- }- }- }- }-- item {- MerchantRewardsCard(- rewards = rewards,- onJoin = onJoinLoyalty,- onLeave = onLeaveLoyalty,- )- }-- item {- OutlinedTextField(- value = query,- onValueChange = { query = it },- label = { Text(stringResource(R.string.search_menu)) },- singleLine = true,- leadingIcon = { IconSearch() },- trailingIcon = {- if (query.isNotEmpty()) {- IconButton(onClick = { query = "" }) { IconClose() }- }- },- modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 8.dp),- )- }-- if (sections.isEmpty()) {- item {- Text(- stringResource(R.string.no_menu_items_match, q),- style = MaterialTheme.typography.bodyMedium,- color = MaterialTheme.colorScheme.onSurfaceVariant,- modifier = Modifier.padding(16.dp),- )- }- }-- sections.forEach { (category, categoryItems) ->- item {- HorizontalDivider(Modifier.padding(horizontal = 16.dp))- Spacer(Modifier.height(12.dp))- Text(category.name,- style = MaterialTheme.typography.titleMedium,- fontWeight = FontWeight.Bold,- modifier = Modifier.padding(horizontal = 16.dp))- Spacer(Modifier.height(8.dp))- }- // An item can sit in more than one category, so the key has to include the- // category to stay unique across the whole list.- items(categoryItems, key = { "${category.id}-${it.id}" }) { menuItem ->- MenuItemRow(menuItem) {- if (menuItem.modifierGroups.isNotEmpty()) {- customizeItem = menuItem- } else {- onAddItem(menuItem, emptyList())- }- }- }- }- }- }- }-} /** * Pick modifiers for [item]. Pass [initialSelection] to reopen it over an existing choice
fooddelivery/src/main/res/values-ar/strings.xml
diff --git a/fooddelivery/src/main/res/values-ar/strings.xml b/fooddelivery/src/main/res/values-ar/strings.xmlindex 1ab2aad351..bff1abfd90 100644--- a/fooddelivery/src/main/res/values-ar/strings.xml+++ b/fooddelivery/src/main/res/values-ar/strings.xml@@ -2,8 +2,6 @@ <resources> <string name="first_name">الاسم الأول</string> <string name="last_name">اسم العائلة</string>- <string name="email">البريد الإلكتروني</string> <string name="addresses">العناوين</string> <string name="delete_account">حذف الحساب</string>- <string name="action_cancel">إلغاء</string> </resources>
fooddelivery/src/main/res/values-az/strings.xml
diff --git a/fooddelivery/src/main/res/values-az/strings.xml b/fooddelivery/src/main/res/values-az/strings.xmlindex e437a715d5..045e125f3d 100644--- a/fooddelivery/src/main/res/values-az/strings.xml+++ b/fooddelivery/src/main/res/values-az/strings.xml@@ -1,4 +1,3 @@ <?xml version="1.0" encoding="utf-8"?> <resources>- <string name="action_cancel">Ləğv et</string> </resources>
fooddelivery/src/main/res/values-et/strings.xml
diff --git a/fooddelivery/src/main/res/values-et/strings.xml b/fooddelivery/src/main/res/values-et/strings.xmlindex 0c2815560f..05ab57420a 100644--- a/fooddelivery/src/main/res/values-et/strings.xml+++ b/fooddelivery/src/main/res/values-et/strings.xml@@ -15,13 +15,11 @@ <string name="order_not_found">Tellimust ei leidu</string> <string name="no_map_location">Asukoht pole veel teada</string> <string name="your_courier">Sinu kuller</string>- <string name="call">Helista</string> <string name="delivered_photo">Kohaletoimetatud</string> <string name="eta_minutes">Saabumiseni on jäänud umbes %1$d min (%2$s)</string> <string name="eta_any_moment">Saabub kohe</string> <string name="driver_distance">Juht on %1$s miili kaugusel</string> <string name="feedback_optional">Tagasiside (kui tahad lisada)</string>- <string name="action_cancel">Katkesta</string> <string name="submit">Edasta</string> <string name="your_cart_is_empty">Sinu ostukorv on tühi</string> <string name="addresses">Aadressid</string>@@ -48,7 +46,10 @@ <string name="no_deals_yet">Hetkel eripakkumisi pole</string> <string name="deals_will_appear_here">Uued eripakkumised saavad olema kuvatud siin</string> <string name="deal_unlocked">Pakkumine on kasutusel</string>- <string name="deal_progress">%1$d / %2$d pakkumist</string>+ <plurals name="deal_progress">+ <item quantity="one">%1$d / %2$d pakkumine</item>+ <item quantity="other">%1$d / %2$d pakkumist</item>+ </plurals> <string name="invite_code">Kutsekood</string> <string name="join">Liitu</string> <string name="leave_loyalty">Lahku kliendiprogrammist</string>@@ -63,7 +64,6 @@ <string name="verification_code">Kinnituskood</string> <string name="your_savings">Sa oled säästnud</string> <string name="sign_out">Logi välja</string>- <string name="email">E-posti aadress</string> <string name="label_e_g_home_work">Silt (nt. kodu, töö)</string> <string name="street_address">Maja aadress *</string> <string name="city">Linn *</string>
fooddelivery/src/main/res/values-fr/strings.xml
diff --git a/fooddelivery/src/main/res/values-fr/strings.xml b/fooddelivery/src/main/res/values-fr/strings.xmlindex 5d92a5eacc..e7f629654b 100644--- a/fooddelivery/src/main/res/values-fr/strings.xml+++ b/fooddelivery/src/main/res/values-fr/strings.xml@@ -1,6 +1,4 @@ <?xml version="1.0" encoding="utf-8"?> <resources>- <string name="email">E-mail</string>- <string name="action_cancel">Annuler</string> <string name="delete_account">Supprimer le compte</string> </resources>
fooddelivery/src/main/res/values-it/strings.xml
diff --git a/fooddelivery/src/main/res/values-it/strings.xml b/fooddelivery/src/main/res/values-it/strings.xmlindex d875880f5a..3fd4ba257c 100644--- a/fooddelivery/src/main/res/values-it/strings.xml+++ b/fooddelivery/src/main/res/values-it/strings.xml@@ -1,5 +1,4 @@ <?xml version="1.0" encoding="utf-8"?> <resources>- <string name="action_cancel">Annulla</string> <string name="delete_account">Elimina account</string> </resources>
fooddelivery/src/main/res/values-ja/strings.xml
diff --git a/fooddelivery/src/main/res/values-ja/strings.xml b/fooddelivery/src/main/res/values-ja/strings.xmlindex 3069b167ab..4811b9e0b1 100644--- a/fooddelivery/src/main/res/values-ja/strings.xml+++ b/fooddelivery/src/main/res/values-ja/strings.xml@@ -1,8 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <resources>- <string name="action_cancel">キャンセル</string> <string name="first_name">名</string> <string name="last_name">姓</string>- <string name="email">Eメール</string> <string name="addresses">住所</string> </resources>
fooddelivery/src/main/res/values-ru/strings.xml
diff --git a/fooddelivery/src/main/res/values-ru/strings.xml b/fooddelivery/src/main/res/values-ru/strings.xmlindex 99bdf67534..1c42562586 100644--- a/fooddelivery/src/main/res/values-ru/strings.xml+++ b/fooddelivery/src/main/res/values-ru/strings.xml@@ -2,7 +2,6 @@ <resources> <string name="first_name">Имя</string> <string name="last_name">Фамилия</string>- <string name="email">Email</string> <string name="addresses">Адреса</string> <string name="delete_account">Удалить учетку</string> </resources>
fooddelivery/src/main/res/values-sv/strings.xml
diff --git a/fooddelivery/src/main/res/values-sv/strings.xml b/fooddelivery/src/main/res/values-sv/strings.xmlindex d8edc66c58..80a2cf2d0a 100644--- a/fooddelivery/src/main/res/values-sv/strings.xml+++ b/fooddelivery/src/main/res/values-sv/strings.xml@@ -1,9 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <resources>- <string name="action_cancel">Avbryt</string> <string name="first_name">Förnamn</string> <string name="last_name">Efternamn</string>- <string name="email">E-post</string> <string name="addresses">Adresser</string> <string name="delete_account">Ta bort konto</string> <string name="app_name">Matleverans</string>@@ -27,7 +25,10 @@ <string name="no_deals_yet">Inga erbjudanden just nu</string> <string name="deals_will_appear_here">Nya erbjudanden visas här</string> <string name="deal_unlocked">Erbjudande upplåst</string>- <string name="deal_progress">%1$d av %2$d beställningar</string>+ <plurals name="deal_progress">+ <item quantity="one">%1$d av %2$d beställning</item>+ <item quantity="other">%1$d av %2$d beställningar</item>+ </plurals> <string name="rewards">Belöningar</string> <string name="rewards_available">Belöningar för %1$s finns här</string> <string name="no_rewards_here_yet">Inga belöningar på den här restaurangen ännu</string>
fooddelivery/src/main/res/values-zh-rCN/strings.xml
diff --git a/fooddelivery/src/main/res/values-zh-rCN/strings.xml b/fooddelivery/src/main/res/values-zh-rCN/strings.xmlindex aa747c575e..aaf98f364a 100644--- a/fooddelivery/src/main/res/values-zh-rCN/strings.xml+++ b/fooddelivery/src/main/res/values-zh-rCN/strings.xml@@ -1,5 +1,4 @@ <?xml version="1.0" encoding="utf-8"?> <resources> <string name="delete_account">删除账号</string>- <string name="action_cancel">取消</string> </resources>
fooddelivery/src/main/res/values/strings.xml
diff --git a/fooddelivery/src/main/res/values/strings.xml b/fooddelivery/src/main/res/values/strings.xmlindex 1e370b688f..81370753bf 100644--- a/fooddelivery/src/main/res/values/strings.xml+++ b/fooddelivery/src/main/res/values/strings.xml@@ -23,8 +23,11 @@ <string name="no_deals_yet">No deals right now</string> <string name="deals_will_appear_here">New offers will show up here</string> <string name="deal_unlocked">Deal unlocked</string>- <!-- %1$d = orders so far, %2$d = orders needed -->- <string name="deal_progress">%1$d of %2$d orders</string>+ <!-- %1$d = orders so far, %2$d = orders needed (the total, which drives the plural) -->+ <plurals name="deal_progress">+ <item quantity="one">%1$d of %2$d order</item>+ <item quantity="other">%1$d of %2$d orders</item>+ </plurals> <string name="rewards">Rewards</string> <!-- %1$s = a dollar amount of reward credit --> <string name="rewards_available">%1$s in rewards available here</string>
fooddelivery/src/test/java/com/vayunmathur/fooddelivery/FoodWave3MainActivityTest.kt
diff --git a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/FoodWave3MainActivityTest.kt b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/FoodWave3MainActivityTest.ktindex 608d459c0e..5b31a75eb0 100644--- a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/FoodWave3MainActivityTest.kt+++ b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/FoodWave3MainActivityTest.kt@@ -1,12 +1,16 @@ package com.vayunmathur.fooddelivery +import com.vayunmathur.fooddelivery.platform.canAddFromSameMerchant+import com.vayunmathur.fooddelivery.platform.pushDetail+import com.vayunmathur.fooddelivery.platform.tabRouteFor+ import android.app.Application import android.content.Context import android.content.Intent import android.net.Uri import androidx.test.core.app.ApplicationProvider-import com.vayunmathur.fooddelivery.api.BitesAuth-import com.vayunmathur.fooddelivery.api.BitesCore+import com.vayunmathur.fooddelivery.network.BitesAuth+import com.vayunmathur.fooddelivery.network.BitesCore import com.vayunmathur.fooddelivery.data.AuthToken import com.vayunmathur.fooddelivery.data.CartItem import com.vayunmathur.fooddelivery.data.MenuItem
fooddelivery/src/test/java/com/vayunmathur/fooddelivery/StoresAndMiscTest.kt
diff --git a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/StoresAndMiscTest.kt b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/StoresAndMiscTest.ktindex a63c2c617c..beeb5a2922 100644--- a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/StoresAndMiscTest.kt+++ b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/StoresAndMiscTest.kt@@ -1,5 +1,7 @@ package com.vayunmathur.fooddelivery +import com.vayunmathur.fooddelivery.platform.canAddFromSameMerchant+ import android.app.Application import android.content.Context import androidx.test.core.app.ApplicationProvider@@ -11,7 +13,7 @@ import com.vayunmathur.fooddelivery.data.Order import com.vayunmathur.fooddelivery.data.OrderStage import com.vayunmathur.fooddelivery.data.SavedAddress import com.vayunmathur.fooddelivery.data.parseIsoMillis-import com.vayunmathur.fooddelivery.ipc.OrderLookupContract+import com.vayunmathur.fooddelivery.intents.OrderLookupContract import com.vayunmathur.fooddelivery.notifications.OrderLiveUpdate import kotlinx.coroutines.runBlocking import org.junit.runner.RunWith
fooddelivery/src/test/java/com/vayunmathur/fooddelivery/TrackingServiceTest.kt
diff --git a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/TrackingServiceTest.kt b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/TrackingServiceTest.ktindex 950cbc4b9e..baee6903c5 100644--- a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/TrackingServiceTest.kt+++ b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/TrackingServiceTest.kt@@ -6,7 +6,7 @@ import android.content.Context import android.content.Intent import android.os.Looper import androidx.test.core.app.ApplicationProvider-import com.vayunmathur.fooddelivery.api.BitesCore+import com.vayunmathur.fooddelivery.network.BitesCore import com.vayunmathur.fooddelivery.notifications.OrderTrackingService import com.vayunmathur.library.network.SimpleResponse import org.junit.runner.RunWith
fooddelivery/src/test/java/com/vayunmathur/fooddelivery/data/FoodWave3ModelsTest.kt
diff --git a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/data/FoodWave3ModelsTest.kt b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/data/FoodWave3ModelsTest.ktindex 1e1a705da6..3d8259c0c4 100644--- a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/data/FoodWave3ModelsTest.kt+++ b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/data/FoodWave3ModelsTest.kt@@ -1,6 +1,6 @@ package com.vayunmathur.fooddelivery.data -import com.vayunmathur.fooddelivery.api.BitesCore+import com.vayunmathur.fooddelivery.network.BitesCore import kotlinx.serialization.builtins.serializer import kotlin.test.Test import kotlin.test.assertEquals
fooddelivery/src/test/java/com/vayunmathur/fooddelivery/intents/AssistantIntentsTest.kt
diff --git a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/intents/AssistantIntentsTest.kt b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/intents/AssistantIntentsTest.ktindex 9f75c7b8bb..b61882a152 100644--- a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/intents/AssistantIntentsTest.kt+++ b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/intents/AssistantIntentsTest.kt@@ -5,13 +5,13 @@ import android.content.Context import android.content.Intent import android.net.Uri import androidx.test.core.app.ApplicationProvider-import com.vayunmathur.fooddelivery.api.BitesAuth-import com.vayunmathur.fooddelivery.api.BitesCore+import com.vayunmathur.fooddelivery.network.BitesAuth+import com.vayunmathur.fooddelivery.network.BitesCore import com.vayunmathur.fooddelivery.data.AddressStore import com.vayunmathur.fooddelivery.data.AuthToken import com.vayunmathur.fooddelivery.data.CartStore import com.vayunmathur.fooddelivery.data.SavedAddress-import com.vayunmathur.fooddelivery.isCheckoutDeepLink+import com.vayunmathur.fooddelivery.platform.isCheckoutDeepLink import com.vayunmathur.fooddelivery.platform.AppInit import com.vayunmathur.library.intents.fooddelivery.FindRestaurants import com.vayunmathur.library.intents.fooddelivery.GetCart
fooddelivery/src/test/java/com/vayunmathur/fooddelivery/network/BitesApiFakeTransportTest.kt
diff --git a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/api/BitesApiFakeTransportTest.kt b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/network/BitesApiFakeTransportTest.ktsimilarity index 99%rename from fooddelivery/src/test/java/com/vayunmathur/fooddelivery/api/BitesApiFakeTransportTest.ktrename to fooddelivery/src/test/java/com/vayunmathur/fooddelivery/network/BitesApiFakeTransportTest.ktindex 84c55e7c89..30c7f3a1ac 100644--- a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/api/BitesApiFakeTransportTest.kt+++ b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/network/BitesApiFakeTransportTest.kt@@ -1,4 +1,4 @@-package com.vayunmathur.fooddelivery.api+package com.vayunmathur.fooddelivery.network import android.app.Application import org.junit.runner.RunWith
fooddelivery/src/test/java/com/vayunmathur/fooddelivery/network/FoodWave3ApiTest.kt
diff --git a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/api/FoodWave3ApiTest.kt b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/network/FoodWave3ApiTest.ktsimilarity index 99%rename from fooddelivery/src/test/java/com/vayunmathur/fooddelivery/api/FoodWave3ApiTest.ktrename to fooddelivery/src/test/java/com/vayunmathur/fooddelivery/network/FoodWave3ApiTest.ktindex 92170b4422..78f7bcdc95 100644--- a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/api/FoodWave3ApiTest.kt+++ b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/network/FoodWave3ApiTest.kt@@ -1,4 +1,4 @@-package com.vayunmathur.fooddelivery.api+package com.vayunmathur.fooddelivery.network import android.app.Application import com.vayunmathur.fooddelivery.data.AuthToken
fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/BinderScreensTest.kt
diff --git a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/BinderScreensTest.kt b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/BinderScreensTest.ktindex 74d562162b..554e603d4b 100644--- a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/BinderScreensTest.kt+++ b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/BinderScreensTest.kt@@ -9,8 +9,8 @@ import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performSemanticsAction import androidx.compose.ui.test.performTextInput import androidx.test.core.app.ApplicationProvider-import com.vayunmathur.fooddelivery.api.BitesAuth-import com.vayunmathur.fooddelivery.api.BitesCore+import com.vayunmathur.fooddelivery.network.BitesAuth+import com.vayunmathur.fooddelivery.network.BitesCore import com.vayunmathur.fooddelivery.data.AuthToken import com.vayunmathur.fooddelivery.data.CartItem import com.vayunmathur.fooddelivery.data.MenuItem
fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow2Test.kt
diff --git a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow2Test.kt b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow2Test.ktindex 857e4f8ff1..ec7b9669eb 100644--- a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow2Test.kt+++ b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow2Test.kt@@ -12,8 +12,8 @@ import androidx.compose.ui.test.performSemanticsAction import androidx.compose.ui.test.performTextInput import androidx.compose.ui.semantics.SemanticsActions import androidx.test.core.app.ApplicationProvider-import com.vayunmathur.fooddelivery.api.BitesAuth-import com.vayunmathur.fooddelivery.api.BitesCore+import com.vayunmathur.fooddelivery.network.BitesAuth+import com.vayunmathur.fooddelivery.network.BitesCore import com.vayunmathur.fooddelivery.data.AddressStore import com.vayunmathur.fooddelivery.data.AuthToken import com.vayunmathur.fooddelivery.data.CartItem
fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow3Test.kt
diff --git a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow3Test.kt b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow3Test.ktindex f267698dab..5a06f94f09 100644--- a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow3Test.kt+++ b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow3Test.kt@@ -11,7 +11,7 @@ import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performSemanticsAction import androidx.compose.ui.test.performTextInput import androidx.test.core.app.ApplicationProvider-import com.vayunmathur.fooddelivery.api.BitesCore+import com.vayunmathur.fooddelivery.network.BitesCore import com.vayunmathur.fooddelivery.data.Merchant import com.vayunmathur.fooddelivery.platform.AppInit import com.vayunmathur.library.network.SimpleResponse
fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow4Test.kt
diff --git a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow4Test.kt b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow4Test.ktindex 53c16cb3aa..0e29c31aad 100644--- a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow4Test.kt+++ b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow4Test.kt@@ -10,8 +10,8 @@ import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performSemanticsAction import androidx.compose.ui.semantics.SemanticsActions import androidx.test.core.app.ApplicationProvider-import com.vayunmathur.fooddelivery.api.BitesAuth-import com.vayunmathur.fooddelivery.api.BitesCore+import com.vayunmathur.fooddelivery.network.BitesAuth+import com.vayunmathur.fooddelivery.network.BitesCore import com.vayunmathur.fooddelivery.data.AuthToken import com.vayunmathur.fooddelivery.data.CartItem import com.vayunmathur.fooddelivery.data.MenuItem
fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow5Test.kt
diff --git a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow5Test.kt b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow5Test.ktindex 5dd6987a40..c6644149f6 100644--- a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow5Test.kt+++ b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow5Test.kt@@ -12,8 +12,8 @@ import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performSemanticsAction import androidx.compose.ui.semantics.SemanticsActions import androidx.test.core.app.ApplicationProvider-import com.vayunmathur.fooddelivery.api.BitesAuth-import com.vayunmathur.fooddelivery.api.BitesCore+import com.vayunmathur.fooddelivery.network.BitesAuth+import com.vayunmathur.fooddelivery.network.BitesCore import com.vayunmathur.fooddelivery.data.AddressStore import com.vayunmathur.fooddelivery.data.AuthToken import com.vayunmathur.fooddelivery.data.CartItem
fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow6Test.kt
diff --git a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow6Test.kt b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow6Test.ktindex aa93b22348..0d9cef7be1 100644--- a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow6Test.kt+++ b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow6Test.kt@@ -12,8 +12,8 @@ import androidx.compose.ui.test.performSemanticsAction import androidx.compose.ui.test.performTextInput import androidx.compose.ui.semantics.SemanticsActions import androidx.test.core.app.ApplicationProvider-import com.vayunmathur.fooddelivery.api.BitesAuth-import com.vayunmathur.fooddelivery.api.BitesCore+import com.vayunmathur.fooddelivery.network.BitesAuth+import com.vayunmathur.fooddelivery.network.BitesCore import com.vayunmathur.fooddelivery.data.AddressStore import com.vayunmathur.fooddelivery.data.AuthToken import com.vayunmathur.fooddelivery.data.SavedAddress@@ -78,7 +78,7 @@ class FoodFlow6Test { @Test fun ordersRenderItemsAndModifiers() { installFake("""{"data":[{"id":9,"uuid":"u9","foodTotal":1000,"orderTotal":1500,"channel":"ORDER_CHANNEL_STOREFRONT_DELIVERY","createdAt":"2024-01-01T12:00:00Z","deliveredAt":"2024-01-01T00:00:00Z","merchant":{"id":1,"name":"Burger Barn","imageUrl":"https://example.com/m.png"},"orderItems":[{"id":1,"name":"Burger","quantity":2,"price":999,"modifiers":[{"name":"Cheese","price":100,"quantity":1}]},{"id":2,"name":"Fries","quantity":1,"price":399}]}]}""")- val fetched = kotlinx.coroutines.runBlocking { com.vayunmathur.fooddelivery.api.BitesOrders.getOrders() }+ val fetched = kotlinx.coroutines.runBlocking { com.vayunmathur.fooddelivery.network.BitesOrders.getOrders() } assertTrue(fetched.size == 1, "orders fake did not decode: $fetched") rule.setContent { OrdersScreen {} } awaitNode("Burger Barn")
fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow7Test.kt
diff --git a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow7Test.kt b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow7Test.ktindex 9c39688bf6..65dd5be9f5 100644--- a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow7Test.kt+++ b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodFlow7Test.kt@@ -8,8 +8,8 @@ import androidx.compose.ui.test.performSemanticsAction import androidx.compose.ui.test.performTextInput import androidx.compose.ui.semantics.SemanticsActions import androidx.test.core.app.ApplicationProvider-import com.vayunmathur.fooddelivery.api.BitesAuth-import com.vayunmathur.fooddelivery.api.BitesCore+import com.vayunmathur.fooddelivery.network.BitesAuth+import com.vayunmathur.fooddelivery.network.BitesCore import com.vayunmathur.fooddelivery.platform.AppInit import com.vayunmathur.library.network.SimpleResponse import org.junit.Rule
fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodTrackingStagesTest.kt
diff --git a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodTrackingStagesTest.kt b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodTrackingStagesTest.ktindex 92951b9602..d4a2cb4565 100644--- a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodTrackingStagesTest.kt+++ b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodTrackingStagesTest.kt@@ -11,8 +11,8 @@ import androidx.compose.ui.test.hasScrollAction import androidx.compose.ui.test.performSemanticsAction import androidx.compose.ui.semantics.SemanticsActions import androidx.test.core.app.ApplicationProvider-import com.vayunmathur.fooddelivery.api.BitesAuth-import com.vayunmathur.fooddelivery.api.BitesCore+import com.vayunmathur.fooddelivery.network.BitesAuth+import com.vayunmathur.fooddelivery.network.BitesCore import com.vayunmathur.fooddelivery.data.AddressStore import com.vayunmathur.fooddelivery.data.AuthToken import com.vayunmathur.fooddelivery.data.CartItem
fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodUiExtraTest.kt
diff --git a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodUiExtraTest.kt b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodUiExtraTest.ktindex 9d25000c26..1b7896962e 100644--- a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodUiExtraTest.kt+++ b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodUiExtraTest.kt@@ -12,8 +12,8 @@ import androidx.compose.ui.test.onRoot import androidx.compose.ui.test.printToLog import androidx.compose.ui.test.performClick import androidx.test.core.app.ApplicationProvider-import com.vayunmathur.fooddelivery.api.BitesAuth-import com.vayunmathur.fooddelivery.api.BitesCore+import com.vayunmathur.fooddelivery.network.BitesAuth+import com.vayunmathur.fooddelivery.network.BitesCore import com.vayunmathur.fooddelivery.data.AuthToken import com.vayunmathur.fooddelivery.data.CartItem import com.vayunmathur.fooddelivery.data.Customer
fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodWave3MainComposeTest.kt
diff --git a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodWave3MainComposeTest.kt b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodWave3MainComposeTest.ktindex 68571b6441..7b14f7e3b2 100644--- a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodWave3MainComposeTest.kt+++ b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodWave3MainComposeTest.kt@@ -13,8 +13,8 @@ import androidx.compose.ui.test.hasScrollAction import androidx.compose.ui.test.performScrollToIndex import androidx.test.core.app.ApplicationProvider import com.vayunmathur.fooddelivery.MainActivity-import com.vayunmathur.fooddelivery.api.BitesAuth-import com.vayunmathur.fooddelivery.api.BitesCore+import com.vayunmathur.fooddelivery.network.BitesAuth+import com.vayunmathur.fooddelivery.network.BitesCore import com.vayunmathur.fooddelivery.data.AddressStore import com.vayunmathur.fooddelivery.data.AuthToken import com.vayunmathur.fooddelivery.data.SavedAddress
fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodWave3ScreensTest.kt
diff --git a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodWave3ScreensTest.kt b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodWave3ScreensTest.ktindex 6067146581..ddce6a20ce 100644--- a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodWave3ScreensTest.kt+++ b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodWave3ScreensTest.kt@@ -15,8 +15,8 @@ import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performSemanticsAction import androidx.compose.ui.test.performTextInput import androidx.test.core.app.ApplicationProvider-import com.vayunmathur.fooddelivery.api.BitesAuth-import com.vayunmathur.fooddelivery.api.BitesCore+import com.vayunmathur.fooddelivery.network.BitesAuth+import com.vayunmathur.fooddelivery.network.BitesCore import com.vayunmathur.fooddelivery.data.AuthToken import com.vayunmathur.fooddelivery.data.CartItem import com.vayunmathur.fooddelivery.data.Deal