Toddy.Iced.Widget.QrCode (Toddy v0.3.0)

Copy Markdown View Source

QR Code -- renders a QR code from a data string.

Uses the iced canvas to draw a grid of cells representing the encoded data.

Props

  • data (string) -- the data to encode in the QR code. Required.
  • cell_size (number) -- size of each QR module in pixels. Default: 4.0.
  • cell_color (color) -- color of dark modules. Default: black.
  • background_color (color) -- color of light modules. Default: white.
  • error_correction (atom) -- error correction level. One of :low, :medium (default), :quartile, :high.
  • a11y (map) -- accessibility overrides. See Toddy.Iced.A11y.

Summary

Functions

Sets accessibility annotations.

Sets the background color (light modules).

Converts this QR code struct to a ui_node() map via the Toddy.Iced.Widget protocol.

Sets the color of dark modules.

Sets the cell size (pixels per QR module).

Sets the error correction level.

Creates a new QR code struct with the given data string and optional keyword opts.

Applies keyword options to an existing QR code struct.

Types

error_correction()

@type error_correction() :: :high | :quartile | :medium | :low

option()

@type option() ::
  {:cell_size, number()}
  | {:cell_color, Toddy.Iced.Color.input()}
  | {:background_color, Toddy.Iced.Color.input()}
  | {:error_correction, error_correction()}
  | {:a11y, Toddy.Iced.A11y.t()}

t()

@type t() :: %Toddy.Iced.Widget.QrCode{
  a11y: Toddy.Iced.A11y.t() | nil,
  background_color: Toddy.Iced.Color.t() | nil,
  cell_color: Toddy.Iced.Color.t() | nil,
  cell_size: number() | nil,
  data: String.t(),
  error_correction: error_correction() | nil,
  id: String.t()
}

Functions

a11y(qr, a11y)

@spec a11y(qr_code :: t(), a11y :: Toddy.Iced.A11y.t()) :: t()

Sets accessibility annotations.

background_color(qr, background_color)

@spec background_color(qr_code :: t(), background_color :: Toddy.Iced.Color.input()) ::
  t()

Sets the background color (light modules).

build(qr)

@spec build(qr_code :: t()) :: Toddy.Iced.ui_node()

Converts this QR code struct to a ui_node() map via the Toddy.Iced.Widget protocol.

cell_color(qr, cell_color)

@spec cell_color(qr_code :: t(), cell_color :: Toddy.Iced.Color.input()) :: t()

Sets the color of dark modules.

cell_size(qr, cell_size)

@spec cell_size(qr_code :: t(), cell_size :: number()) :: t()

Sets the cell size (pixels per QR module).

error_correction(qr, ec)

@spec error_correction(qr_code :: t(), error_correction :: error_correction()) :: t()

Sets the error correction level.

new(id, data, opts \\ [])

@spec new(id :: String.t(), data :: String.t(), opts :: [option()]) :: t()

Creates a new QR code struct with the given data string and optional keyword opts.

with_options(qr, opts)

@spec with_options(qr_code :: t(), opts :: [option()]) :: t()

Applies keyword options to an existing QR code struct.