-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.go
56 lines (49 loc) · 1.62 KB
/
helpers.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
package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
)
type Helper struct{}
func (h *Helper) CreateHeader(inputLangSelect, outputLangSelect *widget.Select, switchButton *widget.Button) fyne.CanvasObject {
return container.NewBorder(nil, nil,
container.NewHBox(inputLangSelect),
container.NewHBox(outputLangSelect),
container.NewHBox(layout.NewSpacer(), switchButton, layout.NewSpacer()),
)
}
func (h *Helper) NewClearButton(onClick func()) *widget.Button {
clearButton := widget.NewButtonWithIcon("", theme.ContentClearIcon(), onClick)
clearButton.Importance = widget.LowImportance
return clearButton
}
func (h *Helper) CreateInputContainer(clearButton *widget.Button) fyne.CanvasObject {
return container.NewStack(
inputBox,
container.NewStack(
container.NewVBox(
container.New(layout.NewHBoxLayout(), layout.NewSpacer(), container.NewPadded(clearButton)),
layout.NewSpacer(),
),
),
)
}
func (h *Helper) NewCopyButton(onClick func()) *widget.Button {
copyButton := widget.NewButtonWithIcon("Copy", theme.ContentCopyIcon(), onClick)
copyButton.Importance = widget.LowImportance
return copyButton
}
func (h *Helper) CreateOutputContainer(copyButton *widget.Button, settingsButton *widget.Button) fyne.CanvasObject {
// @todo: buttons stay on the text. should be fix.
return container.NewStack(
outputBox,
container.NewStack(
container.NewVBox(
layout.NewSpacer(),
container.New(layout.NewHBoxLayout(), container.NewPadded(settingsButton), layout.NewSpacer(), container.NewPadded(copyButton)),
),
),
)
}