add home button to navigation bar
This commit is contained in:
@@ -40,8 +40,12 @@ type BrowsingPane struct {
|
|||||||
|
|
||||||
app *backend.App
|
app *backend.App
|
||||||
|
|
||||||
|
// Invoked when the home button is clicked
|
||||||
|
OnGoHome func()
|
||||||
|
|
||||||
curPage Page
|
curPage Page
|
||||||
|
|
||||||
|
home *widget.Button
|
||||||
forward *widget.Button
|
forward *widget.Button
|
||||||
back *widget.Button
|
back *widget.Button
|
||||||
reload *widget.Button
|
reload *widget.Button
|
||||||
@@ -62,6 +66,7 @@ func NewBrowsingPane(app *backend.App) *BrowsingPane {
|
|||||||
b.ExtendBaseWidget(b)
|
b.ExtendBaseWidget(b)
|
||||||
b.searchBar = widgets.NewSearchEntry()
|
b.searchBar = widgets.NewSearchEntry()
|
||||||
b.searchBar.OnTextChanged = b.onSearchTextChanged
|
b.searchBar.OnTextChanged = b.onSearchTextChanged
|
||||||
|
b.home = widget.NewButtonWithIcon("", theme.HomeIcon(), b.goHome)
|
||||||
b.back = widget.NewButtonWithIcon("", theme.NavigateBackIcon(), b.GoBack)
|
b.back = widget.NewButtonWithIcon("", theme.NavigateBackIcon(), b.GoBack)
|
||||||
b.forward = widget.NewButtonWithIcon("", theme.NavigateNextIcon(), b.GoForward)
|
b.forward = widget.NewButtonWithIcon("", theme.NavigateNextIcon(), b.GoForward)
|
||||||
b.reload = widget.NewButtonWithIcon("", theme.ViewRefreshIcon(), b.Reload)
|
b.reload = widget.NewButtonWithIcon("", theme.ViewRefreshIcon(), b.Reload)
|
||||||
@@ -70,7 +75,7 @@ func NewBrowsingPane(app *backend.App) *BrowsingPane {
|
|||||||
canvas.NewRectangle(color.RGBA{R: 24, G: 24, B: 24, A: 255}),
|
canvas.NewRectangle(color.RGBA{R: 24, G: 24, B: 24, A: 255}),
|
||||||
layout.NewSpacer())
|
layout.NewSpacer())
|
||||||
b.container = container.NewBorder(
|
b.container = container.NewBorder(
|
||||||
container.NewHBox(b.back, b.forward, b.reload, b.searchBar),
|
container.NewHBox(b.home, b.back, b.forward, b.reload, b.searchBar),
|
||||||
nil, nil, nil, b.pageContainer)
|
nil, nil, nil, b.pageContainer)
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
@@ -116,6 +121,12 @@ func (b *BrowsingPane) addPageToHistory(p Page) {
|
|||||||
b.historyIdx++
|
b.historyIdx++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *BrowsingPane) goHome() {
|
||||||
|
if b.OnGoHome != nil {
|
||||||
|
b.OnGoHome()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (b *BrowsingPane) GoBack() {
|
func (b *BrowsingPane) GoBack() {
|
||||||
if b.historyIdx > 1 {
|
if b.historyIdx > 1 {
|
||||||
b.historyIdx -= 1
|
b.historyIdx -= 1
|
||||||
|
|||||||
+9
-1
@@ -21,12 +21,20 @@ type MainWindow struct {
|
|||||||
container *fyne.Container
|
container *fyne.Container
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
HomePage = browsing.AlbumsRoute(backend.AlbumSortRecentlyAdded)
|
||||||
|
)
|
||||||
|
|
||||||
func NewMainWindow(fyneApp fyne.App, appName string, app *backend.App) MainWindow {
|
func NewMainWindow(fyneApp fyne.App, appName string, app *backend.App) MainWindow {
|
||||||
m := MainWindow{
|
m := MainWindow{
|
||||||
Window: fyneApp.NewWindow(appName),
|
Window: fyneApp.NewWindow(appName),
|
||||||
BrowsingPane: browsing.NewBrowsingPane(app),
|
BrowsingPane: browsing.NewBrowsingPane(app),
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Router = browsing.NewRouter(app, m.BrowsingPane)
|
m.Router = browsing.NewRouter(app, m.BrowsingPane)
|
||||||
|
m.BrowsingPane.OnGoHome = func() {
|
||||||
|
m.Router.OpenRoute(HomePage)
|
||||||
|
}
|
||||||
m.BottomPanel = NewBottomPanel(app.Player, m.Router.OpenRoute)
|
m.BottomPanel = NewBottomPanel(app.Player, m.Router.OpenRoute)
|
||||||
m.BottomPanel.SetPlaybackManager(app.PlaybackManager)
|
m.BottomPanel.SetPlaybackManager(app.PlaybackManager)
|
||||||
m.BottomPanel.ImageManager = app.ImageManager
|
m.BottomPanel.ImageManager = app.ImageManager
|
||||||
@@ -41,7 +49,7 @@ func NewMainWindow(fyneApp fyne.App, appName string, app *backend.App) MainWindo
|
|||||||
m.Window.SetTitle(song.Title)
|
m.Window.SetTitle(song.Title)
|
||||||
})
|
})
|
||||||
app.ServerManager.OnServerConnected(func() {
|
app.ServerManager.OnServerConnected(func() {
|
||||||
m.Router.OpenRoute(browsing.AlbumsRoute(backend.AlbumSortRecentlyAdded))
|
m.Router.OpenRoute(HomePage)
|
||||||
})
|
})
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user