Skip to content

Commit

Permalink
Handle watch only wallets click events
Browse files Browse the repository at this point in the history
  • Loading branch information
beansgum committed Jul 2, 2021
1 parent dcf0e0d commit 068423f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 27 deletions.
4 changes: 2 additions & 2 deletions ui/page.go
Expand Up @@ -330,8 +330,8 @@ func (common *pageCommon) sortedWalletList() []*dcrlibwallet.Wallet {
return wallets
}

func (c *pageCommon) HDPrefix() string {
switch c.network {
func (common *pageCommon) HDPrefix() string {
switch common.network {
case "testnet3": // should use a constant
return dcrlibwallet.TestnetHDPath
case "mainnet":
Expand Down
35 changes: 10 additions & 25 deletions ui/wallet_page.go
Expand Up @@ -54,6 +54,7 @@ type walletPage struct {
accountIcon *widget.Image
walletAlertIcon *widget.Image
container, walletsList layout.List
watchWalletsList *decredmaterial.ClickableList
toAcctDetails []*gesture.Click
iconButton decredmaterial.IconButton
card decredmaterial.Card
Expand All @@ -75,6 +76,7 @@ func WalletPage(common *pageCommon) Page {
multiWallet: common.multiWallet,
container: layout.List{Axis: layout.Vertical},
walletsList: layout.List{Axis: layout.Vertical},
watchWalletsList: common.theme.NewClickableList(layout.Vertical),
theme: common.theme,
card: common.theme.Card(),
backdrop: new(widget.Clickable),
Expand Down Expand Up @@ -408,8 +410,6 @@ func (pg *walletPage) walletSection(gtx layout.Context, common *pageCommon) layo
return D{}
}

pg.updateAcctDetailsButtons(listItem.accounts)

collapsibleMore := func(gtx C) {
pg.layoutOptionsMenu(gtx, i, listItem)
}
Expand Down Expand Up @@ -522,7 +522,7 @@ func (pg *walletPage) watchOnlyWalletSection(gtx layout.Context) layout.Dimensio
}

func (pg *walletPage) layoutWatchOnlyWallets(gtx layout.Context) D {
return (&layout.List{Axis: layout.Vertical}).Layout(gtx, len(pg.listItems), func(gtx C, i int) D {
return pg.watchWalletsList.Layout(gtx, len(pg.listItems), func(gtx C, i int) D {
listItem := pg.listItems[i]
if !listItem.wal.IsWatchingOnlyWallet() {
return D{}
Expand Down Expand Up @@ -780,25 +780,6 @@ func (pg *walletPage) layoutAddWalletSection(gtx layout.Context, common *pageCom
})
}

func (pg *walletPage) updateAcctDetailsButtons(walAcct []*dcrlibwallet.Account) {
if len(walAcct) != len(pg.toAcctDetails) {
for i := 0; i < len(walAcct); i++ {
pg.toAcctDetails = append(pg.toAcctDetails, &gesture.Click{})
}
}
}

func (pg *walletPage) goToAcctDetails(gtx layout.Context, common *pageCommon, accts []*dcrlibwallet.Account, index int, click *gesture.Click) {
for _, e := range click.Events(gtx) {
if e.Type == gesture.TypeClick {
// TODO
// *pg.walletAccount = acct
common.changePage(PageAccountDetails)
// *common.selectedWallet = index
}
}
}

func (pg *walletPage) closePopups() {
pg.openPopupIndex = -1
pg.isAddWalletMenuOpen = false
Expand All @@ -809,12 +790,10 @@ func (pg *walletPage) openPopup(index int) {
if pg.openPopupIndex == index {
pg.closePopups()
return
} else {
pg.closePopups()
}
pg.closePopups()
}

// *common.selectedWallet = index TODO
pg.openPopupIndex = index
}

Expand All @@ -825,6 +804,12 @@ func (pg *walletPage) handle() {
pg.closePopups()
}

if ok, selectedItem := pg.watchWalletsList.ItemClicked(); ok {
listItem := pg.listItems[selectedItem]
// TODO: find default account using number
pg.common.changeFragment(AcctDetailsPage(common, listItem.accounts[0]), PageAccountDetails)
}

for index, listItem := range pg.listItems {
*common.selectedWallet = index

Expand Down

0 comments on commit 068423f

Please sign in to comment.