# `Dala.Ui.Scan`
[🔗](https://github.com/manhvu/dala/blob/main/lib/dala/ui/scan.ex#L1)

Parsers for common NFC tag payloads and QR/barcode content.

Takes a raw string from an NFC tag read or barcode scan and returns a
structured map with `:type` and `:value` fields.

## Supported formats

| Type | Example raw input | `:value` shape |
|------|-------------------|-----------------|
| `:url` | `https://example.com` | `String.t()` |
| `:wifi` | `WIFI:T:WPA;S:MyNet;P:pass;H:true;;` | `%{ssid, password, security, hidden}` |
| `:email` | `mailto:user@example.com` | `%{email, subject, body}` |
| `:phone` | `tel:+1234567890` | `%{number}` |
| `:sms` | `smsto:+1234567890:hello` | `%{number, message}` |
| `:geo` | `geo:37.78,-122.40?q=Golden+Gate` | `%{lat, lon, query, altitude}` |
| `:vcard` | `BEGIN:VCARD...END:VCARD` | `%{name, phone, email, org, title, url, address}` |
| `:vevent` | `BEGIN:VEVENT...END:VEVENT` | `%{summary, start, end, location, description}` |
| `:text` | `Hello world` | `String.t()` |

## Usage

    # Parse an NFC tag payload
    Dala.Ui.Scan.parse("WIFI:T:WPA;S:MyNet;P:secret;;")
    # => %{type: :wifi, value: %{ssid: "MyNet", password: "secret", security: :wpa, hidden: false}}

    # Parse a QR code value
    Dala.Ui.Scan.parse("https://example.com")
    # => %{type: :url, value: "https://example.com"}

    # Parse a vCard
    Dala.Ui.Scan.parse("BEGIN:VCARD\nVERSION:3.0\nFN:John Doe\nTEL:+1234567890\nEND:VCARD")
    # => %{type: :vcard, value: %{name: "John Doe", phone: "+1234567890", ...}}

# `parsed`

```elixir
@type parsed() :: %{
  type: :url | :wifi | :email | :phone | :sms | :geo | :vcard | :vevent | :text,
  value: term()
}
```

# `parse`

```elixir
@spec parse(String.t()) :: parsed()
```

Parse a raw NFC/barcode string into a structured format.

Returns `%{type: atom, value: term()}` or `%{type: :text, value: raw}` as fallback.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
