Theory
Compose UI: functions, not XML
In lesson 1 you saw: Compose UI is @Composable functions, not XML files. Today we build a real menu out of them.
Three ideas you'll need:
- A composable — a function describing a piece of UI:
Text(...),Card { ... },Column { ... }. Some call others — that's how a screen grows. Modifier— how an element looks and behaves:Modifier.fillMaxWidth().padding(16.dp). The chain reads left to right.LazyColumn— a scrolling list that only renders the visible items (not all hundred at once). A menu can be long, so a plainColumnwon't do — you wantLazyColumn.
Material 3 gives ready-made components with the right Android look: Scaffold (the screen frame with a top bar), TopAppBar, Card, and Text with MaterialTheme.typography styles.
The menu screen plan:
Scaffold
└─ TopAppBar("Pica Menu")
└─ LazyColumn
└─ for each pizza: Card { name · description · price }
The data today is static — a short list of pizzas in code. We connect the real menu from the server (GET /menu) in lesson 5; for now what matters is the screen looking right. Start with the model — what one pizza looks like in code.