> ## Documentation Index
> Fetch the complete documentation index at: https://docs.clariodesk.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Swift prebuilt UI

> A themeable SwiftUI support UI you present with one call, from SwiftUI or UIKit.

`ClarioDeskUI` is a drop-in support UI built in SwiftUI. One static call
presents it as a self-owned modal on the top-most view controller, so it works
identically from SwiftUI and UIKit hosts with zero setup — your navigation
stack is never touched. On iPhone it's full-screen; on iPad (regular width)
it's a centered form-sheet card.

## Open a screen

```swift theme={null}
import ClarioDeskUI

ClarioDeskWidgets.openInbox()
```

From there, the SDK handles inbox → thread → composer → attachment viewer
internally. Control returns to your app when the user dismisses the modal.

All entry points:

```swift theme={null}
ClarioDeskWidgets.openInbox()                 // the user's conversations
ClarioDeskWidgets.openNewTicket()             // straight into the composer
ClarioDeskWidgets.openBugReport()             // bug report form (auto-screenshot)
ClarioDeskWidgets.openConversation(ticketId)  // one thread — the push deep-link target
```

Each takes optional `theme:`, `strings:`, and `from:` (an explicit presenting
`UIViewController`; omitted, the SDK finds the top-most one itself).

## The four screens

| Screen               | What it does                                                                                                             |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| **Inbox**            | The user's list of conversations, with whose-turn chips.                                                                 |
| **Thread**           | The message thread, with a reply composer, typing, read receipts, and the CSAT prompt on resolve.                        |
| **New conversation** | Subject + body form.                                                                                                     |
| **Bug report**       | Description + a removable screenshot tile, captured **before** the modal presents so the SDK's own UI is never in frame. |

Plus an attachment viewer: zoomable images (with save), and **in-app HLS video
via `AVPlayer`** — a deliberate upward divergence from the Flutter/RN SDKs,
where in-app video playback would ship an ExoPlayer-weight dependency to every
host. AVPlayer is free and native on iOS.

## Theming

The theme is 13 optional tokens. Every unset token derives from sensible
light/dark defaults keyed off the system color scheme, so a zero-config
install already matches the host. Token names are 1:1 with the Flutter theme.

```swift theme={null}
let theme = ClarioDeskTheme(
  primary: Color(red: 0.83, green: 1.0, blue: 0.0),
  background: Color(white: 0.05),
  primaryText: .white,
  cornerRadius: 18
)

ClarioDeskWidgets.openInbox(theme: theme)
```

| Token                 | Notes                                                        |
| --------------------- | ------------------------------------------------------------ |
| `primary`             | Accent — send button, links, unread dot, own-message bubble. |
| `onPrimary`           | Text/icon drawn on `primary`.                                |
| `background`          | Screen background.                                           |
| `primaryText`         | Body text.                                                   |
| `secondaryText`       | Timestamps and metadata.                                     |
| `componentBackground` | Composer field + received-message bubbles.                   |
| `componentBorder`     | Dividers and input borders.                                  |
| `placeholderText`     | Composer placeholder.                                        |
| `appBarBackground`    | App bar background (defaults to `background`).               |
| `appBarForeground`    | App bar title + icons (defaults to `primaryText`).           |
| `error`               | Failed sends, bug-report accents.                            |
| `cornerRadius`        | Bubbles, inputs, cards. Default 14.                          |
| `borderWidth`         | Inputs and dividers. Default 1.                              |

<Note>
  The UI carries a WCAG 4.5:1 contrast guard: if a theme color would make text
  unreadable on its background (a pastel accent, say), the SDK falls back to
  black/white for the on-color instead of shipping unreadable text.
</Note>

## Strings

\~50 user-facing strings are overridable for copy tweaks and localization —
English defaults, and no agent jargon (never "ticket" or raw statuses).
Field names are 1:1 with the Flutter `ClarioDeskStrings`.

```swift theme={null}
ClarioDeskWidgets.openInbox(
  strings: ClarioDeskStrings(
    inboxTitle: "Support",
    newConversationCta: "New conversation"
  )
)
```

## Shake to report a bug

Opt-in: a deliberate shake captures a screenshot and opens the bug-report
form. Foreground-only, debounced (5 s cooldown), suppressed while the support
modal is already up, and needs no `Info.plist` key.

```swift theme={null}
ClarioDeskWidgets.enableShakeReport()   // idempotent; call once at launch
ClarioDeskWidgets.disableShakeReport()
```

<Warning>
  Shake detection uses the CoreMotion accelerometer, so it does **not** fire on
  the iOS Simulator (`⌃⌘Z` sends a UIKit motion event, not an accelerometer
  sample). Verify on a physical device.
</Warning>

## Headless instead?

Everything the prebuilt screens do rides the same public methods — see the
[API reference](/swift/api-reference) to build the UI in your own design
system.
