itd/cmd/itgui/notify.go

38 lines
868 B
Go
Raw Normal View History

2021-08-26 04:18:24 +00:00
package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/widget"
2021-10-24 20:27:14 +00:00
"go.arsenm.dev/itd/api"
2021-08-26 04:18:24 +00:00
)
2021-10-24 20:27:14 +00:00
func notifyTab(parent fyne.Window, client *api.Client) *fyne.Container {
2021-08-26 15:47:17 +00:00
// Create new entry for notification title
2021-08-26 04:18:24 +00:00
titleEntry := widget.NewEntry()
titleEntry.SetPlaceHolder("Title")
2021-08-26 15:47:17 +00:00
// Create multiline entry for notification body
2021-08-26 04:18:24 +00:00
bodyEntry := widget.NewMultiLineEntry()
bodyEntry.SetPlaceHolder("Body")
2021-08-26 15:47:17 +00:00
// Create new button to send notification
2021-08-26 04:18:24 +00:00
sendBtn := widget.NewButton("Send", func() {
2021-10-24 20:27:14 +00:00
err := client.Notify(titleEntry.Text, bodyEntry.Text)
2021-08-26 04:18:24 +00:00
if err != nil {
2021-10-24 20:27:14 +00:00
guiErr(err, "Error sending notification", false, parent)
2021-08-26 04:18:24 +00:00
return
}
})
2021-08-26 15:47:17 +00:00
// Return new container containing all elements
2021-08-26 04:18:24 +00:00
return container.NewVBox(
layout.NewSpacer(),
titleEntry,
bodyEntry,
sendBtn,
layout.NewSpacer(),
)
}