2021-07-30 22:29:20 +00:00
|
|
|
package gui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"image/color"
|
|
|
|
"time"
|
2021-08-02 19:55:04 +00:00
|
|
|
|
|
|
|
"github.com/liamg/darktile/internal/app/darktile/gui/popup"
|
2021-07-30 22:29:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
popupMessageDisplayDuration = time.Second * 5
|
|
|
|
popupErrorDisplayDuration = time.Second * 10
|
|
|
|
)
|
|
|
|
|
|
|
|
func (g *GUI) ShowPopup(msg string, fg color.Color, bg color.Color, duration time.Duration) {
|
2021-08-02 19:55:04 +00:00
|
|
|
g.popupMessages = append(g.popupMessages, popup.Message{
|
2021-07-30 22:29:20 +00:00
|
|
|
Text: msg,
|
|
|
|
Expiry: time.Now().Add(duration),
|
|
|
|
Foreground: fg,
|
|
|
|
Background: bg,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *GUI) ShowError(msg string) {
|
|
|
|
g.ShowPopup(fmt.Sprintf("Error!\n%s", msg), color.White, color.RGBA{A: 0xff, R: 0xff}, popupErrorDisplayDuration)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *GUI) ShowMessage(msg string) {
|
|
|
|
g.ShowPopup(msg, color.White, color.RGBA{A: 0xff, G: 0x40, R: 0x40, B: 0xff}, popupMessageDisplayDuration)
|
|
|
|
}
|