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:
|
of ModelRole.FiatBalance:
|
||||||
result = newQVariant(item.getFiatBalance())
|
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()
|
self.countChanged()
|
|
@ -1,6 +1,6 @@
|
||||||
import NimQml
|
import NimQml, sequtils, sugar
|
||||||
import eventemitter
|
import eventemitter
|
||||||
import ./io_interface, ./view, ./controller
|
import ./io_interface, ./view, ./controller, ./item
|
||||||
import ../../../../core/global_singleton
|
import ../../../../core/global_singleton
|
||||||
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
|
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
|
||||||
|
|
||||||
|
@ -28,10 +28,21 @@ method delete*[T](self: Module[T]) =
|
||||||
self.view.delete
|
self.view.delete
|
||||||
|
|
||||||
method load*[T](self: Module[T]) =
|
method load*[T](self: Module[T]) =
|
||||||
|
singletonInstance.engine.setRootContextProperty("walletSectionAccountTokens", newQVariant(self.view))
|
||||||
self.moduleLoaded = true
|
self.moduleLoaded = true
|
||||||
|
|
||||||
method isLoaded*[T](self: Module[T]): bool =
|
method isLoaded*[T](self: Module[T]): bool =
|
||||||
return self.moduleLoaded
|
return self.moduleLoaded
|
||||||
|
|
||||||
method switchAccount*[T](self: Module[T], accountIndex: int) =
|
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 NimQml
|
||||||
|
|
||||||
import ./model
|
import ./model, ./item
|
||||||
import ./io_interface
|
import ./io_interface
|
||||||
|
|
||||||
QtObject:
|
QtObject:
|
||||||
|
@ -29,4 +29,7 @@ QtObject:
|
||||||
|
|
||||||
QtProperty[QVariant] model:
|
QtProperty[QVariant] model:
|
||||||
read = getModel
|
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):
|
if activeTokenSymbols.contains(result.symbol):
|
||||||
result.isVisible = true
|
result.isVisible = true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
proc addressAsString*(self: TokenDto): string =
|
proc addressAsString*(self: TokenDto): string =
|
||||||
return $self.address
|
return $self.address
|
|
@ -17,7 +17,7 @@ QtObject {
|
||||||
property var customTokenList: walletSectionAllTokens.custom
|
property var customTokenList: walletSectionAllTokens.custom
|
||||||
property var tokens: walletSectionAllTokens.all
|
property var tokens: walletSectionAllTokens.all
|
||||||
|
|
||||||
property var assets: walletModel.tokensView.assets
|
property var assets: walletSectionAccountTokens.model
|
||||||
|
|
||||||
property string signingPhrase: walletModel.utilsView.signingPhrase
|
property string signingPhrase: walletModel.utilsView.signingPhrase
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue