feat(@desktop/wallet2): Toggle network
This commit is contained in:
parent
6e3ac7d5dc
commit
1cea69b331
|
@ -40,7 +40,7 @@ QtObject:
|
||||||
result.accountsView = newAccountsView(status)
|
result.accountsView = newAccountsView(status)
|
||||||
result.collectiblesView = newCollectiblesView(status, appService)
|
result.collectiblesView = newCollectiblesView(status, appService)
|
||||||
result.settingsView = newSettingsView()
|
result.settingsView = newSettingsView()
|
||||||
result.networksView = newNetworksView()
|
result.networksView = newNetworksView(status)
|
||||||
result.cryptoServiceController = newCryptoServiceController(status, appService)
|
result.cryptoServiceController = newCryptoServiceController(status, appService)
|
||||||
result.savedAddressesView = newSavedAddressesView(status, appService)
|
result.savedAddressesView = newSavedAddressesView(status, appService)
|
||||||
result.setup
|
result.setup
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import NimQml, chronicles, sequtils, sugar
|
import NimQml, chronicles, sequtils, sugar
|
||||||
from status/types/network import Network, `$`
|
from status/types/network import Network, `$`
|
||||||
|
import status/[status, wallet2]
|
||||||
import ./network_list
|
import ./network_list
|
||||||
|
|
||||||
logScope:
|
logScope:
|
||||||
|
@ -8,14 +8,16 @@ logScope:
|
||||||
|
|
||||||
QtObject:
|
QtObject:
|
||||||
type NetworksView* = ref object of QObject
|
type NetworksView* = ref object of QObject
|
||||||
|
status: Status
|
||||||
allNetworks: NetworkList
|
allNetworks: NetworkList
|
||||||
enabledNetworks: NetworkList
|
enabledNetworks: NetworkList
|
||||||
|
|
||||||
proc setup(self: NetworksView) = self.QObject.setup
|
proc setup(self: NetworksView) = self.QObject.setup
|
||||||
proc delete(self: NetworksView) = self.QObject.delete
|
proc delete(self: NetworksView) = self.QObject.delete
|
||||||
|
|
||||||
proc newNetworksView*(): NetworksView =
|
proc newNetworksView*(status: Status): NetworksView =
|
||||||
new(result, delete)
|
new(result, delete)
|
||||||
|
result.status = status
|
||||||
result.allNetworks = newNetworkList()
|
result.allNetworks = newNetworkList()
|
||||||
result.enabledNetworks = newNetworkList()
|
result.enabledNetworks = newNetworkList()
|
||||||
result.setup
|
result.setup
|
||||||
|
@ -35,3 +37,10 @@ QtObject:
|
||||||
|
|
||||||
QtProperty[QVariant] enabledNetworks:
|
QtProperty[QVariant] enabledNetworks:
|
||||||
read = getEnabledNetworks
|
read = getEnabledNetworks
|
||||||
|
|
||||||
|
proc toggleNetwork(self: NetworksView, chainId: int) {.slot.} =
|
||||||
|
for network in self.allNetworks.networks:
|
||||||
|
if network.chainId == chainId:
|
||||||
|
self.status.wallet2.toggleNetwork(network)
|
||||||
|
self.updateNetworks(self.status.wallet2.networks)
|
||||||
|
break
|
|
@ -97,6 +97,9 @@ Item {
|
||||||
qrCode: walletView.store.profileModelInst.qrCode(walletView.store.selectedAccount.address)
|
qrCode: walletView.store.profileModelInst.qrCode(walletView.store.selectedAccount.address)
|
||||||
allNetworksModel: walletView.store.walletModelV2Inst.networksView.allNetworks
|
allNetworksModel: walletView.store.walletModelV2Inst.networksView.allNetworks
|
||||||
enabledNetworksModel: walletView.store.walletModelV2Inst.networksView.enabledNetworks
|
enabledNetworksModel: walletView.store.walletModelV2Inst.networksView.enabledNetworks
|
||||||
|
onToggleNetwork: {
|
||||||
|
walletView.store.walletModelV2Inst.networksView.toggleNetwork(chainId)
|
||||||
|
}
|
||||||
onCopyText: {
|
onCopyText: {
|
||||||
walletView.store.copyText(text);
|
walletView.store.copyText(text);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ Item {
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
property var allNetworks
|
property var allNetworks
|
||||||
property var enabledNetworks
|
property var enabledNetworks
|
||||||
|
signal toggleNetwork(int chainId)
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: selectRectangle
|
id: selectRectangle
|
||||||
|
@ -65,5 +66,8 @@ Item {
|
||||||
x: (parent.width - width)
|
x: (parent.width - width)
|
||||||
y: (root.height - networkFilterPanel.height)
|
y: (root.height - networkFilterPanel.height)
|
||||||
model: root.allNetworks
|
model: root.allNetworks
|
||||||
|
onToggleNetwork: {
|
||||||
|
root.toggleNetwork(chainId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ Item {
|
||||||
property var enabledNetworksModel
|
property var enabledNetworksModel
|
||||||
property var allNetworksModel
|
property var allNetworksModel
|
||||||
signal copyText(string text)
|
signal copyText(string text)
|
||||||
|
signal toggleNetwork(int chainId)
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
id: accountRow
|
id: accountRow
|
||||||
|
@ -78,6 +79,9 @@ Item {
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
allNetworks: walletHeader.allNetworksModel
|
allNetworks: walletHeader.allNetworksModel
|
||||||
enabledNetworks: walletHeader.enabledNetworksModel
|
enabledNetworks: walletHeader.enabledNetworksModel
|
||||||
|
onToggleNetwork: {
|
||||||
|
walletHeader.toggleNetwork(chainId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
|
|
|
@ -14,6 +14,7 @@ Popup {
|
||||||
height: 432
|
height: 432
|
||||||
closePolicy: Popup.CloseOnEscape
|
closePolicy: Popup.CloseOnEscape
|
||||||
property var model
|
property var model
|
||||||
|
signal toggleNetwork(int chainId)
|
||||||
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
radius: Style.current.radius
|
radius: Style.current.radius
|
||||||
|
@ -65,7 +66,9 @@ Popup {
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
checked: model.enabled
|
checked: model.enabled
|
||||||
onCheckedChanged: {
|
onCheckedChanged: {
|
||||||
console.log("TODO: Not yet implemented")
|
if(checked !== model.enabled){
|
||||||
|
popup.toggleNetwork(model.chainId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit c07e04e976f46edc72077b4095001afd10170a6a
|
Subproject commit fe7e74459ed3cb7601087db3e16931f06ed36ad0
|
Loading…
Reference in New Issue