Homework

Homework — connect the flow

Homework — feel the flow and the stack.

  1. Run the whole flow: menu → "Add to cart" → cart icon → cart → Back → menu. Confirm the cart contents survive going back.
  2. Add a third screen. Screen.kt already has MenuItemDetail(itemId). Add an entry<Screen.MenuItemDetail> to PicaNavHost (it can just show Text("Pica #${itemId}") for now) and, in the menu card, onClick = { backStack.add(Screen.MenuItemDetail(item.id)) }. Tapping a pizza opens the detail screen with the right id.
  3. Watch the stack. Go menu → detail → cart a few times and press Back. Do you return in a tidy order?

Required tests:

  • Navigation test: menu → cart → Back works; the cart state survives.
  • Argument test: MenuItemDetail(item.id) shows the correct id on the detail screen.

To submit: a short note on navigation + a video or sequence of screenshots of the flow.

Tip. You have a flow, but the menu is still static — pizzas "from code". Next lesson we finally connect the real server: with Retrofit we load the menu from GET /menu (the Go backend you ran in lesson 1). And we'll do it by hand (no Koin) — so next lesson you feel why dependency injection is needed.