# Location-aware versions

One widget that shows work things at work, the gym plan at the gym, and a calm card at home. The phone switches by itself; no agent runs.

**Sizes:** small (the heading), medium (heading and the list), large (the same)
**Needs:** places the user saved in Droplet.ai (Settings, Places). Read them from the phone context's `places`.
**Freshness:** the switching is live on the phone; the content is whatever you last wrote

## Widget

```json
{
  "slug": "smart-card",
  "title": "Right now",
  "symbol": "location.fill",
  "blocks": [
    { "type": "text", "style": "title", "text": "On the go" },
    { "type": "list", "items": ["Pick up dry cleaning", "Buy milk", "Fuel: 40 km left"] },
    { "type": "map", "lat": 24.6936, "lon": 46.6853, "label": "Near you: Al Olaya", "span": 2000 }
  ],
  "variants": [
    { "when": { "from": "22:00", "to": "06:00" }, "title": "Night",
      "blocks": [
        { "type": "text", "style": "title", "text": "Wind down" },
        { "type": "list", "items": ["Alarm set for 06:30", "Phone on the charger", "Lights off at 11"] },
        { "type": "map", "lat": 24.7741, "lon": 46.7386, "label": "Home", "span": 800 }
      ] },
    { "when": { "place": "work" }, "title": "At work",
      "blocks": [
        { "type": "text", "style": "title", "text": "Focus" },
        { "type": "list", "items": ["10:00 Standup", "14:00 Design review", "Reply to Khalid"] },
        { "type": "map", "lat": 24.6936, "lon": 46.6853, "label": "Office, Al Olaya", "span": 800 }
      ] },
    { "when": { "place": "gym" }, "title": "At the gym",
      "blocks": [
        { "type": "text", "style": "title", "text": "Leg day" },
        { "type": "checklist", "items": [
          { "title": "Squats 3x8", "done": false },
          { "title": "Lunges 3x10", "done": false },
          { "title": "Calf raises 3x15", "done": false }
        ] },
        { "type": "map", "lat": 24.7012, "lon": 46.6779, "label": "Gym, King Fahd Rd", "span": 800 }
      ] },
    { "when": { "place": "home" }, "title": "Home",
      "blocks": [
        { "type": "text", "style": "title", "text": "You're home" },
        { "type": "list", "items": ["Bins go out tonight", "Water the plants", "Call Mom"] },
        { "type": "map", "lat": 24.7741, "lon": 46.7386, "label": "Home", "span": 800 }
      ] }
  ],
  "sizes": { "small": [0], "medium": [0, 1], "large": [0, 1, 2] },
  "lock": { "rectangular": 1, "inline": "Right now" }
}
```

- The first matching version wins, so the night version comes first: at 23:00 at home the user sees "Wind down".
- Every version has three blocks in the same order (a heading, a list or checklist, a map of where it applies), so `sizes` and `lock` fit all of them.
- Medium: heading (24) + a 3-row list (60) is 94 pt, the limit. Keep lists to 3 items. Large adds the map, so it's more than half full.
- The maps use place names as labels, never coordinates in text. The coordinates come from the user's saved places or the context's `location`.
- Ticks in the gym checklist are saved in that version. When you rewrite the widget, copy them from `list_widgets` (`variants[2].blocks[1]`).
- Versions are replaced on every `set_widget`: always send all of them.

## Place names

```javascript
const ctx = await droplet_get_phone_context();
const places = ctx.places ?? [];   // ["home", "work", "gym"], always lowercase
```

Use names from `places` exactly, or `"away"` (not at any saved place). A place the user hasn't saved never matches, and the checker warns when it can see the saved list. If `places` is missing, the user doesn't share Place: ask them to save places and turn it on, or use time versions instead.

## Preview each version

`droplet_preview_widget` with the draft plus `"place": "gym"` (and `"at": "18:00"` to stay out of the night version). Days can't be previewed.
