-
Notifications
You must be signed in to change notification settings - Fork 27
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
Fyne History Page Implementation #439
Open
Sirmorrison
wants to merge
74
commits into
raedahgroup:master
Choose a base branch
from
Sirmorrison:fyneHistoryPage
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 69 commits
Commits
Show all changes
74 commits
Select commit
Hold shift + click to select a range
f1dcdfd
added transaction filter popup
Sirmorrison eae10b8
fixed dropdown selection issues
Sirmorrison d347c73
added table.go, and table header
Sirmorrison 6af6f32
added table.go, and fetched table data into the table
Sirmorrison a8a6c51
bug fix with tablefilter
Sirmorrison cf1a818
implemented txtable filtering
Sirmorrison 0f3fa0c
added pagination
Sirmorrison 2c1c538
added transaction details page, improved table.go, removed pagination…
Sirmorrison d19d5f8
removed txdetails.go
Sirmorrison 95100e2
added errorhandling, split function into table header and table conte…
Sirmorrison 4bd5f6d
added copy txhash copy functionality for txdetails page, aligned txde…
Sirmorrison c70253a
added modal popup collapse icon, made txdetail pop a modal popup, add…
Sirmorrison a241b45
hint tip
Sirmorrison 60ad5d1
renamed variables, remoeved commentedline and un used lines ofcode
Sirmorrison c35e1ba
fixed ssues with tx table not scrolling and returning to the table to…
Sirmorrison 3463275
fixed panic issue with error handlers for txdetails page and txdropdo…
Sirmorrison 1e8334c
fixed error handler panic for tx, added txsort dropdown to history page
Sirmorrison c328cb1
fixe issues with txdetails popup
Sirmorrison 6278f21
un-did changes
Sirmorrison 7540cf9
rebased pr
Sirmorrison b5c41bd
added transaction filter popup
Sirmorrison f3057c6
fixed dropdown selection issues
Sirmorrison b9b10ab
added table.go, and table header
Sirmorrison b6de20b
added table.go, and fetched table data into the table
Sirmorrison 1a72ea4
bug fix with tablefilter
Sirmorrison e17a827
implemented txtable filtering
Sirmorrison f8d90cc
added pagination
Sirmorrison 49f45bb
added transaction details page, improved table.go, removed pagination…
Sirmorrison 433720d
removed txdetails.go
Sirmorrison c3f4dad
added errorhandling, split function into table header and table conte…
Sirmorrison 55fece0
added copy txhash copy functionality for txdetails page, aligned txde…
Sirmorrison 9f7f4f2
added modal popup collapse icon, made txdetail pop a modal popup, add…
Sirmorrison 321d755
hint tip
Sirmorrison df594a1
renamed variables, remoeved commentedline and un used lines ofcode
Sirmorrison f203132
fixed ssues with tx table not scrolling and returning to the table to…
Sirmorrison 4b9f4a1
fixed panic issue with error handlers for txdetails page and txdropdo…
Sirmorrison 452c58f
fixed error handler panic for tx, added txsort dropdown to history page
Sirmorrison 7c42b02
fixe issues with txdetails popup
Sirmorrison 0475626
un-did changes
Sirmorrison a6ab7d9
fixing history page
Sirmorrison aa8fde1
implemented multiwallet feature
Sirmorrison 578a185
added selected wallet line
Sirmorrison 39010fc
fixed issues with txDetailsPopup
Sirmorrison 5804ef8
hide filter popup when there re no tx in wallet
Sirmorrison 86fe1b5
fixed issues with txSort dropdown
Sirmorrison e2fe7aa
added info popup and cleaned up code
Sirmorrison 8a838e4
added txdirection icon to tx table
Sirmorrison 77776e1
fixed issues with history table when a diiferent wallet is selected
Sirmorrison ffbc339
fixed issues with txDropdown and txSort Labels not reflecting the cur…
Sirmorrison e78054f
fixed panic when there is an error, changed wallet list to a dropdown…
Sirmorrison e7c6888
cleaned up code
Sirmorrison fc7fa45
removed repeated codes, rebased pr and cleaned up code
Sirmorrison f076174
optimzed txupdate
Sirmorrison f70be2e
added redirect to dcrdata feature
Sirmorrison 00b4208
added section seperators
Sirmorrison 6cc7353
removed file
Sirmorrison 19e6a96
rebased PR
Sirmorrison 6a52d76
fixed broken page after rebase due to fyne update
Sirmorrison 5463d00
undid changes
Sirmorrison ef81d88
added scroll feature to wallet dropdown
Sirmorrison 9f4ce43
implemented @metaclips review
Sirmorrison a8cab7a
removed unrelated file
Sirmorrison 06b6a8b
removed unrelated file
Sirmorrison 3bc6ba6
minor mod
Sirmorrison a7a406b
Merge branch 'fyneHistoryPage' of https://github.com/Sirmorrison/godc…
Sirmorrison c868cab
reduced table width, removed horizontal scroll, removed type column
Sirmorrison 0d86a52
fixed issues with no transaction in wallet message not showing
Sirmorrison 7e63a18
removed direction label and added #column
Sirmorrison c72a35a
fixed issues with txdetails popup being larger than the screensize, u…
Sirmorrison 1303925
trimmed long string and optimized code
Sirmorrison a50dcd4
aligned info icon to the right and reduced popup size, aligned table …
Sirmorrison 8b9d018
used form widget for txdetails data
Sirmorrison 08c678b
cleaned up code and fixed issues with txtable content alignment
Sirmorrison 2fb8d2e
fixed pagination
Sirmorrison File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,24 @@ | ||
package helpers | ||
|
||
import ( | ||
"fyne.io/fyne/widget" | ||
"github.com/raedahgroup/godcr/fyne/assets" | ||
) | ||
|
||
func TxDirectionIcon(direction int32) string { | ||
switch direction { | ||
case 0: | ||
return assets.SendIcon | ||
case 1: | ||
return assets.ReceiveIcon | ||
case 2: | ||
return assets.ReceiveIcon | ||
default: | ||
return assets.InfoIcon | ||
} | ||
} | ||
|
||
func ErrorHandler(err string, errorLabel *widget.Label) { | ||
errorLabel.SetText(err) | ||
errorLabel.Show() | ||
} |
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,45 @@ | ||
package historypagehandler | ||
|
||
import ( | ||
"fyne.io/fyne" | ||
"fyne.io/fyne/canvas" | ||
"fyne.io/fyne/layout" | ||
"fyne.io/fyne/widget" | ||
|
||
"github.com/raedahgroup/godcr/fyne/assets" | ||
"github.com/raedahgroup/godcr/fyne/pages/handler/values" | ||
"github.com/raedahgroup/godcr/fyne/widgets" | ||
) | ||
|
||
func (historyPage *HistoryPageData) initBaseObjects() error { | ||
icons, err := assets.GetIcons(assets.CollapseIcon, assets.InfoIcon, assets.SendIcon, assets.ReceiveIcon, assets.ReceiveIcon, assets.InfoIcon, assets.RedirectIcon) | ||
if err != nil { | ||
return err | ||
} | ||
historyPage.icons = icons | ||
// history page title label | ||
historyTitleLabel := widget.NewLabelWithStyle(values.HistoryTitle, fyne.TextAlignLeading, fyne.TextStyle{Bold: true, Italic: true}) | ||
|
||
// infoPopUp creates a popup with history page hint-text | ||
var infoIcon *widgets.ImageButton | ||
infoIcon = widgets.NewImageButton(historyPage.icons[assets.InfoIcon], nil, func() { | ||
infoLabel := widget.NewLabelWithStyle(values.PageHint, fyne.TextAlignLeading, fyne.TextStyle{Monospace: true}) | ||
gotItLabel := canvas.NewText(values.GotIt, values.Blue) | ||
gotItLabel.TextStyle = fyne.TextStyle{Bold: true} | ||
gotItLabel.TextSize = 14 | ||
|
||
var infoPopUp *widget.PopUp | ||
infoPopUp = widget.NewPopUp(widget.NewVBox( | ||
widgets.NewVSpacer(5), | ||
widget.NewHBox(widgets.NewHSpacer(5), infoLabel, widgets.NewHSpacer(5)), | ||
widgets.NewVSpacer(5), | ||
widget.NewHBox(layout.NewSpacer(), widgets.NewClickableBox(widget.NewVBox(gotItLabel), func() { infoPopUp.Hide() }), widgets.NewHSpacer(5)), | ||
widgets.NewVSpacer(5), | ||
), historyPage.Window.Canvas()) | ||
|
||
infoPopUp.Move(fyne.CurrentApp().Driver().AbsolutePositionForObject(infoIcon).Add(fyne.NewPos(0, infoIcon.Size().Height))) | ||
}) | ||
|
||
historyPage.HistoryPageContents.Append(widget.NewHBox(historyTitleLabel, widgets.NewHSpacer(110), infoIcon)) | ||
return nil | ||
} |
133 changes: 133 additions & 0 deletions
133
fyne/pages/handler/historypagehandler/filterselector.go
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,133 @@ | ||
package historypagehandler | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"fyne.io/fyne/widget" | ||
|
||
"github.com/raedahgroup/dcrlibwallet" | ||
"github.com/raedahgroup/godcr/fyne/assets" | ||
"github.com/raedahgroup/godcr/fyne/widgets" | ||
) | ||
|
||
func (historyPage *HistoryPageData) txFilterDropDown(walletId int) { | ||
var txTable widgets.Table | ||
txFilterListWidget := widget.NewVBox() | ||
|
||
var allTxFilterNames = []string{"All", "Sent", "Received", "Transferred", "Coinbase", "Staking"} | ||
var allTxFilters = map[string]int32{ | ||
"All": dcrlibwallet.TxFilterAll, | ||
"Sent": dcrlibwallet.TxFilterSent, | ||
"Received": dcrlibwallet.TxFilterReceived, | ||
"Transferred": dcrlibwallet.TxFilterTransferred, | ||
"Coinbase": dcrlibwallet.TxFilterCoinBase, | ||
"Staking": dcrlibwallet.TxFilterStaking, | ||
} | ||
|
||
if walletId != historyPage.selectedWalletID { | ||
historyPage.selectedWalletID = walletId | ||
} | ||
|
||
txCountForFilter, err := historyPage.MultiWallet.WalletWithID(historyPage.selectedWalletID).CountTransactions(allTxFilters["All"]) | ||
if err != nil { | ||
historyPage.errorMessage = fmt.Sprintf("Cannot load history page page. Error getting transaction count for filter All: %s", err.Error()) | ||
return | ||
} | ||
|
||
historyPage.allTxCount = txCountForFilter | ||
|
||
historyPage.selectedTxFilterLabel.SetText(fmt.Sprintf("%s (%d)", "All", txCountForFilter)) | ||
|
||
for _, filterName := range allTxFilterNames { | ||
filterId := allTxFilters[filterName] | ||
txCountForFilter, err := historyPage.MultiWallet.WalletWithID(historyPage.selectedWalletID).CountTransactions(filterId) | ||
if err != nil { | ||
historyPage.errorMessage = fmt.Sprintf("Cannot load historyPage page. Error getting transaction count for filter %s: %s", filterName, err.Error()) | ||
return | ||
} | ||
if txCountForFilter > 0 { | ||
filter := fmt.Sprintf("%s (%d)", filterName, txCountForFilter) | ||
txFilterView := widget.NewHBox( | ||
widgets.NewHSpacer(5), | ||
widget.NewLabel(filter), | ||
widgets.NewHSpacer(5), | ||
) | ||
|
||
txFilterListWidget.Append(widgets.NewClickableBox(txFilterView, func() { | ||
selectedFilterName := strings.Split(filter, " ")[0] | ||
selectedFilterId := allTxFilters[selectedFilterName] | ||
if allTxCountForSelectedTx, err := historyPage.MultiWallet.WalletWithID(historyPage.selectedWalletID).CountTransactions(selectedFilterId); err == nil { | ||
historyPage.allTxCount = allTxCountForSelectedTx | ||
} | ||
|
||
if selectedFilterId != historyPage.selectedFilterId { | ||
historyPage.selectedTxFilterLabel.SetText(filter) | ||
historyPage.txTableHeader(&txTable) | ||
historyPage.fetchTx(&txTable, 0, selectedFilterId, false) | ||
widget.Refresh(historyPage.txTable.Result) | ||
} | ||
|
||
historyPage.txFilterSelectionPopup.Hide() | ||
})) | ||
} | ||
} | ||
|
||
// txFilterSelectionPopup create a popup that has tx filter name and tx count | ||
historyPage.txFilterSelectionPopup = widget.NewPopUp(widget.NewVBox(txFilterListWidget), historyPage.Window.Canvas()) | ||
historyPage.txFilterSelectionPopup.Hide() | ||
|
||
historyPage.txFilterTab = widget.NewHBox( | ||
historyPage.selectedTxFilterLabel, | ||
widgets.NewHSpacer(10), | ||
widget.NewIcon(historyPage.icons[assets.CollapseIcon]), | ||
widgets.NewHSpacer(10), | ||
) | ||
widget.Refresh(historyPage.txFilterTab) | ||
} | ||
|
||
func (historyPage *HistoryPageData) txSortDropDown() { | ||
var txTable widgets.Table | ||
var allTxSortNames = []string{"Newest", "Oldest"} | ||
var allTxSortFilters = map[string]bool{ | ||
"Newest": true, | ||
"Oldest": false, | ||
} | ||
|
||
historyPage.selectedTxSortFilterLabel.SetText("Newest") | ||
|
||
historyPage.selectedtxSort = allTxSortFilters["Newest"] | ||
|
||
txSortFilterListWidget := widget.NewVBox() | ||
for _, sortName := range allTxSortNames { | ||
txSortView := widget.NewHBox( | ||
widgets.NewHSpacer(5), | ||
widget.NewLabel(sortName), | ||
widgets.NewHSpacer(5), | ||
) | ||
txSort := allTxSortFilters[sortName] | ||
newSortName := sortName | ||
|
||
txSortFilterListWidget.Append(widgets.NewClickableBox(txSortView, func() { | ||
historyPage.selectedTxSortFilterLabel.SetText(newSortName) | ||
historyPage.selectedtxSort = txSort | ||
|
||
historyPage.txTableHeader(&txTable) | ||
historyPage.txTable.Result.Children = txTable.Result.Children | ||
historyPage.fetchTx(&txTable, 0, historyPage.selectedFilterId, false) | ||
widget.Refresh(historyPage.txTable.Result) | ||
historyPage.txSortFilterSelectionPopup.Hide() | ||
})) | ||
} | ||
|
||
// txSortFilterSelectionPopup create a popup that has tx filter name and tx count | ||
historyPage.txSortFilterSelectionPopup = widget.NewPopUp(widget.NewVBox(txSortFilterListWidget), historyPage.Window.Canvas()) | ||
historyPage.txSortFilterSelectionPopup.Hide() | ||
|
||
historyPage.txSortFilterTab = widget.NewHBox( | ||
historyPage.selectedTxSortFilterLabel, | ||
widgets.NewHSpacer(10), | ||
widget.NewIcon(historyPage.icons[assets.CollapseIcon]), | ||
) | ||
widget.Refresh(historyPage.txSortFilterTab) | ||
} |
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,91 @@ | ||
package historypagehandler | ||
|
||
import ( | ||
"errors" | ||
|
||
"fyne.io/fyne" | ||
"fyne.io/fyne/layout" | ||
"fyne.io/fyne/widget" | ||
|
||
"github.com/raedahgroup/dcrlibwallet" | ||
"github.com/raedahgroup/godcr/fyne/pages/handler/values" | ||
"github.com/raedahgroup/godcr/fyne/widgets" | ||
) | ||
|
||
type HistoryPageData struct { | ||
allTxCount int | ||
selectedWalletID int | ||
selectedFilterId int32 | ||
TotalTxFetched int32 | ||
selectedtxSort bool | ||
errorMessage string | ||
txFilterTab *widget.Box | ||
txSortFilterTab *widget.Box | ||
txTable widgets.Table | ||
errorLabel *widget.Label | ||
selectedTxFilterLabel *widget.Label | ||
selectedTxSortFilterLabel *widget.Label | ||
txFilterSelectionPopup *widget.PopUp | ||
txSortFilterSelectionPopup *widget.PopUp | ||
MultiWallet *dcrlibwallet.MultiWallet | ||
icons map[string]*fyne.StaticResource | ||
HistoryPageContents *widget.Box | ||
Window fyne.Window | ||
TabMenu *widget.TabContainer | ||
} | ||
|
||
func (historyPage *HistoryPageData) InitHistoryPage() error { | ||
historyPage.HistoryPageContents.Append(widgets.NewVSpacer(values.Padding)) | ||
|
||
err := historyPage.initBaseObjects() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
historyPage.HistoryPageContents.Append(widgets.NewVSpacer(values.SpacerSize10)) | ||
|
||
historyPage.errorLabel = widget.NewLabelWithStyle("", fyne.TextAlignCenter, fyne.TextStyle{Bold: true}) | ||
historyPage.errorLabel.Hide() | ||
|
||
historyPage.selectedFilterId = dcrlibwallet.TxFilterAll | ||
historyPage.selectedTxFilterLabel = widget.NewLabel("") | ||
historyPage.selectedTxSortFilterLabel = widget.NewLabel("") | ||
|
||
historyPage.txWalletList() | ||
|
||
// txFilterDropDown creates a popup like dropdown that holds the list of tx filters. | ||
var txFilterDropDown *widgets.ClickableBox | ||
txFilterDropDown = widgets.NewClickableBox(historyPage.txFilterTab, func() { | ||
if historyPage.allTxCount == 0 { | ||
historyPage.txFilterSelectionPopup.Hide() | ||
} else { | ||
historyPage.txFilterSelectionPopup.Move(fyne.CurrentApp().Driver().AbsolutePositionForObject( | ||
txFilterDropDown).Add(fyne.NewPos(0, txFilterDropDown.Size().Height))) | ||
historyPage.txFilterSelectionPopup.Show() | ||
} | ||
}) | ||
|
||
// txSortFilterDropDown creates a popup like dropdown that holds the list of sort filters. | ||
var txSortFilterDropDown *widgets.ClickableBox | ||
txSortFilterDropDown = widgets.NewClickableBox(historyPage.txSortFilterTab, func() { | ||
if historyPage.allTxCount == 0 { | ||
historyPage.txSortFilterSelectionPopup.Hide() | ||
} else { | ||
historyPage.txSortFilterSelectionPopup.Move(fyne.CurrentApp().Driver().AbsolutePositionForObject( | ||
txSortFilterDropDown).Add(fyne.NewPos(0, txSortFilterDropDown.Size().Height))) | ||
historyPage.txSortFilterSelectionPopup.Show() | ||
} | ||
}) | ||
|
||
// catch all errors when trying to setup and render tx page data. | ||
if historyPage.errorMessage != "" { | ||
return errors.New(historyPage.errorMessage) | ||
} | ||
|
||
historyPage.HistoryPageContents.Append(widget.NewHBox(txSortFilterDropDown, widgets.NewHSpacer(30), txFilterDropDown)) | ||
historyPage.HistoryPageContents.Append(widgets.NewVSpacer(5)) | ||
historyPage.HistoryPageContents.Append(historyPage.errorLabel) | ||
historyPage.HistoryPageContents.Append(fyne.NewContainerWithLayout(layout.NewFixedGridLayout(fyne.NewSize(historyPage.txTable.Result.MinSize().Width+30, historyPage.txTable.Container.MinSize().Height+450)), historyPage.txTable.Container)) | ||
historyPage.HistoryPageContents.Append(widgets.NewVSpacer(15)) | ||
return nil | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we passing error messages here? isn't there already a widget that handles that? Also, if err!=nil parameter is met, the app crashes, all component functions that require using dcrlibwallet should have a return parameter "error", you should stop all history page initialisation if any function throws an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not true if there is an error at any point the error is returned the app does not panic... you should do well to test this properly as i have done so from my end...
if you are changing
!=
to==
you should comment outerr.Error()
else it will panic as there is no error to be returned.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what is shown when I make
err == nil
here, you are showing parts of history page components even when there was an error.You shouldn't be passing errors to variables and then making a return
You are still calling up functions even if there was error on other functions called recently and then checking if any of the functions returned an error here
This shouldn't be as any of the functions that errors and returns early without initialising struct variable "HistoryPageData struct" could cause a panic in other functions if they use the uninitialised variable, you should instead pass return parameter "errors" to all functions that uses dcrlibwallet also InitHistoryPage function and then if any of the dcrlibwallet library functions return an error,
err
if there was an error, only show on history page a label indicating that there was an error initialising history page.