feat(@settings): Display account information
This commit is contained in:
parent
1d6d20200a
commit
49ca009a7c
|
@ -46,4 +46,7 @@ method updateCurrency*[T](self: Controller[T], currency: string) =
|
|||
self.walletAccountService.updateCurrency(currency)
|
||||
|
||||
method isEIP1559Enabled*[T](self: Controller[T]): bool =
|
||||
return self.networkService.isEIP1559Enabled()
|
||||
return self.networkService.isEIP1559Enabled()
|
||||
|
||||
method getIndex*[T](self: Controller[T], address: string): int =
|
||||
return self.walletAccountService.getIndex(address)
|
|
@ -26,6 +26,9 @@ method updateCurrency*(self: AccessInterface, currency: string) {.base.} =
|
|||
method isEIP1559Enabled*(self: AccessInterface): bool {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getIndex*(self: AccessInterface, address: string): int {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
type
|
||||
## Abstract class (concept) which must be implemented by object/s used in this
|
||||
## module.
|
||||
|
|
|
@ -14,6 +14,9 @@ method isLoaded*(self: AccessInterface): bool {.base.} =
|
|||
method switchAccount*(self: AccessInterface, accountIndex: int) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method switchAccountByAddress*(self: AccessInterface, address: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method updateCurrency*(self: AccessInterface, currency: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
|
|
@ -90,6 +90,10 @@ method switchAccount*[T](self: Module[T], accountIndex: int) =
|
|||
self.accountTokensModule.switchAccount(accountIndex)
|
||||
self.transactionsModule.switchAccount(accountIndex)
|
||||
|
||||
method switchAccountByAddress*[T](self: Module[T], address: string) =
|
||||
let accountIndex = self.controller.getIndex(address)
|
||||
self.switchAccount(accountIndex)
|
||||
|
||||
method setTotalCurrencyBalance*[T](self: Module[T]) =
|
||||
self.view.setTotalCurrencyBalance(self.controller.getCurrencyBalance())
|
||||
|
||||
|
|
|
@ -63,6 +63,9 @@ QtObject:
|
|||
proc switchAccount(self: View, accountIndex: int) {.slot.} =
|
||||
self.delegate.switchAccount(accountIndex)
|
||||
|
||||
proc switchAccountByAddress(self: View, address: string) {.slot.} =
|
||||
self.delegate.switchAccountByAddress(address)
|
||||
|
||||
proc setTotalCurrencyBalance*(self: View, totalCurrencyBalance: float64) =
|
||||
self.totalCurrencyBalance = totalCurrencyBalance
|
||||
self.totalCurrencyBalanceChanged()
|
||||
|
|
|
@ -220,6 +220,12 @@ method getWalletAccount*(self: Service, accountIndex: int): WalletAccountDto =
|
|||
return
|
||||
return self.getWalletAccounts()[accountIndex]
|
||||
|
||||
method getIndex*(self: Service, address: string): int =
|
||||
let accounts = self.getWalletAccounts()
|
||||
for i in 0..accounts.len:
|
||||
if(accounts[i].address == address):
|
||||
return i
|
||||
|
||||
method getCurrencyBalance*(self: Service): float64 =
|
||||
return self.getWalletAccounts().map(a => a.getCurrencyBalance()).foldl(a + b, 0.0)
|
||||
|
||||
|
|
|
@ -50,3 +50,6 @@ method toggleTokenVisible*(self: ServiceInterface, chainId: int, symbol: string)
|
|||
|
||||
method getPrice*(self: ServiceInterface, crypto: string, fiat: string): float64 {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getIndex*(self: ServiceInterface, address: string): int {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
|
@ -4,10 +4,14 @@ import StatusQ.Core 0.1
|
|||
|
||||
|
||||
StatusListItem {
|
||||
signal goToAccountView()
|
||||
|
||||
property var account
|
||||
|
||||
title: account.name
|
||||
subTitle: account.address
|
||||
icon.isLetterIdenticon: true
|
||||
icon.color: account.color
|
||||
width: parent.width
|
||||
leftPadding: 0
|
||||
rightPadding: 0
|
||||
|
@ -18,4 +22,8 @@ StatusListItem {
|
|||
color: Theme.palette.baseColor1
|
||||
}
|
||||
]
|
||||
|
||||
onClicked: {
|
||||
goToAccountView()
|
||||
}
|
||||
}
|
|
@ -26,4 +26,14 @@ QtObject {
|
|||
function removeCustomToken(chainId, address) {
|
||||
walletSectionAllTokens.removeCustomToken(chainId, address)
|
||||
}
|
||||
|
||||
property var currentAccount: walletSectionCurrent
|
||||
|
||||
function switchAccountByAddress(address) {
|
||||
walletSection.switchAccountByAddress(address)
|
||||
}
|
||||
|
||||
function deleteAccount(address) {
|
||||
return walletSectionAccounts.deleteAccount(address)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,12 +36,6 @@ ScrollView {
|
|||
anchors.fill: parent
|
||||
currentIndex: 0
|
||||
|
||||
onCurrentIndexChanged: {
|
||||
if(visibleChildren[0] === ensContainer){
|
||||
ensContainer.goToStart();
|
||||
}
|
||||
}
|
||||
|
||||
MainView {
|
||||
walletStore: root.walletStore
|
||||
anchors.topMargin: 64
|
||||
|
@ -53,6 +47,11 @@ ScrollView {
|
|||
onGoToNetworksView: {
|
||||
stackContainer.currentIndex = 1
|
||||
}
|
||||
|
||||
onGoToAccountView: {
|
||||
root.walletStore.switchAccountByAddress(address)
|
||||
stackContainer.currentIndex = 2
|
||||
}
|
||||
}
|
||||
|
||||
NetworksView {
|
||||
|
@ -62,6 +61,15 @@ ScrollView {
|
|||
stackContainer.currentIndex = 0
|
||||
}
|
||||
}
|
||||
|
||||
AccountView {
|
||||
id: accountView
|
||||
walletStore: root.walletStore
|
||||
anchors.fill: parent
|
||||
onGoBack: {
|
||||
stackContainer.currentIndex = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,227 @@
|
|||
import QtQuick 2.13
|
||||
|
||||
import shared.status 1.0
|
||||
import shared.popups 1.0
|
||||
import StatusQ.Controls 0.1
|
||||
import StatusQ.Core 0.1
|
||||
import StatusQ.Components 0.1
|
||||
import StatusQ.Core.Theme 0.1
|
||||
import utils 1.0
|
||||
|
||||
import "../../stores"
|
||||
import "../../controls"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
signal goBack
|
||||
|
||||
property WalletStore walletStore
|
||||
|
||||
StatusFlatButton {
|
||||
id: backButton
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: Style.current.bigPadding
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: Style.current.bigPadding
|
||||
icon.name: "arrow-left"
|
||||
icon.height: 13.5
|
||||
icon.width: 17.5
|
||||
text: qsTr("Wallet")
|
||||
onClicked: {
|
||||
root.goBack()
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
id: column
|
||||
anchors.topMargin: Style.current.xlPadding
|
||||
anchors.top: backButton.bottom
|
||||
anchors.leftMargin: Style.current.xlPadding * 2
|
||||
anchors.left: root.left
|
||||
width: 560
|
||||
|
||||
Item {
|
||||
id: header
|
||||
height: 60
|
||||
width: parent.width
|
||||
StatusSmartIdenticon {
|
||||
id: accountImage
|
||||
anchors.left: parent.left
|
||||
anchors.topMargin: Style.current.halfPadding
|
||||
anchors.top: parent.top
|
||||
image.isIdenticon: true
|
||||
icon: StatusIconSettings {
|
||||
width: 40
|
||||
height: 40
|
||||
letterSize: 21
|
||||
color: walletStore.currentAccount.color
|
||||
}
|
||||
name: walletStore.currentAccount.name
|
||||
}
|
||||
|
||||
|
||||
Item {
|
||||
id: accountNameAndAddress
|
||||
anchors.left: accountImage.right
|
||||
anchors.leftMargin: Style.current.padding
|
||||
anchors.top: parent.top
|
||||
|
||||
StatusBaseText {
|
||||
id: accountName
|
||||
text: walletStore.currentAccount.name
|
||||
font.weight: Font.Bold
|
||||
font.pixelSize: 28
|
||||
color: Theme.palette.directColor1
|
||||
anchors.left: parent.left
|
||||
}
|
||||
|
||||
StatusAddress {
|
||||
text: walletStore.currentAccount.address
|
||||
anchors.top: accountName.bottom
|
||||
anchors.topMargin: Style.current.halfPadding
|
||||
anchors.left: parent.left
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
height: Style.current.bigPadding
|
||||
width: parent.width
|
||||
}
|
||||
|
||||
Item {
|
||||
height: 50
|
||||
width: parent.width
|
||||
|
||||
Rectangle {
|
||||
id: typeRectangle
|
||||
border.width: 1
|
||||
border.color: Theme.palette.directColor7
|
||||
radius: Style.current.radius
|
||||
width: typeText.width + Style.current.xlPadding
|
||||
height: parent.height
|
||||
StatusBaseText {
|
||||
id: labelType
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: Style.current.smallPadding
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: Style.current.smallPadding
|
||||
text: qsTr("Type")
|
||||
font.pixelSize: 13
|
||||
color: Theme.palette.directColor5
|
||||
}
|
||||
StatusBaseText {
|
||||
id: typeText
|
||||
anchors.top: labelType.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: Style.current.smallPadding
|
||||
text: {
|
||||
const walletType = walletStore.currentAccount.walletType
|
||||
if (walletType === "watch") {
|
||||
return qsTr("Watch-Only Account")
|
||||
} else if (walletType === "generated" || walletType === "") {
|
||||
return qsTr("Generated by your Status seed phrase profile")
|
||||
} else if (walletType === "imported") {
|
||||
return qsTr("Imported Account")
|
||||
}
|
||||
}
|
||||
font.pixelSize: 15
|
||||
color: Theme.palette.directColor1
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: storageRectangle
|
||||
anchors.left: typeRectangle.right
|
||||
anchors.leftMargin: Style.current.padding
|
||||
border.width: 1
|
||||
border.color: Theme.palette.directColor7
|
||||
radius: Style.current.radius
|
||||
width: storageText.width + Style.current.xlPadding
|
||||
height: parent.height
|
||||
StatusBaseText {
|
||||
id: labelStorage
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: Style.current.smallPadding
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: Style.current.smallPadding
|
||||
text: qsTr("Storage")
|
||||
font.pixelSize: 13
|
||||
color: Theme.palette.directColor5
|
||||
}
|
||||
StatusBaseText {
|
||||
id: storageText
|
||||
anchors.top: labelStorage.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: Style.current.smallPadding
|
||||
text: qsTr("On Device")
|
||||
font.pixelSize: 15
|
||||
color: Theme.palette.directColor1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
height: Style.current.bigPadding
|
||||
width: parent.width
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
visible: walletStore.currentAccount.path !== ""
|
||||
border.width: 1
|
||||
border.color: Theme.palette.directColor7
|
||||
radius: Style.current.radius
|
||||
width: Math.max(path.width, labelPath.width) + Style.current.xlPadding
|
||||
height: 50
|
||||
StatusBaseText {
|
||||
id: labelPath
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: Style.current.smallPadding
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: Style.current.smallPadding
|
||||
text: qsTr("Derivation Path")
|
||||
font.weight: Font.Medium
|
||||
font.pixelSize: 13
|
||||
color: Theme.palette.directColor5
|
||||
}
|
||||
StatusBaseText {
|
||||
id: path
|
||||
anchors.top: labelPath.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: Style.current.smallPadding
|
||||
text: walletStore.currentAccount.path
|
||||
font.pixelSize: 15
|
||||
color: Theme.palette.directColor1
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
height: Style.current.bigPadding
|
||||
width: parent.width
|
||||
}
|
||||
|
||||
StatusButton {
|
||||
visible: walletStore.currentAccount.walletType !== ""
|
||||
text: qsTr("Remove from your profile")
|
||||
type: StatusBaseButton.Type.Danger
|
||||
|
||||
ConfirmationDialog {
|
||||
id: confirmationPopup
|
||||
header.title: qsTr("Confirm %1 Removal").arg(walletStore.currentAccount.name)
|
||||
confirmationText: qsTr("You will not be able to restore viewing access to this account in the future unless you enter this account’s address again.")
|
||||
confirmButtonLabel: qsTr("Remove Account")
|
||||
onConfirmButtonClicked: {
|
||||
confirmationPopup.close();
|
||||
root.goBack();
|
||||
root.walletStore.deleteAccount(walletStore.currentAccount.address);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onClicked : {
|
||||
confirmationPopup.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@ Column {
|
|||
property WalletStore walletStore
|
||||
|
||||
signal goToNetworksView()
|
||||
|
||||
signal goToAccountView(address: string)
|
||||
|
||||
StatusBaseText {
|
||||
id: titleText
|
||||
|
@ -106,6 +106,9 @@ Column {
|
|||
model: walletStore.generatedAccounts
|
||||
delegate: WalletAccountDelegate {
|
||||
account: model
|
||||
onGoToAccountView: {
|
||||
root.goToAccountView(model.address)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,6 +122,9 @@ Column {
|
|||
model: walletStore.importedAccounts
|
||||
delegate: WalletAccountDelegate {
|
||||
account: model
|
||||
onGoToAccountView: {
|
||||
root.goToAccountView(model.address)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,6 +138,9 @@ Column {
|
|||
model: walletStore.watchOnlyAccounts
|
||||
delegate: WalletAccountDelegate {
|
||||
account: model
|
||||
onGoToAccountView: {
|
||||
root.goToAccountView(model.address)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue