forked from fyne-io/fyne
/
information.go
39 lines (32 loc) · 1.23 KB
/
information.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
package dialog
import (
"fyne.io/fyne"
"fyne.io/fyne/theme"
"fyne.io/fyne/widget"
)
func createTextDialog(title, message string, icon fyne.Resource, parent fyne.Window) Dialog {
d := newDialog(title, message, icon, nil, parent)
d.dismiss = &widget.Button{Text: "OK",
OnTapped: func() {
d.response <- false
},
}
d.setButtons(newButtonList(d.dismiss))
return d
}
// NewInformation creates a dialog over the specified window for user information.
// The title is used for the ialog window and message is the content.
// After creation you should call Show().
func NewInformation(title, message string, parent fyne.Window) Dialog {
return createTextDialog(title, message, theme.InfoIcon(), parent)
}
// ShowInformation shows a dialog over the specified window for user
// information. The title is used for the dialog window and message is the content.
func ShowInformation(title, message string, parent fyne.Window) {
NewInformation(title, message, parent).Show()
}
// ShowError shows a dialog over the specified window for an application
// error. The title and message are extracted from the provided error.
func ShowError(err error, parent fyne.Window) {
createTextDialog("Error", err.Error(), theme.WarningIcon(), parent).Show()
}