LeCodesdocs

Toast & SvgSource

Two small platform globals: a transient notification, and a wrapper that turns raw SVG XML into an image source.

toast

TypeScript
toast(msg: string): void

Show a transient toast notification — a quick "Saved", "Copied", "No connection". Fire-and-forget; the host shows and dismisses it.

TypeScript
toast('Saved!')

SvgSource

TypeScript
SvgSource(svg: string): { readonly svg: string, tintColor: string | null }

Wrap a raw SVG XML string so it can be used wherever an image source is accepted (e.g. a UIImage's src — see UI content). Set tintColor on the returned value to recolor the SVG; null (the default) means untinted.

TypeScript
const icon = SvgSource('<svg viewBox="0 0 24 24"><path d="M12 2 L22 22 H2 Z"/></svg>')
icon.tintColor = '#4caf50'
const img = UIImage(icon)
Note

importing a .svg file from the project does this for you — the compiler turns import icon from './icon.svg' into a ready-made SvgSource value.

See also

  • UI contentUIImage and the full set of image sources
  • NetworkingFetchResponse/File as the other image sources