fix: Show only selected networks (#16588)
This commit is contained in:
parent
f7823cd0b7
commit
c47f42eb39
|
@ -23,7 +23,7 @@ SplitView {
|
|||
}
|
||||
|
||||
NetworkSelectorView {
|
||||
id: networkSelectionView
|
||||
id: networkSelectorView
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
@ -40,7 +40,7 @@ SplitView {
|
|||
}
|
||||
|
||||
NetworkSelectorView {
|
||||
id: networkSelectionView2
|
||||
id: networkSelectorView2
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
@ -72,10 +72,10 @@ SplitView {
|
|||
model: NetworksModel.flatNetworks
|
||||
delegate: CheckBox {
|
||||
text: model.chainName
|
||||
checked: networkSelectionView.selection.includes(model.chainId)
|
||||
checked: networkSelectorView.selection.includes(model.chainId)
|
||||
onToggled: {
|
||||
if (checked) {
|
||||
networkSelectionView.selection = [model.chainId]
|
||||
networkSelectorView.selection = [model.chainId]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,14 +89,14 @@ SplitView {
|
|||
model: NetworksModel.flatNetworks
|
||||
delegate: CheckBox {
|
||||
text: model.chainName
|
||||
checked: networkSelectionView2.selection.includes(model.chainId)
|
||||
checked: networkSelectorView2.selection.includes(model.chainId)
|
||||
onToggled: {
|
||||
if (checked) {
|
||||
const selection = networkSelectionView2.selection
|
||||
const selection = networkSelectorView2.selection
|
||||
selection.push(model.chainId)
|
||||
networkSelectionView2.selection = selection
|
||||
networkSelectorView2.selection = selection
|
||||
} else {
|
||||
networkSelectionView2.selection = networkSelectionView2.selection.filter((id) => id !== model.chainId)
|
||||
networkSelectorView2.selection = networkSelectorView2.selection.filter((id) => id !== model.chainId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,6 +62,14 @@ Item {
|
|||
|
||||
property bool forceRefreshBalanceStore: false
|
||||
readonly property var splitAddresses: root.networkFilters.split(":")
|
||||
|
||||
readonly property SortFilterProxyModel enabledNetworksModel: SortFilterProxyModel {
|
||||
sourceModel: root.allNetworksModel
|
||||
filters: ValueFilter {
|
||||
roleName: "isEnabled"
|
||||
value: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
|
@ -105,7 +113,7 @@ Item {
|
|||
}
|
||||
decimals: token && token.decimals ? token.decimals : 4
|
||||
balances: token && token.balances ? token.balances: null
|
||||
allNetworksModel: root.allNetworksModel
|
||||
networksModel: d.enabledNetworksModel
|
||||
isLoading: d.marketDetailsLoading
|
||||
address: root.address
|
||||
errorTooltipText: token && token.balances ? networkConnectionStore.getBlockchainNetworkDownTextForToken(token.balances): ""
|
||||
|
|
|
@ -1,116 +0,0 @@
|
|||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
|
||||
import StatusQ 0.1
|
||||
import StatusQ.Core 0.1
|
||||
import StatusQ.Core.Theme 0.1
|
||||
|
||||
import SortFilterProxyModel 0.2
|
||||
|
||||
import utils 1.0
|
||||
|
||||
import "../stores/NetworkSelectPopup"
|
||||
import "../controls"
|
||||
|
||||
StatusListView {
|
||||
id: root
|
||||
|
||||
required property var flatNetworks
|
||||
property bool useEnabledRole: true
|
||||
property SingleSelectionInfo singleSelection: SingleSelectionInfo {}
|
||||
property var preferredSharingNetworks: []
|
||||
property bool preferredNetworksMode: false
|
||||
property bool showCheckboxes: true
|
||||
property bool showRadioButtons: true
|
||||
|
||||
signal toggleNetwork(var network, int index)
|
||||
|
||||
/// Mirrors Nim's UxEnabledState enum from networks/item.nim
|
||||
enum UxEnabledState {
|
||||
Enabled,
|
||||
AllEnabled,
|
||||
Disabled
|
||||
}
|
||||
|
||||
model: root.flatNetworks
|
||||
|
||||
delegate: NetworkSelectItemDelegate {
|
||||
id: delegateItem
|
||||
|
||||
required property var model
|
||||
readonly property int multiSelectCheckState: {
|
||||
if(root.preferredNetworksMode) {
|
||||
return root.preferredSharingNetworks.length === root.count ?
|
||||
Qt.PartiallyChecked :
|
||||
root.preferredSharingNetworks.includes(model.chainId.toString()) ? Qt.Checked : Qt.Unchecked
|
||||
}
|
||||
else if(root.useEnabledRole) {
|
||||
return model.isEnabled ? Qt.Checked : Qt.Unchecked
|
||||
} else if (model.enabledState === NetworkSelectionView.UxEnabledState.Enabled) {
|
||||
return Qt.Checked
|
||||
} else {
|
||||
if( model.enabledState === NetworkSelectionView.UxEnabledState.AllEnabled) {
|
||||
return Qt.PartiallyChecked
|
||||
} else {
|
||||
return Qt.Unchecked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
readonly property int singleSelectCheckState: {
|
||||
if (root.singleSelection.currentModel === root.model && root.singleSelection.currentIndex === model.index)
|
||||
return Qt.Checked
|
||||
return Qt.Unchecked
|
||||
}
|
||||
|
||||
|
||||
implicitHeight: 48
|
||||
implicitWidth: root.width
|
||||
title: model.chainName
|
||||
iconUrl: Theme.svg(model.iconUrl)
|
||||
showIndicator: (multiSelection && root.showCheckboxes) || (!multiSelection && root.showRadioButtons)
|
||||
multiSelection: !root.singleSelection.enabled
|
||||
|
||||
Binding on checkState {
|
||||
when: root.singleSelection.enabled
|
||||
value: singleSelectCheckState
|
||||
}
|
||||
|
||||
Binding on checkState {
|
||||
when: !root.singleSelection.enabled
|
||||
value: multiSelectCheckState
|
||||
}
|
||||
|
||||
nextCheckState: checkState
|
||||
onToggled: {
|
||||
if(!root.singleSelection.enabled) {
|
||||
Qt.callLater(root.toggleNetwork, delegateItem.model, delegateItem.model.index)
|
||||
} else if(!checkState !== Qt.Checked) { // Don't allow uncheck
|
||||
checkState = checkState === Qt.Checked ? Qt.Unchecked : Qt.Checked
|
||||
root.toggleNetwork(delegateItem.model, model.index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
section {
|
||||
property: "layer"
|
||||
delegate: Loader {
|
||||
required property int section
|
||||
width: parent.width
|
||||
sourceComponent: section === 2 ? layer2text: null
|
||||
|
||||
Component {
|
||||
id: layer2text
|
||||
StatusBaseText {
|
||||
width: parent.width
|
||||
color: Theme.palette.baseColor1
|
||||
text: qsTr("Layer 2")
|
||||
height: 40
|
||||
leftPadding: 16
|
||||
topPadding: 10
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
AssetsDetailView 1.0 AssetsDetailView.qml
|
||||
CollectiblesView 1.0 CollectiblesView.qml
|
||||
NetworkSelectionView 1.0 NetworkSelectionView.qml
|
||||
NetworkSelectorView 1.0 NetworkSelectorView.qml
|
||||
SavedAddresses 1.0 SavedAddresses.qml
|
||||
TokenSelectorAssetDelegate 1.0 TokenSelectorAssetDelegate.qml
|
||||
|
|
|
@ -23,7 +23,7 @@ Control {
|
|||
property alias communityTag: communityTag
|
||||
property var balances
|
||||
property int decimals
|
||||
property var allNetworksModel
|
||||
property var networksModel
|
||||
property bool isLoading: false
|
||||
property string errorTooltipText
|
||||
property string address
|
||||
|
@ -110,7 +110,7 @@ Control {
|
|||
Repeater {
|
||||
id: chainRepeater
|
||||
Layout.alignment: Qt.AlignRight
|
||||
model: root.allNetworksModel
|
||||
model: root.networksModel
|
||||
delegate: InformationTag {
|
||||
readonly property double aggregatedbalance: balancesAggregator.value/(10 ** root.decimals)
|
||||
SortFilterProxyModel {
|
||||
|
|
Loading…
Reference in New Issue