show What's New dialog when launching updated version
This commit is contained in:
@@ -66,8 +66,8 @@ func (a *AboutDialog) buildMainTabContainer(version string) *fyne.Container {
|
||||
ts := license.Segments[0].(*widget.TextSegment)
|
||||
ts.Style.TextStyle.Bold = true
|
||||
ts.Style.Alignment = fyne.TextAlignCenter
|
||||
ghUrl, _ := url.Parse("https://github.com/dweymouth/supersonic")
|
||||
kofiUrl, _ := url.Parse("https://ko-fi.com/dweymouth")
|
||||
ghUrl, _ := url.Parse(res.GithubURL)
|
||||
kofiUrl, _ := url.Parse(res.KofiURL)
|
||||
githubKofi := container.NewCenter(
|
||||
container.New(&layouts.HboxCustomPadding{DisableThemePad: true, ExtraPad: -10},
|
||||
widget.NewHyperlink("Github page", ghUrl),
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package dialogs
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"github.com/dweymouth/supersonic/res"
|
||||
"github.com/dweymouth/supersonic/ui/layouts"
|
||||
)
|
||||
|
||||
type WhatsNewDialog struct {
|
||||
widget.BaseWidget
|
||||
}
|
||||
|
||||
func NewWhatsNewDialog() *WhatsNewDialog {
|
||||
w := &WhatsNewDialog{}
|
||||
w.ExtendBaseWidget(w)
|
||||
return w
|
||||
}
|
||||
|
||||
func (w *WhatsNewDialog) CreateRenderer() fyne.WidgetRenderer {
|
||||
objects := container.NewVBox()
|
||||
if res.WhatsAdded != "" {
|
||||
added := widget.NewRichTextFromMarkdown(res.WhatsAdded)
|
||||
added.Wrapping = fyne.TextWrapWord
|
||||
objects.Add(added)
|
||||
}
|
||||
if res.WhatsFixed != "" {
|
||||
fixed := widget.NewRichTextFromMarkdown(res.WhatsFixed)
|
||||
fixed.Wrapping = fyne.TextWrapWord
|
||||
objects.Add(fixed)
|
||||
}
|
||||
|
||||
ghUrl, _ := url.Parse(res.GithubURL)
|
||||
kofiUrl, _ := url.Parse(res.KofiURL)
|
||||
githubKofi := container.NewCenter(
|
||||
container.New(&layouts.HboxCustomPadding{DisableThemePad: true, ExtraPad: -10},
|
||||
widget.NewHyperlink("Github page", ghUrl),
|
||||
widget.NewLabel("·"),
|
||||
widget.NewHyperlink("Support the project", kofiUrl)))
|
||||
objects.Add(githubKofi)
|
||||
|
||||
c := container.NewVScroll(objects)
|
||||
return widget.NewSimpleRenderer(c)
|
||||
}
|
||||
|
||||
func (w *WhatsNewDialog) MinSize() fyne.Size {
|
||||
return fyne.NewSize(400, 250)
|
||||
}
|
||||
+12
-2
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/dweymouth/supersonic/res"
|
||||
"github.com/dweymouth/supersonic/ui/browsing"
|
||||
"github.com/dweymouth/supersonic/ui/controller"
|
||||
"github.com/dweymouth/supersonic/ui/dialogs"
|
||||
"github.com/dweymouth/supersonic/ui/os"
|
||||
"github.com/dweymouth/supersonic/ui/theme"
|
||||
|
||||
@@ -93,8 +94,13 @@ func NewMainWindow(fyneApp fyne.App, appName, displayAppName, appVersion string,
|
||||
app.ServerManager.OnServerConnected(func() {
|
||||
m.BrowsingPane.EnableNavigationButtons()
|
||||
m.Router.NavigateTo(m.StartupPage())
|
||||
// check if found new version on startup
|
||||
if t := app.UpdateChecker.VersionTagFound(); t != "" && t != app.Config.Application.LastCheckedVersion {
|
||||
// check if launching new version, else if found available update on startup
|
||||
if l := app.Config.Application.LastLaunchedVersion; app.VersionTag() != l {
|
||||
if !app.IsFirstLaunch() {
|
||||
m.ShowWhatsNewDialog()
|
||||
}
|
||||
m.App.Config.Application.LastLaunchedVersion = app.VersionTag()
|
||||
} else if t := app.UpdateChecker.VersionTagFound(); t != "" && t != app.Config.Application.LastCheckedVersion {
|
||||
if t != app.VersionTag() {
|
||||
m.ShowNewVersionDialog(displayAppName, t)
|
||||
}
|
||||
@@ -202,6 +208,10 @@ func (m *MainWindow) ShowNewVersionDialog(appName, versionTag string) {
|
||||
})
|
||||
}
|
||||
|
||||
func (m *MainWindow) ShowWhatsNewDialog() {
|
||||
dialog.ShowCustom("What's new in "+res.AppVersion, "Close", dialogs.NewWhatsNewDialog(), m.Window)
|
||||
}
|
||||
|
||||
func (m *MainWindow) addNavigationButtons() {
|
||||
m.BrowsingPane.AddNavigationButton(theme.NowPlayingIcon, func() {
|
||||
m.Router.NavigateTo(controller.NowPlayingRoute(""))
|
||||
|
||||
Reference in New Issue
Block a user