refactor(@desktop/wallet): connect ui and account token

This commit is contained in:
Anthony Laibe 2021-10-20 16:05:59 +02:00 committed by Iuri Matias
parent 6a1923abcf
commit a7a56cf471
5 changed files with 24 additions and 9 deletions

View File

@ -77,5 +77,8 @@ QtObject:
of ModelRole.FiatBalance:
result = newQVariant(item.getFiatBalance())
proc setData*(self: Model, item: seq[Item]) =
proc setItems*(self: Model, items: seq[Item]) =
self.beginResetModel()
self.items = items
self.endResetModel()
self.countChanged()

View File

@ -1,6 +1,6 @@
import NimQml
import NimQml, sequtils, sugar
import eventemitter
import ./io_interface, ./view, ./controller
import ./io_interface, ./view, ./controller, ./item
import ../../../../core/global_singleton
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
@ -28,10 +28,21 @@ method delete*[T](self: Module[T]) =
self.view.delete
method load*[T](self: Module[T]) =
singletonInstance.engine.setRootContextProperty("walletSectionAccountTokens", newQVariant(self.view))
self.moduleLoaded = true
method isLoaded*[T](self: Module[T]): bool =
return self.moduleLoaded
method switchAccount*[T](self: Module[T], accountIndex: int) =
discard
let walletAccount = self.controller.getWalletAccount(accountIndex)
self.view.setItems(
walletAccount.tokens.map(t => initItem(
t.name,
t.symbol,
t.balance,
t.address,
t.currencyBalance,
$t.currencyBalance,
))
)

View File

@ -1,6 +1,6 @@
import NimQml
import ./model
import ./model, ./item
import ./io_interface
QtObject:
@ -29,4 +29,7 @@ QtObject:
QtProperty[QVariant] model:
read = getModel
notify = modelChanged
notify = modelChanged
proc setItems*(self: View, items: seq[Item]) =
self.model.setItems(items)

View File

@ -38,8 +38,6 @@ proc toTokenDto*(jsonObj: JsonNode, activeTokenSymbols: seq[string]): TokenDto =
if activeTokenSymbols.contains(result.symbol):
result.isVisible = true
proc addressAsString*(self: TokenDto): string =
return $self.address

View File

@ -17,7 +17,7 @@ QtObject {
property var customTokenList: walletSectionAllTokens.custom
property var tokens: walletSectionAllTokens.all
property var assets: walletModel.tokensView.assets
property var assets: walletSectionAccountTokens.model
property string signingPhrase: walletModel.utilsView.signingPhrase