package ui

import (
	"go_dreamfactory/cmd/v2/lib/common"
	"net/url"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/dialog"
	"fyne.io/fyne/v2/widget"
)

type about struct {
	aboutDialog dialog.Dialog
}

func newAbout() *about {
	var a about
	ver := toolWin.app.Metadata().Version
	link, _ := url.Parse("http://10.0.0.9:8080")
	wlink := widget.NewHyperlinkWithStyle("更新包", link, fyne.TextAlignLeading, fyne.TextStyle{})
	content := widget.NewCard("", "", widget.NewRichTextFromMarkdown(
		`
		梦工厂项目辅助工具GUI
		@v`+ver,
	))
	a.aboutDialog = dialog.NewCustom(common.APP_ABOUT_TITLE, common.APP_ABOUT_CONFIRM,
		container.NewVBox(content, wlink), toolWin.w)

	return &a
}

func showAbout() {
	newAbout().aboutDialog.Show()
}
