Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refractor project structure #470

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions fyne/pages/accounts.go → fyne/pages/accounts/accounts.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package pages
package accounts

import (
"fyne.io/fyne"
"fyne.io/fyne/widget"
)

func accountsPageContent() fyne.CanvasObject {
func PageContent() fyne.CanvasObject {
return widget.NewLabelWithStyle("Accounts", fyne.TextAlignLeading, fyne.TextStyle{Bold: true, Italic: true})
}
2 changes: 1 addition & 1 deletion fyne/pages/createAndRestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/raedahgroup/dcrlibwallet"

"github.com/raedahgroup/godcr/fyne/assets"
"github.com/raedahgroup/godcr/fyne/pages/handler/values"
"github.com/raedahgroup/godcr/fyne/values"
"github.com/raedahgroup/godcr/fyne/widgets"
)

Expand Down
33 changes: 13 additions & 20 deletions fyne/pages/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (

"github.com/decred/slog"
"github.com/raedahgroup/dcrlibwallet"

"github.com/raedahgroup/godcr/fyne/assets"
)

type AppInterface struct {
Expand All @@ -22,7 +20,8 @@ type AppInterface struct {
Window fyne.Window
AppDisplayName string

tabMenu *widget.TabContainer
tabMenu *widget.TabContainer
handlers *pageHandlers
}

func (app *AppInterface) DisplayLaunchErrorAndExit(errorMessage string) {
Expand Down Expand Up @@ -56,29 +55,23 @@ func (app *AppInterface) DisplayMainWindow() {
app.Window.SetFixedSize(true)
app.Window.CenterOnScreen()
fyne.CurrentApp().Settings().SetTheme(theme.LightTheme())
go app.handlers.overviewHandler.PreserveSyncSteps()
app.Window.ShowAndRun()
app.tearDown()
}

func (app *AppInterface) setupNavigationMenu() {
icons, err := assets.GetIcons(assets.OverviewIcon, assets.HistoryIcon, assets.SendIcon,
assets.ReceiveIcon, assets.AccountsIcon, assets.StakeIcon)
var err error
p := initiatePages(app.MultiWallet, app.tabMenu, app.Window)

app.handlers = p.pageHandlers()
app.tabMenu, err = p.NewTab()
if err != nil {
app.DisplayLaunchErrorAndExit(fmt.Sprintf("An error occured while loading app icons: %s", err))
return
}

app.tabMenu = widget.NewTabContainer(
widget.NewTabItemWithIcon("Overview", icons[assets.OverviewIcon], overviewPageContent(app)),
widget.NewTabItemWithIcon("History", icons[assets.HistoryIcon], widget.NewHBox()),
widget.NewTabItemWithIcon("Send", icons[assets.SendIcon], widget.NewHBox()),
widget.NewTabItemWithIcon("Receive", icons[assets.ReceiveIcon], widget.NewHBox()),
widget.NewTabItemWithIcon("Accounts", icons[assets.AccountsIcon], widget.NewHBox()),
widget.NewTabItemWithIcon("Staking", icons[assets.StakeIcon], widget.NewHBox()),
)
app.tabMenu.SetTabLocation(widget.TabLocationLeading)

app.Window.SetContent(app.tabMenu)
go func() {
var currentTabIndex = 0
Expand All @@ -102,17 +95,17 @@ func (app *AppInterface) setupNavigationMenu() {

switch currentTabIndex {
case 0:
newPageContent = overviewPageContent(app)
newPageContent = p.overviewPage()
case 1:
newPageContent = historyPageContent()
newPageContent = p.historyPage()
case 2:
newPageContent = sendPageContent(app.MultiWallet, app.Window)
newPageContent = p.sendPage()
case 3:
newPageContent = receivePageContent(app.MultiWallet, app.Window)
newPageContent = p.receivePage()
case 4:
newPageContent = accountsPageContent()
newPageContent = p.accountsPage()
case 5:
newPageContent = stakingPageContent()
newPageContent = p.stakingPage()
}

if activePageBox, ok := app.tabMenu.Items[currentTabIndex].Content.(*widget.Box); ok {
Expand Down
4 changes: 2 additions & 2 deletions fyne/pages/history.go → fyne/pages/history/history.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package pages
package history

import (
"fyne.io/fyne"
"fyne.io/fyne/widget"
)

func historyPageContent() fyne.CanvasObject {
func PageContent() fyne.CanvasObject {
return widget.NewLabelWithStyle("History", fyne.TextAlignLeading, fyne.TextStyle{Bold: true, Italic: true})
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/raedahgroup/dcrlibwallet"

"github.com/raedahgroup/godcr/fyne/assets"
"github.com/raedahgroup/godcr/fyne/pages/handler/values"
"github.com/raedahgroup/godcr/fyne/values"
"github.com/raedahgroup/godcr/fyne/widgets"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/decred/dcrd/dcrutil"
"github.com/raedahgroup/dcrlibwallet"

"github.com/raedahgroup/godcr/fyne/pages/handler/values"
"github.com/raedahgroup/godcr/fyne/values"
"github.com/raedahgroup/godcr/fyne/widgets"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/raedahgroup/dcrlibwallet"

"github.com/raedahgroup/godcr/fyne/pages/handler/values"
"github.com/raedahgroup/godcr/fyne/values"
"github.com/raedahgroup/godcr/fyne/widgets"
)

Expand Down
Loading