-
Notifications
You must be signed in to change notification settings - Fork 5
/
dialog.go
65 lines (53 loc) · 1.51 KB
/
dialog.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
package main
import (
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
)
func popup(width int, height int, primitive tview.Primitive) *tview.Flex {
flex := tview.NewFlex().
AddItem(nil, 0, 1, false).
AddItem(tview.NewFlex().SetDirection(tview.FlexRow).
AddItem(nil, 0, 1, false).
AddItem(primitive, height, 1, true).
AddItem(nil, 0, 1, false), width, 1, true).
AddItem(nil, 0, 1, false)
return flex
}
func showFailWindow(msg string) {
fail := tview.NewModal().
SetText(msg).
AddButtons([]string{"OK"}).
SetDoneFunc(func(buttonIndex int, buttonLabel string) {
layoutRoot.RemovePage("fail")
})
fail.SetBackgroundColor(tcell.ColorHotPink)
layoutRoot.AddPage("fail", fail, true, true)
}
func showSuccessWindow(msg string, callback func()) {
succ := tview.NewModal().
SetText(msg).
AddButtons([]string{"OK"}).
SetDoneFunc(func(buttonIndex int, buttonLabel string) {
// update info window & mainFrame window
layoutRoot.RemovePage("success")
if callback != nil {
callback()
}
})
succ.SetBackgroundColor(tcell.ColorLightGreen)
layoutRoot.AddPage("success", succ, true, true)
}
func showInfoWindow(msg string, callback func()) {
succ := tview.NewModal().
SetText(msg).
AddButtons([]string{"OK"}).
SetDoneFunc(func(buttonIndex int, buttonLabel string) {
// update info window & mainFrame window
layoutRoot.RemovePage("info")
if callback != nil {
callback()
}
})
succ.SetBackgroundColor(tcell.ColorDarkOrange)
layoutRoot.AddPage("info", succ, true, true)
}