/
doc.go
69 lines (69 loc) · 2.06 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Package fyner provides a declarative wrapper around the Fyne UI
// library.
//
// Fyner's approach to structuring the UI and state management of an
// app is very difference from Fyne's. Fyner provides its own set of
// widgets that wrap the basic Fyne widgets, providing similar
// functionality but in a far more declarative way. To differentiate,
// Fyner refers to its own widgets as "components".
//
// Fyner components are instantiated manually as struct pointer
// literals. They export a number of fields which may be set, some of
// which are of a type from the state package. The fields of a
// component should not be changed after it is created, though if any
// of the fields are mutable state types, they may be set via the
// state API.
//
// For example, to create a center-layout container that contains a
// single label:
//
// &fyner.Center{
// Child: &fyner.Label{
// Text: state.Static("This is an example."),
// },
// }
//
// To interact with the typical Fyne UI system, a Content function is
// provided that turns a Fyner component into a Fyne CanvasObject.
// This is typically only used at the top-level in order to set the
// content of a window, hence the name, but it can actually be used
// anywhere that a client might want to insert a component into a
// regular Fyne UI layout.
//
// To illustrate the whole system, here's a complete example:
//
// package main
//
// import (
// "deedles.dev/fyner"
// "deedles.dev/fyner/state"
// "fyne.io/fyne/v2/app"
// )
//
// func main() {
// a := app.New()
//
// text := state.Mutable("This is an example.")
//
// w := a.NewWindow("Example")
// w.SetContent(fyner.Content(
// &fyner.Center{
// Child: &fyner.Box{
// Children: []fyner.Component{
// &fyner.Label{
// Text: text,
// },
// &fyner.Button{
// Text: state.Static("Greet"),
// OnTapped: func() {
// text.Set("Hi.")
// },
// },
// },
// },
// },
// ))
//
// w.ShowAndRun()
// }
package fyner