Skip to content

Commit

Permalink
create new page for GoHome instead of using browsing history
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed Apr 29, 2024
1 parent e4514c5 commit c161f2b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
15 changes: 2 additions & 13 deletions ui/browsing/browsingpane.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ type BrowsingPane struct {
navBtnsPageMap map[controller.PageName]fyne.Resource
}

func NewBrowsingPane(app *backend.App, contr *controller.Controller) *BrowsingPane {
func NewBrowsingPane(app *backend.App, contr *controller.Controller, onGoHome func()) *BrowsingPane {
b := &BrowsingPane{app: app}
b.ExtendBaseWidget(b)
b.home = widget.NewButtonWithIcon("", theme.HomeIcon(), b.GoHome)
b.home = widget.NewButtonWithIcon("", theme.HomeIcon(), onGoHome)
b.back = widget.NewButtonWithIcon("", theme.NavigateBackIcon(), b.GoBack)
b.forward = widget.NewButtonWithIcon("", theme.NavigateNextIcon(), b.GoForward)
b.reload = widget.NewButtonWithIcon("", theme.ViewRefreshIcon(), b.Reload)
Expand Down Expand Up @@ -269,17 +269,6 @@ func (b *BrowsingPane) updateHistoryButtons() {
}
}

func (b *BrowsingPane) GoHome() {
if len(b.history) > 0 {
homePage := b.history[0].Restore()
if b.CurrentPage() != homePage.Route() {
b.addPageToHistory(b.curPage, false)
b.doSetPage(homePage)
b.updateHistoryButtons()
}
}
}

func (b *BrowsingPane) GoBack() {
if b.historyIdx > 0 {
// due to widget reuse between pages,
Expand Down
2 changes: 1 addition & 1 deletion ui/mainwindow.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func NewMainWindow(fyneApp fyne.App, appName, displayAppName, appVersion string,
MainWindow: m.Window,
App: app,
}
m.BrowsingPane = browsing.NewBrowsingPane(app, m.Controller)
m.BrowsingPane = browsing.NewBrowsingPane(app, m.Controller, func() { m.Router.NavigateTo(m.StartupPage()) })
m.Router = browsing.NewRouter(app, m.Controller, m.BrowsingPane)
// inject controller dependencies
m.Controller.NavHandler = m.Router.NavigateTo
Expand Down

0 comments on commit c161f2b

Please sign in to comment.