Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup wallets page & its sub pages (#493)
* Use dcrlibwallet directly in wallets page * Add walletListItem struct for managing wallets and accounts list * Add ClickableList and implement accounts list using ClickableList. * Use one backdrop for all popups * Cleanup account details page * account details: hide staking balances if empty * Hide imported account if empty * Cleanup wallet settings, sign message and stake shuffle pages * Handle watch only wallets click events
- Loading branch information
Showing
8 changed files
with
478 additions
and
493 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package decredmaterial | ||
|
||
import ( | ||
"gioui.org/layout" | ||
"gioui.org/widget" | ||
) | ||
|
||
type ClickableList struct { | ||
layout.List | ||
clickables []*widget.Clickable | ||
selectedItem int | ||
} | ||
|
||
func (t *Theme) NewClickableList(axis layout.Axis) *ClickableList { | ||
return &ClickableList{ | ||
List: layout.List{Axis: layout.Vertical}, | ||
selectedItem: -1, | ||
} | ||
} | ||
|
||
func (cl *ClickableList) ItemClicked() (bool, int) { | ||
defer func() { | ||
cl.selectedItem = -1 | ||
}() | ||
return cl.selectedItem != -1, cl.selectedItem | ||
} | ||
|
||
func (cl *ClickableList) handleClickables(count int) { | ||
if len(cl.clickables) != count { | ||
|
||
cl.clickables = make([]*widget.Clickable, count) | ||
for i := 0; i < count; i++ { | ||
cl.clickables[i] = new(widget.Clickable) | ||
} | ||
} | ||
|
||
for index, clickable := range cl.clickables { | ||
for clickable.Clicked() { | ||
cl.selectedItem = index | ||
} | ||
} | ||
} | ||
|
||
func (cl *ClickableList) Layout(gtx layout.Context, count int, w layout.ListElement) layout.Dimensions { | ||
cl.handleClickables(count) | ||
return cl.List.Layout(gtx, count, func(gtx layout.Context, i int) layout.Dimensions { | ||
return Clickable(gtx, cl.clickables[i], func(gtx layout.Context) layout.Dimensions { | ||
return w(gtx, i) | ||
}) | ||
|
||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.