Spinner
Spinner shows that the page function is busy, and returns the function that takes it down again.
API
Interface
func Spinner(c *tgframe.Container, label string, conf ...*SpinnerConf) func()
Parameters
c: Parent container.label: Text shown beside the spinner.conf: Optional configuration, at most one.
// SpinnerConf is the configuration for the Spinner component.
type SpinnerConf struct {
tgframe.Base // ID
}
The spinner sits in an Empty slot, so taking it down leaves the page as if it had never been there. The returned function may be called more than once; only the first call does anything.
Taking it down is the only thing a spinner is asked to do afterwards, so it
hands back a bare func() rather than a handle. See what a component hands
back.
Example
if tgcomp.Button(p.Main, "Spin for three seconds") {
stop := tgcomp.Spinner(p.Main, "Working…")
time.Sleep(3 * time.Second)
stop()
tgcomp.Text(p.Main, "Done!")
}
Call it with defer and the spinner is taken down however the work ends, a
panic included:
defer tgcomp.Spinner(c, "Loading…")()