feat(@settings): plug in accounts

This commit is contained in:
Anthony Laibe 2022-03-01 15:40:53 +01:00 committed by Anthony Laibe
parent 3549273307
commit 02bc62a9a2
5 changed files with 115 additions and 2 deletions

View File

@ -4,17 +4,32 @@ import ./model
import ./item
import ./io_interface
const WATCH = "watch"
const GENERATED = "generated"
QtObject:
type
View* = ref object of QObject
delegate: io_interface.AccessInterface
model: Model
generated: Model
watchOnly: Model
imported: Model
modelVariant: QVariant
generatedVariant: QVariant
importedVariant: QVariant
watchOnlyVariant: QVariant
tmpAddress: string
proc delete*(self: View) =
self.model.delete
self.modelVariant.delete
self.imported.delete
self.importedVariant.delete
self.generated.delete
self.generatedVariant.delete
self.watchOnly.delete
self.watchOnlyVariant.delete
self.QObject.delete
proc newView*(delegate: io_interface.AccessInterface): View =
@ -23,6 +38,12 @@ QtObject:
result.delegate = delegate
result.model = newModel()
result.modelVariant = newQVariant(result.model)
result.imported = newModel()
result.importedVariant = newQVariant(result.imported)
result.generated = newModel()
result.generatedVariant = newQVariant(result.generated)
result.watchOnly = newModel()
result.watchOnlyVariant = newQVariant(result.watchOnly)
proc load*(self: View) =
self.delegate.viewDidLoad()
@ -36,8 +57,51 @@ QtObject:
read = getModel
notify = modelChanged
proc watchOnlyChanged*(self: View) {.signal.}
proc getWatchOnly(self: View): QVariant {.slot.} =
return self.watchOnlyVariant
QtProperty[QVariant] watchOnly:
read = getWatchOnly
notify = watchOnlyChanged
proc importedChanged*(self: View) {.signal.}
proc getImported(self: View): QVariant {.slot.} =
return self.importedVariant
QtProperty[QVariant] imported:
read = getImported
notify = importedChanged
proc generatedChanged*(self: View) {.signal.}
proc getGenereated(self: View): QVariant {.slot.} =
return self.generatedVariant
QtProperty[QVariant] generated:
read = getGenereated
notify = generatedChanged
proc setItems*(self: View, items: seq[Item]) =
self.model.setItems(items)
var watchOnly: seq[Item] = @[]
var imported: seq[Item] = @[]
var generated: seq[Item] = @[]
for item in items:
if item.getWalletType() == "" or item.getWalletType() == GENERATED:
generated.add(item)
elif item.getWalletType() == WATCH:
watchOnly.add(item)
else:
imported.add(item)
self.watchOnly.setItems(watchOnly)
self.imported.setItems(imported)
self.generated.setItems(generated)
proc generateNewAccount*(self: View, password: string, accountName: string, color: string): string {.slot.} =
return self.delegate.generateNewAccount(password, accountName, color)

@ -1 +1 @@
Subproject commit 8495fae8a50c3a7da7796c3348208bfc6aa0c47e
Subproject commit c3c0ac64d50268cd35b84f1c73184d4b7b7e9a5f

View File

@ -0,0 +1,21 @@
import StatusQ.Components 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Core 0.1
StatusListItem {
property var account
title: account.name
subTitle: account.address
icon.isLetterIdenticon: true
width: parent.width
leftPadding: 0
rightPadding: 0
components: [
StatusIcon {
icon: "chevron-down"
rotation: 270
color: Theme.palette.baseColor1
}
]
}

View File

@ -6,4 +6,9 @@ QtObject {
property var layer1Networks: networksModule.layer1
property var layer2Networks: networksModule.layer2
property var testNetworks: networksModule.test
}
property var importedAccounts: walletSectionAccounts.imported
property var generatedAccounts: walletSectionAccounts.generated
property var watchOnlyAccounts: walletSectionAccounts.watchOnly
}

View File

@ -7,6 +7,8 @@ import StatusQ.Core.Theme 0.1
import StatusQ.Core 0.1
import "../../stores"
import "../../controls"
Column {
id: root
@ -93,15 +95,36 @@ Column {
bottomPadding: Style.current.padding
}
Repeater {
model: walletStore.generatedAccounts
delegate: WalletAccountDelegate {
account: model
}
}
StatusSectionHeadline {
text: qsTr("Imported")
topPadding: Style.current.bigPadding
bottomPadding: Style.current.padding
}
Repeater {
model: walletStore.importedAccounts
delegate: WalletAccountDelegate {
account: model
}
}
StatusSectionHeadline {
text: qsTr("Watch-Only")
topPadding: Style.current.bigPadding
bottomPadding: Style.current.padding
}
Repeater {
model: walletStore.watchOnlyAccounts
delegate: WalletAccountDelegate {
account: model
}
}
}