dialog

package
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package dialog shows the platform's own dialogs: alerts, confirmations, action sheets, short toasts, and date and time pickers. Each call waits for the user, so call them from an action or effect, not in Render:

place := ui.UseAction(c, func(ctx context.Context, o Order) (bool, error) {
	return dialog.Confirm(ctx, "Cancel order?", "This can't be undone.", "Cancel order", true)
})

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alert

func Alert(ctx context.Context, title, message string) error

Alert tells the user something, with one OK button.

func Choose

func Choose(ctx context.Context, title string, options ...string) (int, error)

Choose shows options as an action sheet with a Cancel button, and returns the index of the one chosen, or -1.

func Confirm

func Confirm(ctx context.Context, title, message, confirm string, destructive bool) (bool, error)

Confirm asks yes or no: it is true when the user chose confirm. destructive marks confirm as dangerous (red on iOS).

func PickDate

func PickDate(ctx context.Context, mode Mode, initial time.Time) (t time.Time, ok bool, err error)

PickDate shows the platform's date or time picker starting at initial, in the device's time zone. ok is false when the user cancelled.

func Show

func Show(ctx context.Context, o Options) (int, error)

Show shows a dialog and returns the index of the button the user chose, or -1 when they dismissed it without choosing.

func Toast

func Toast(ctx context.Context, message string) error

Toast shows a short message that goes away by itself.

Types

type Button

type Button struct {
	Label string `json:"label"`
	// Style is "default", "cancel" (placed apart, chosen by tapping outside
	// or Back) or "destructive" (red on iOS).
	Style string `json:"style,omitempty"`
}

Button is one choice in a dialog.

type Mode

type Mode string

Mode is what PickDate asks for.

const (
	Date     Mode = "date"
	Time     Mode = "time"
	DateTime Mode = "datetime"
)

type Options

type Options struct {
	Title   string   `json:"title"`
	Message string   `json:"message,omitempty"`
	Buttons []Button `json:"buttons"`
	// Sheet shows the buttons as an action sheet (from the bottom on iOS, a
	// list on Android) instead of an alert.
	Sheet bool `json:"sheet,omitempty"`
}

Options describe a dialog for Show.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL