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 ¶
- func Alert(ctx context.Context, title, message string) error
- func Choose(ctx context.Context, title string, options ...string) (int, error)
- func Confirm(ctx context.Context, title, message, confirm string, destructive bool) (bool, error)
- func PickDate(ctx context.Context, mode Mode, initial time.Time) (t time.Time, ok bool, err error)
- func Show(ctx context.Context, o Options) (int, error)
- func Toast(ctx context.Context, message string) error
- type Button
- type Mode
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Choose ¶
Choose shows options as an action sheet with a Cancel button, and returns the index of the one chosen, or -1.
func Confirm ¶
Confirm asks yes or no: it is true when the user chose confirm. destructive marks confirm as dangerous (red on iOS).
func PickDate ¶
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.
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 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.
Click to show internal directories.
Click to hide internal directories.