2023-11-22 19:58:02 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
|
2023-11-24 12:16:13 +00:00
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
|
|
|
|
import StatusQ 0.1
|
2023-11-22 19:58:02 +00:00
|
|
|
import StatusQ.Core 0.1
|
2023-11-24 12:16:13 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as SQUtils
|
2023-11-22 19:58:02 +00:00
|
|
|
|
|
|
|
import mainui 1.0
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import shared.views 1.0
|
2023-12-18 10:12:57 +00:00
|
|
|
import shared.stores 1.0
|
2023-11-22 19:58:02 +00:00
|
|
|
|
|
|
|
import Storybook 1.0
|
|
|
|
import Models 1.0
|
|
|
|
|
2023-11-24 12:16:13 +00:00
|
|
|
import AppLayouts.Wallet.views 1.0
|
|
|
|
|
2023-11-22 19:58:02 +00:00
|
|
|
SplitView {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
Logs { id: logs }
|
|
|
|
|
|
|
|
orientation: Qt.Horizontal
|
|
|
|
|
2023-11-24 12:16:13 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
readonly property string networksChainsCurrentlySelected: {
|
|
|
|
let supportNwChains = ":"
|
|
|
|
for (let i =0; i< networksRepeater.count; i++) {
|
|
|
|
if (networksRepeater.itemAt(i).checked && networksRepeater.itemAt(i).visible)
|
|
|
|
supportNwChains += networksRepeater.itemAt(i).chainID + ":"
|
|
|
|
}
|
|
|
|
return supportNwChains
|
|
|
|
}
|
|
|
|
|
|
|
|
readonly property string addressesSelected: {
|
|
|
|
let supportedAddresses = ""
|
|
|
|
let allChecked = true
|
|
|
|
let allUnchecked = true
|
|
|
|
for (let i =0; i< accountsRepeater.count; i++) {
|
|
|
|
if (accountsRepeater.itemAt(i).checked && accountsRepeater.itemAt(i).visible)
|
|
|
|
supportedAddresses += accountsRepeater.itemAt(i).address
|
|
|
|
allChecked = allChecked && accountsRepeater.itemAt(i).checked
|
|
|
|
allUnchecked = allUnchecked && !accountsRepeater.itemAt(i).checked
|
|
|
|
}
|
|
|
|
if(allChecked || allUnchecked) {
|
|
|
|
supportedAddresses = ""
|
|
|
|
}
|
|
|
|
return supportedAddresses
|
|
|
|
}
|
|
|
|
|
2023-12-18 10:12:57 +00:00
|
|
|
readonly property var currencyStore: CurrenciesStore {}
|
2023-11-24 12:16:13 +00:00
|
|
|
|
|
|
|
readonly property var groupedAccountsAssetsModel: GroupedAccountsAssetsModel {}
|
|
|
|
readonly property var tokensBySymbolModel: TokensBySymbolModel {}
|
2023-12-18 10:12:57 +00:00
|
|
|
readonly property CommunitiesModel communityModel: CommunitiesModel {}
|
2023-11-24 12:16:13 +00:00
|
|
|
|
|
|
|
// Added this here simply because the network and address filtering wont work in Storybook applied in AssetsView
|
|
|
|
readonly property SubmodelProxyModel assetsWithFilteredBalances: SubmodelProxyModel {
|
|
|
|
sourceModel: d.groupedAccountsAssetsModel
|
|
|
|
submodelRoleName: "balances"
|
|
|
|
delegateModel: SortFilterProxyModel {
|
|
|
|
sourceModel: submodel
|
|
|
|
filters: ExpressionFilter {
|
|
|
|
expression: {
|
|
|
|
d.networksChainsCurrentlySelected
|
|
|
|
d.addressesSelected
|
|
|
|
return d.networksChainsCurrentlySelected.split(":").includes(chainId+"") &&
|
2023-12-18 10:12:57 +00:00
|
|
|
(!! d.addressesSelected ? d.addressesSelected.toUpperCase() === account.toUpperCase() : true)
|
2023-11-24 12:16:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// renaming tokens by symbol key so that can be used to join models
|
|
|
|
readonly property var renamedTokensBySymbolModel: RolesRenamingModel {
|
|
|
|
sourceModel: d.tokensBySymbolModel
|
|
|
|
mapping: [
|
|
|
|
RoleRename {
|
|
|
|
from: "key"
|
|
|
|
to: "tokensKey"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
// join account assets and tokens by symbol model
|
|
|
|
property LeftJoinModel jointModel: LeftJoinModel {
|
|
|
|
leftModel: d.assetsWithFilteredBalances
|
|
|
|
rightModel: d.renamedTokensBySymbolModel
|
|
|
|
joinRole: "tokensKey"
|
|
|
|
}
|
|
|
|
|
|
|
|
// combining community model with assets to get community meta data
|
|
|
|
property LeftJoinModel builtAccountAssetsModel: LeftJoinModel {
|
|
|
|
leftModel: d.jointModel
|
|
|
|
rightModel: d.communityModel
|
|
|
|
joinRole: "communityId"
|
|
|
|
}
|
2023-11-22 19:58:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Popups {
|
|
|
|
popupParent: root
|
|
|
|
rootStore: QtObject {}
|
|
|
|
communityTokensStore: QtObject {}
|
|
|
|
}
|
|
|
|
|
2023-11-24 12:16:13 +00:00
|
|
|
StackLayout {
|
|
|
|
id: stack
|
|
|
|
SplitView.fillWidth: true
|
2023-11-22 19:58:02 +00:00
|
|
|
SplitView.fillHeight: true
|
|
|
|
|
2023-11-24 12:16:13 +00:00
|
|
|
currentIndex: 0
|
2023-11-22 19:58:02 +00:00
|
|
|
|
2023-11-24 12:16:13 +00:00
|
|
|
AssetsView {
|
|
|
|
id: assetsView
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
areAssetsLoading: loadingCheckbox.checked
|
|
|
|
assets: d.builtAccountAssetsModel
|
|
|
|
filterVisible: ctrlFilterVisible.checked
|
|
|
|
currencyStore: d.currencyStore
|
|
|
|
networkFilters: d.networksChainsCurrentlySelected
|
|
|
|
addressFilters: d.addressesSelected
|
|
|
|
onAssetClicked: {
|
|
|
|
stack.currentIndex = 1
|
|
|
|
detailsView.token = token
|
|
|
|
logs.logEvent("onAssetClicked", ["token"], [token.symbol, token.communityId])
|
|
|
|
}
|
|
|
|
onSendRequested: logs.logEvent("onSendRequested", ["symbol"], arguments)
|
|
|
|
onReceiveRequested: logs.logEvent("onReceiveRequested", ["symbol"], arguments)
|
|
|
|
onSwitchToCommunityRequested: logs.logEvent("onSwitchToCommunityRequested", ["communityId"], arguments)
|
|
|
|
onManageTokensRequested: logs.logEvent("onManageTokensRequested")
|
|
|
|
}
|
2023-11-22 19:58:02 +00:00
|
|
|
|
2023-11-24 12:16:13 +00:00
|
|
|
AssetsDetailView {
|
|
|
|
id: detailsView
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
currencyStore: d.currencyStore
|
|
|
|
allNetworksModel: NetworksModel.allNetworks
|
|
|
|
networkFilters: d.networksChainsCurrentlySelected
|
|
|
|
Button {
|
|
|
|
anchors.top: parent.top
|
|
|
|
text: "go back"
|
|
|
|
onClicked: stack.currentIndex = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Pane {
|
|
|
|
SplitView.minimumWidth: 300
|
|
|
|
SplitView.preferredWidth: 300
|
2023-12-06 10:54:36 +00:00
|
|
|
|
|
|
|
ColumnLayout {
|
2023-11-24 12:16:13 +00:00
|
|
|
spacing: 12
|
|
|
|
anchors.fill: parent
|
|
|
|
|
2023-12-06 10:54:36 +00:00
|
|
|
Switch {
|
|
|
|
id: ctrlFilterVisible
|
|
|
|
text: "Filter visible"
|
|
|
|
checked: true
|
|
|
|
}
|
2023-11-24 12:16:13 +00:00
|
|
|
|
|
|
|
CheckBox {
|
|
|
|
id: loadingCheckbox
|
2023-12-18 10:12:57 +00:00
|
|
|
checked: false
|
2023-11-24 12:16:13 +00:00
|
|
|
text: "loading"
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Text {
|
|
|
|
text: "select supported network(s)"
|
|
|
|
}
|
|
|
|
Repeater {
|
|
|
|
id: networksRepeater
|
|
|
|
model: NetworksModel.allNetworks
|
|
|
|
delegate: CheckBox {
|
|
|
|
property int chainID: chainId
|
|
|
|
width: parent.width
|
|
|
|
text: chainName
|
|
|
|
visible: isTest
|
|
|
|
checked: true
|
|
|
|
onToggled: {
|
|
|
|
isEnabled = checked
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Text {
|
|
|
|
text: "select account(s)"
|
|
|
|
}
|
|
|
|
Repeater {
|
|
|
|
id: accountsRepeater
|
|
|
|
model: WalletAccountsModel {}
|
|
|
|
delegate: CheckBox {
|
|
|
|
property string address: model.address
|
|
|
|
checked: true
|
|
|
|
visible: index<2
|
|
|
|
width: parent.width
|
|
|
|
text: name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-12-06 10:54:36 +00:00
|
|
|
}
|
2023-11-22 19:58:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// category: Views
|
|
|
|
// https://www.figma.com/file/FkFClTCYKf83RJWoifWgoX/Wallet-v2?type=design&node-id=17159-67977&mode=design&t=s5EXsh6Vi4nTNYUh-0
|
|
|
|
// https://www.figma.com/file/FkFClTCYKf83RJWoifWgoX/Wallet-v2?type=design&node-id=17171-285559&mode=design&t=s5EXsh6Vi4nTNYUh-0
|