package common

import (
	"image/color"
	"time"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/canvas"
	"fyne.io/fyne/v2/driver/desktop"
	"fyne.io/fyne/v2/widget"
)

// 显示Tip
func ShowTip(content string) {
	drv := fyne.CurrentApp().Driver()
	if drv, ok := drv.(desktop.Driver); ok {
		w := drv.CreateSplashWindow()
		w.SetContent(widget.NewLabelWithStyle(content, fyne.TextAlignCenter, fyne.TextStyle{}))
		w.Show()

		go func() {
			time.Sleep(time.Millisecond * 1500)
			w.Close()
		}()
	}
}

func ShowCanvasTip(content string) {
	drv := fyne.CurrentApp().Driver()
	if drv, ok := drv.(desktop.Driver); ok {
		w := drv.CreateSplashWindow()
		w.SetContent(canvas.NewText(content, color.RGBA{255, 0, 0, 255}))
		w.Show()

		go func() {
			time.Sleep(time.Millisecond * 1500)
			w.Close()
		}()
	}
}