refactor(@desktop/wallet): connect ui and account token
This commit is contained in:
parent
6a1923abcf
commit
a7a56cf471
|
@ -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()
|
|
@ -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,
|
||||
))
|
||||
)
|
|
@ -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)
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue