refactor(wallet): show qr popup updated to meet new ui requirements
Show Qr popup is partially refactored because of the two things: - to meet new UI requirements (introduced in the new saved addresses design) - to make usage of that popup more generic, that it can be easily used from different places
This commit is contained in:
parent
a22847b000
commit
e115d5e7ce
|
@ -252,5 +252,15 @@ QtObject:
|
|||
break
|
||||
return networkString
|
||||
|
||||
proc getNetworkIds*(self: Model, shortNames: string): string =
|
||||
var networkIds = ""
|
||||
let networksNames = shortNames.split(":")
|
||||
for name in networksNames:
|
||||
for item in self.items:
|
||||
if item.getShortName() == name:
|
||||
networkIds = networkIds & $item.getChainId() & ':'
|
||||
break
|
||||
return networkIds
|
||||
|
||||
proc getAllNetworksChainIds*(self: Model): string =
|
||||
return self.items.map(x => x.getChainId()).join(":")
|
||||
|
|
|
@ -100,7 +100,7 @@ QtObject:
|
|||
QtProperty[QVariant] enabledChainIds:
|
||||
read = getEnabledChainIds
|
||||
notify = enabledChainIdsChanged
|
||||
|
||||
|
||||
proc setItems*(self: View, networks: seq[NetworkDto]) =
|
||||
var items: seq[Item] = @[]
|
||||
let allEnabled = areAllEnabled(networks)
|
||||
|
@ -150,6 +150,9 @@ QtObject:
|
|||
proc getNetworkShortNames*(self: View, preferredNetworks: string): string {.slot.} =
|
||||
return self.all.getNetworkShortNames(preferredNetworks)
|
||||
|
||||
proc getNetworkIds*(self: View, shortNames: string): string {.slot.} =
|
||||
return self.all.getNetworkIds(shortNames)
|
||||
|
||||
proc getAllNetworksChainIds*(self: View): string {.slot.} =
|
||||
return self.all.getAllNetworksChainIds()
|
||||
|
||||
|
|
|
@ -21,6 +21,9 @@ method createOrUpdateSavedAddress*(self: AccessInterface, name: string, address:
|
|||
chainShortNames: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method updatePreferredChains*(self: AccessInterface, address: string, chainShortNames: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method deleteSavedAddress*(self: AccessInterface, address: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
|
|
@ -61,6 +61,12 @@ method createOrUpdateSavedAddress*(self: Module, name: string, address: string,
|
|||
chainShortNames: string) =
|
||||
self.controller.createOrUpdateSavedAddress(name, address, ens, colorId, chainShortNames)
|
||||
|
||||
method updatePreferredChains*(self: Module, address: string, chainShortNames: string) =
|
||||
let item = self.view.getModel().getItemByAddress(address, self.controller.areTestNetworksEnabled())
|
||||
if item.getAddress().len == 0:
|
||||
return
|
||||
self.controller.createOrUpdateSavedAddress(item.getName(), address, item.getEns(), item.getColorId(), chainShortNames)
|
||||
|
||||
method deleteSavedAddress*(self: Module, address: string) =
|
||||
self.controller.deleteSavedAddress(address)
|
||||
|
||||
|
|
|
@ -46,6 +46,9 @@ QtObject:
|
|||
chainShortNames: string) {.slot.} =
|
||||
self.delegate.createOrUpdateSavedAddress(name, address, ens, colorId, chainShortNames)
|
||||
|
||||
proc updatePreferredChains*(self: View, address: string, chainShortNames: string) {.slot.} =
|
||||
self.delegate.updatePreferredChains(address, chainShortNames)
|
||||
|
||||
proc savedAddressDeleted*(self: View, name: string, address: string, errorMsg: string) {.signal.}
|
||||
|
||||
proc deleteSavedAddress*(self: View, address: string) {.slot.} =
|
||||
|
|
|
@ -134,7 +134,7 @@ Rectangle {
|
|||
QtObject {
|
||||
id: d
|
||||
readonly property color iconColor: !statusRoundButton.enabled ? statusRoundButton.icon.disabledColor :
|
||||
(statusRoundButton.enabled && statusRoundButton.hovered) ? statusRoundButton.icon.hoverColor :
|
||||
(statusRoundButton.enabled && (statusRoundButton.hovered || statusRoundButton.highlighted)) ? statusRoundButton.icon.hoverColor :
|
||||
statusRoundButton.icon.color
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,13 @@ import AppLayouts.Wallet.popups 1.0
|
|||
StatusMenu {
|
||||
id: root
|
||||
|
||||
property string selectedAddress
|
||||
property var selectedAccount: ({
|
||||
address: "",
|
||||
name: "",
|
||||
emoji: "",
|
||||
colorId: "",
|
||||
preferredSharingChainIds: ""
|
||||
})
|
||||
property bool areTestNetworksEnabled: false
|
||||
property bool isSepoliaEnabled: false
|
||||
property string preferredSharingNetworks
|
||||
|
@ -49,7 +55,7 @@ StatusMenu {
|
|||
}
|
||||
}
|
||||
|
||||
Global.openLink("%1/%2/%3".arg(link).arg(Constants.networkExplorerLinks.addressPath).arg(root.selectedAddress))
|
||||
Global.openLink("%1/%2/%3".arg(link).arg(Constants.networkExplorerLinks.addressPath).arg(root.selectedAccount.address?? ""))
|
||||
}
|
||||
}
|
||||
StatusAction {
|
||||
|
@ -58,7 +64,7 @@ StatusMenu {
|
|||
icon.name: "link"
|
||||
onTriggered: {
|
||||
const link = areTestNetworksEnabled ? Constants.networkExplorerLinks.goerliArbiscan : Constants.networkExplorerLinks.arbiscan
|
||||
Global.openLink("%1/%2/%3".arg(link).arg(Constants.networkExplorerLinks.addressPath).arg(root.selectedAddress))
|
||||
Global.openLink("%1/%2/%3".arg(link).arg(Constants.networkExplorerLinks.addressPath).arg(root.selectedAccount.address?? ""))
|
||||
}
|
||||
}
|
||||
StatusAction {
|
||||
|
@ -67,7 +73,7 @@ StatusMenu {
|
|||
icon.name: "link"
|
||||
onTriggered: {
|
||||
const link = areTestNetworksEnabled ? Constants.networkExplorerLinks.goerliOptimistic : Constants.networkExplorerLinks.optimistic
|
||||
Global.openLink("%1/%2/%3".arg(link).arg(Constants.networkExplorerLinks.addressPath).arg(root.selectedAddress))
|
||||
Global.openLink("%1/%2/%3".arg(link).arg(Constants.networkExplorerLinks.addressPath).arg(root.selectedAccount.address?? ""))
|
||||
}
|
||||
}
|
||||
StatusSuccessAction {
|
||||
|
@ -75,27 +81,22 @@ StatusMenu {
|
|||
successText: qsTr("Address copied")
|
||||
text: qsTr("Copy address")
|
||||
icon.name: "copy"
|
||||
onTriggered: root.copyToClipboard(root.selectedAddress)
|
||||
onTriggered: root.copyToClipboard(root.selectedAccount.address?? "")
|
||||
}
|
||||
StatusAction {
|
||||
id: showQrAction
|
||||
text: qsTr("Show address QR")
|
||||
icon.name: "qr"
|
||||
onTriggered: Global.openPopup(addressQr)
|
||||
}
|
||||
|
||||
Component {
|
||||
id: addressQr
|
||||
ReceiveModal {
|
||||
anchors.centerIn: parent
|
||||
address: root.selectedAddress
|
||||
chainShortNames: root.preferredSharingNetworks
|
||||
preferredSharingNetworksArray: root.preferredSharingNetworksArray
|
||||
readOnly: true
|
||||
hasFloatingButtons: false
|
||||
advancedHeaderComponent: null
|
||||
description: qsTr("Address")
|
||||
onClosed: destroy()
|
||||
}
|
||||
onTriggered: Global.openShowQRPopup({
|
||||
showSingleAccount: true,
|
||||
switchingAccounsEnabled: false,
|
||||
changingPreferredChainsEnabled: false,
|
||||
hasFloatingButtons: false,
|
||||
name: root.selectedAccount.name?? "",
|
||||
address: root.selectedAccount.address?? "",
|
||||
emoji: root.selectedAccount.emoji?? "",
|
||||
colorId: root.selectedAccount.colorId?? "",
|
||||
preferredSharingChainIds: root.selectedAccount.preferredSharingChainIds?? ""
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -342,7 +342,7 @@ ColumnLayout {
|
|||
|
||||
WalletAddressMenu {
|
||||
id: addressMenu
|
||||
selectedAddress: !!root.account ? root.account.address: ""
|
||||
selectedAccount: root.account
|
||||
areTestNetworksEnabled: root.walletStore.areTestNetworksEnabled
|
||||
isSepoliaEnabled: root.walletStore.isSepoliaEnabled
|
||||
preferredSharingNetworks: d.preferredSharingNetworkShortNames
|
||||
|
|
|
@ -138,7 +138,11 @@ Item {
|
|||
|
||||
headerButton.text: RootStore.overview.ens || StatusQUtils.Utils.elideText(RootStore.overview.mixedcaseAddress, 6, 4)
|
||||
headerButton.visible: !RootStore.overview.isAllAccounts
|
||||
onLaunchShareAddressModal: Global.openPopup(receiveModalComponent);
|
||||
onLaunchShareAddressModal: Global.openShowQRPopup({
|
||||
switchingAccounsEnabled: true,
|
||||
changingPreferredChainsEnabled: true,
|
||||
hasFloatingButtons: true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -204,7 +208,11 @@ Item {
|
|||
networkConnectionStore: root.networkConnectionStore
|
||||
isCommunityOwnershipTransfer: footer.isHoldingSelected && footer.isOwnerCommunityCollectible
|
||||
communityName: !!walletStore.currentViewedCollectible ? walletStore.currentViewedCollectible.communityName : ""
|
||||
onLaunchShareAddressModal: Global.openPopup(receiveModalComponent)
|
||||
onLaunchShareAddressModal: Global.openShowQRPopup({
|
||||
switchingAccounsEnabled: true,
|
||||
changingPreferredChainsEnabled: true,
|
||||
hasFloatingButtons: true
|
||||
})
|
||||
onLaunchSendModal: {
|
||||
if(isCommunityOwnershipTransfer) {
|
||||
let tokenItem = walletStore.currentViewedCollectible
|
||||
|
@ -241,14 +249,6 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: receiveModalComponent
|
||||
ReceiveModal {
|
||||
destroyOnClose: true
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: keypairImport
|
||||
active: false
|
||||
|
|
|
@ -18,63 +18,127 @@ import shared.popups 1.0
|
|||
import shared.popups.send.controls 1.0
|
||||
|
||||
import AppLayouts.stores 1.0
|
||||
import ".."
|
||||
import "../stores"
|
||||
|
||||
StatusModal {
|
||||
id: root
|
||||
|
||||
property string address: RootStore.selectedReceiveAccount.address
|
||||
property string chainShortNames: RootStore.getNetworkShortNames(d.preferredSharingNetworksString)
|
||||
property var preferredSharingNetworksArray: d.preferredSharingNetworksString.split(":").filter(Boolean)
|
||||
property var accounts
|
||||
property var selectedAccount
|
||||
|
||||
property string description: qsTr("Your Address")
|
||||
property bool switchingAccounsEnabled: true
|
||||
property bool changingPreferredChainsEnabled: true
|
||||
|
||||
property bool readOnly: false
|
||||
signal selectedAccountIndexChanged(int selectedIndex)
|
||||
signal updatePreferredChains(string address, string preferredChains)
|
||||
|
||||
QtObject {
|
||||
id: d
|
||||
property string completeAddressWithNetworkPrefix: root.chainShortNames + root.address
|
||||
property string preferredSharingNetworksString: !!RootStore.selectedReceiveAccount ? RootStore.selectedReceiveAccount.preferredSharingChainIds : ""
|
||||
onPreferredSharingNetworksStringChanged: {
|
||||
root.preferredSharingNetworksArray = d.preferredSharingNetworksString.split(":").filter(Boolean)
|
||||
root.chainShortNames = RootStore.getNetworkShortNames(d.preferredSharingNetworksString)
|
||||
onSelectedAccountChanged: {
|
||||
d.preferredChainIdsArray = root.selectedAccount.preferredSharingChainIds.split(":").filter(Boolean)
|
||||
}
|
||||
|
||||
width: 556
|
||||
contentHeight: content.implicitHeight + d.advanceFooterHeight
|
||||
|
||||
hasFloatingButtons: true
|
||||
|
||||
showHeader: false
|
||||
showAdvancedHeader: hasFloatingButtons
|
||||
advancedHeaderComponent: AccountsModalHeader {
|
||||
control.enabled: root.switchingAccounsEnabled && model.count > 1
|
||||
model: SortFilterProxyModel {
|
||||
sourceModel: root.accounts
|
||||
|
||||
sorters: RoleSorter { roleName: "position"; sortOrder: Qt.AscendingOrder }
|
||||
}
|
||||
|
||||
selectedAccount: root.selectedAccount
|
||||
getNetworkShortNames: RootStore.getNetworkShortNames
|
||||
onSelectedIndexChanged: {
|
||||
root.selectedAccountIndexChanged(selectedIndex)
|
||||
}
|
||||
}
|
||||
|
||||
showFooter: false
|
||||
showAdvancedFooter: true
|
||||
advancedFooterComponent: Rectangle {
|
||||
width: parent.width
|
||||
height: d.advanceFooterHeight
|
||||
color: Theme.palette.baseColor4
|
||||
radius: 16
|
||||
|
||||
Rectangle {
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
width: parent.width
|
||||
height: parent.radius
|
||||
color: parent.color
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: Theme.palette.baseColor2
|
||||
}
|
||||
|
||||
StatusBaseText {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: Style.current.bigPadding
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: WalletUtils.colorizedChainPrefix(d.preferredChainShortNames) + root.selectedAccount.address
|
||||
font.pixelSize: 15
|
||||
color: Theme.palette.directColor1
|
||||
}
|
||||
|
||||
StatusRoundButton {
|
||||
width: 32
|
||||
height: 32
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Style.current.bigPadding
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
icon.name: "copy"
|
||||
type: StatusRoundButton.Type.Tertiary
|
||||
onClicked: RootStore.copyToClipboard(d.visibleAddress)
|
||||
}
|
||||
}
|
||||
|
||||
onOpened: {
|
||||
RootStore.addressWasShown(root.address)
|
||||
RootStore.addressWasShown(root.selectedAccount.address)
|
||||
}
|
||||
|
||||
headerSettings.title: qsTr("Receive")
|
||||
contentHeight: layout.implicitHeight
|
||||
width: 556
|
||||
QtObject {
|
||||
id: d
|
||||
|
||||
showHeader: false
|
||||
showAdvancedHeader: true
|
||||
readonly property bool multiChainView: tabBar.currentIndex === 1
|
||||
readonly property int advanceFooterHeight: 88
|
||||
|
||||
property var preferredChainIdsArray: root.selectedAccount.preferredSharingChainIds.split(":").filter(Boolean)
|
||||
property var preferredChainIds: d.preferredChainIdsArray.join(":")
|
||||
|
||||
readonly property string preferredChainShortNames: d.multiChainView? RootStore.getNetworkShortNames(d.preferredChainIds) : ""
|
||||
readonly property string visibleAddress: "%1%2".arg(d.preferredChainShortNames).arg(root.selectedAccount.address)
|
||||
|
||||
readonly property var networkProxies: [layer1NetworksClone, layer2NetworksClone]
|
||||
|
||||
hasFloatingButtons: true
|
||||
advancedHeaderComponent: AccountsModalHeader {
|
||||
model: SortFilterProxyModel {
|
||||
sourceModel: RootStore.receiveAccounts
|
||||
|
||||
sorters: RoleSorter { roleName: "position"; sortOrder: Qt.AscendingOrder }
|
||||
}
|
||||
selectedAccount: RootStore.selectedReceiveAccount
|
||||
getNetworkShortNames: RootStore.getNetworkShortNames
|
||||
onSelectedIndexChanged: RootStore.switchReceiveAccount(selectedIndex)
|
||||
}
|
||||
|
||||
contentItem: Column {
|
||||
id: layout
|
||||
width: root.width
|
||||
Column {
|
||||
id: content
|
||||
width: parent.width
|
||||
height: childrenRect.height
|
||||
|
||||
topPadding: Style.current.xlPadding
|
||||
bottomPadding: Style.current.xlPadding
|
||||
spacing: Style.current.bigPadding
|
||||
|
||||
StatusSwitchTabBar {
|
||||
id: tabBar
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
currentIndex: 1
|
||||
|
||||
StatusSwitchTabButton {
|
||||
text: qsTr("Legacy")
|
||||
}
|
||||
|
@ -83,276 +147,168 @@ StatusModal {
|
|||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: qrCode
|
||||
height: 320
|
||||
width: 320
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
layer.enabled: true
|
||||
layer.effect: OpacityMask {
|
||||
maskSource: Item {
|
||||
width: qrCode.width
|
||||
height: qrCode.height
|
||||
Rectangle {
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
width: qrCode.width
|
||||
height: qrCode.height
|
||||
radius: Style.current.bigPadding
|
||||
border.width: 1
|
||||
border.color: Style.current.border
|
||||
}
|
||||
Rectangle {
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
width: Style.current.bigPadding
|
||||
height: Style.current.bigPadding
|
||||
}
|
||||
Rectangle {
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
width: Style.current.bigPadding
|
||||
height: Style.current.bigPadding
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
id: qrCodeImage
|
||||
anchors.centerIn: parent
|
||||
height: parent.height
|
||||
width: parent.width
|
||||
asynchronous: true
|
||||
fillMode: Image.PreserveAspectFit
|
||||
mipmap: true
|
||||
smooth: false
|
||||
source: RootStore.getQrCode(d.visibleAddress)
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.centerIn: qrCodeImage
|
||||
width: 78
|
||||
height: 78
|
||||
color: "white"
|
||||
StatusSmartIdenticon {
|
||||
anchors.centerIn: parent
|
||||
anchors.margins: 2
|
||||
width: 78
|
||||
height: 78
|
||||
name: root.selectedAccount.name
|
||||
asset {
|
||||
width: 78
|
||||
height: 78
|
||||
name: !root.selectedAccount.name && !root.selectedAccount.emoji? "status-logo-icon" : ""
|
||||
color: !root.selectedAccount.name && !root.selectedAccount.emoji? "transparent" : Utils.getColorForId(root.selectedAccount.colorId)
|
||||
emoji: root.selectedAccount.emoji
|
||||
charactersLen: {
|
||||
let parts = root.selectedAccount.name.split(" ")
|
||||
if (parts.length > 1) {
|
||||
return 2
|
||||
}
|
||||
return 1
|
||||
}
|
||||
isLetterIdenticon: root.selectedAccount.name && !root.selectedAccount.emoji
|
||||
useAcronymForLetterIdenticon: root.selectedAccount.name && !root.selectedAccount.emoji
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Item {
|
||||
width: parent.width
|
||||
height: qrCodeBox.height
|
||||
id: centralLayout
|
||||
height: Math.max(flow.height, editButton.height)
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
visible: d.multiChainView && d.preferredChainIdsArray.length > 0
|
||||
|
||||
Grid {
|
||||
id: multiChainList
|
||||
property bool need2Columns: RootStore.enabledNetworks.count >= 9
|
||||
|
||||
anchors.left: need2Columns ? undefined: qrCodeBox.right
|
||||
anchors.leftMargin: need2Columns ?undefined : Style.current.halfPadding
|
||||
anchors.centerIn: need2Columns ? parent : undefined
|
||||
height: qrCodeBox.height
|
||||
|
||||
columnSpacing: need2Columns ? qrCodeBox.width + Style.current.bigPadding : 0
|
||||
flow: Grid.TopToBottom
|
||||
columns: need2Columns ? 2 : 1
|
||||
Flow {
|
||||
id: flow
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
spacing: 5
|
||||
property var networkProxies: [layer1NetworksClone, layer2NetworksClone]
|
||||
|
||||
Repeater {
|
||||
model: multiChainList.networkProxies.length
|
||||
model: d.networkProxies.length
|
||||
delegate: Repeater {
|
||||
model: multiChainList.networkProxies[index]
|
||||
model: d.networkProxies[index]
|
||||
delegate: InformationTag {
|
||||
tagPrimaryLabel.text: model.shortName
|
||||
tagPrimaryLabel.color: model.chainColor
|
||||
image.source: Style.svg("tiny/" + model.iconUrl)
|
||||
visible: root.preferredSharingNetworksArray.includes(model.chainId.toString())
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: root.readOnly ? Qt.ArrowCursor : Qt.PointingHandCursor
|
||||
enabled: !root.readOnly
|
||||
onClicked: selectPopup.open()
|
||||
}
|
||||
visible: d.preferredChainIdsArray.includes(model.chainId.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
StatusRoundButton {
|
||||
id: editButton
|
||||
width: 32
|
||||
height: 32
|
||||
icon.name: "edit_pencil"
|
||||
color: Theme.palette.primaryColor3
|
||||
visible: !root.readOnly
|
||||
onClicked: selectPopup.open()
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: qrCodeBox
|
||||
height: 339
|
||||
width: 339
|
||||
anchors.centerIn: parent
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
layer.enabled: true
|
||||
layer.effect: OpacityMask {
|
||||
maskSource: Item {
|
||||
width: qrCodeBox.width
|
||||
height: qrCodeBox.height
|
||||
Rectangle {
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
width: qrCodeBox.width
|
||||
height: qrCodeBox.height
|
||||
radius: Style.current.bigPadding
|
||||
border.width: 1
|
||||
border.color: Style.current.border
|
||||
}
|
||||
Rectangle {
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
width: Style.current.bigPadding
|
||||
height: Style.current.bigPadding
|
||||
}
|
||||
Rectangle {
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
width: Style.current.bigPadding
|
||||
height: Style.current.bigPadding
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
id: qrCodeImage
|
||||
anchors.centerIn: parent
|
||||
height: parent.height
|
||||
width: parent.width
|
||||
asynchronous: true
|
||||
fillMode: Image.PreserveAspectFit
|
||||
mipmap: true
|
||||
smooth: false
|
||||
source: RootStore.getQrCode(d.completeAddressWithNetworkPrefix)
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.centerIn: qrCodeImage
|
||||
width: 78
|
||||
height: 78
|
||||
color: "white"
|
||||
StatusIcon {
|
||||
anchors.centerIn: parent
|
||||
anchors.margins: 2
|
||||
width: 78
|
||||
height: 78
|
||||
icon: "status-logo-icon"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: parent.width
|
||||
height: addressLabel.height + copyButton.height
|
||||
Column {
|
||||
id: addressLabel
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: Style.current.bigPadding
|
||||
StatusBaseText {
|
||||
id: contactsLabel
|
||||
font.pixelSize: 15
|
||||
color: Theme.palette.baseColor1
|
||||
text: root.description
|
||||
}
|
||||
RowLayout {
|
||||
id: networksLabel
|
||||
spacing: -1
|
||||
Repeater {
|
||||
model: multiChainList.networkProxies.length
|
||||
delegate: Repeater {
|
||||
model: multiChainList.networkProxies[index]
|
||||
delegate: StatusBaseText {
|
||||
font.pixelSize: 15
|
||||
color: chainColor
|
||||
text: shortName + ":"
|
||||
visible: root.preferredSharingNetworksArray.includes(model.chainId.toString())
|
||||
onVisibleChanged: {
|
||||
if (root.readOnly)
|
||||
return
|
||||
if (visible) {
|
||||
root.chainShortNames += text
|
||||
} else {
|
||||
root.chainShortNames = root.chainShortNames.replace(text, "")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
StatusAddress {
|
||||
id: txtWalletAddress
|
||||
color: Theme.palette.directColor1
|
||||
font.pixelSize: 15
|
||||
text: root.address
|
||||
}
|
||||
}
|
||||
Column {
|
||||
id: copyButton
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
StatusRoundButton {
|
||||
id: editButton
|
||||
width: 32
|
||||
height: 32
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Style.current.bigPadding
|
||||
spacing: 5
|
||||
CopyToClipBoardButton {
|
||||
id: copyToClipBoard
|
||||
textToCopy: txtWalletAddress.text
|
||||
onCopyClicked: RootStore.copyToClipboard(textToCopy)
|
||||
}
|
||||
StatusBaseText {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
font.pixelSize: 13
|
||||
color: Theme.palette.primaryColor1
|
||||
text: qsTr("Copy")
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
icon.name: "edit_pencil"
|
||||
type: StatusRoundButton.Type.Tertiary
|
||||
visible: root.changingPreferredChainsEnabled
|
||||
highlighted: selectPopup.visible
|
||||
onClicked: selectPopup.open()
|
||||
|
||||
NetworkSelectPopup {
|
||||
id: selectPopup
|
||||
|
||||
x: editButton.width - width
|
||||
y: editButton.height + 8
|
||||
|
||||
layer1Networks: layer1NetworksClone
|
||||
layer2Networks: layer2NetworksClone
|
||||
preferredNetworksMode: true
|
||||
preferredSharingNetworks: d.preferredChainIdsArray
|
||||
|
||||
useEnabledRole: false
|
||||
|
||||
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
||||
|
||||
onToggleNetwork: (network, networkModel, index) => {
|
||||
d.preferredChainIdsArray = RootStore.processPreferredSharingNetworkToggle(d.preferredChainIdsArray, network)
|
||||
}
|
||||
|
||||
onClosed: {
|
||||
root.updatePreferredChains(root.selectedAccount.address, d.preferredChainIds)
|
||||
}
|
||||
|
||||
CloneModel {
|
||||
id: layer1NetworksClone
|
||||
|
||||
sourceModel: RootStore.layer1Networks
|
||||
roles: ["layer", "chainId", "chainColor", "chainName","shortName", "iconUrl", "isEnabled"]
|
||||
// rowData used to clone returns string. Convert it to bool for bool arithmetics
|
||||
rolesOverride: [{
|
||||
role: "isEnabled",
|
||||
transform: (modelData) => root.readOnly ? root.chainShortNames.includes(modelData.shortName) : Boolean(modelData.isEnabled)
|
||||
}]
|
||||
}
|
||||
|
||||
CloneModel {
|
||||
id: layer2NetworksClone
|
||||
|
||||
sourceModel: RootStore.layer2Networks
|
||||
roles: layer1NetworksClone.roles
|
||||
rolesOverride: layer1NetworksClone.rolesOverride
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NetworkSelectPopup {
|
||||
id: selectPopup
|
||||
|
||||
x: multiChainList.x + editButton.width + 9
|
||||
y: tabBar.y + tabBar.height
|
||||
|
||||
layer1Networks: layer1NetworksClone
|
||||
layer2Networks: layer2NetworksClone
|
||||
preferredNetworksMode: true
|
||||
preferredSharingNetworks: root.preferredSharingNetworksArray
|
||||
|
||||
useEnabledRole: false
|
||||
|
||||
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
||||
|
||||
onToggleNetwork: (network, networkModel, index) => {
|
||||
root.preferredSharingNetworksArray = RootStore.processPreferredSharingNetworkToggle(root.preferredSharingNetworksArray, network)
|
||||
}
|
||||
|
||||
onClosed: RootStore.updateWalletAccountPreferredChains(root.address, root.preferredSharingNetworksArray.join(":"))
|
||||
|
||||
CloneModel {
|
||||
id: layer1NetworksClone
|
||||
|
||||
sourceModel: RootStore.layer1Networks
|
||||
roles: ["layer", "chainId", "chainColor", "chainName","shortName", "iconUrl", "isEnabled"]
|
||||
// rowData used to clone returns string. Convert it to bool for bool arithmetics
|
||||
rolesOverride: [{
|
||||
role: "isEnabled",
|
||||
transform: (modelData) => root.readOnly ? root.chainShortNames.includes(modelData.shortName) : Boolean(modelData.isEnabled)
|
||||
}]
|
||||
}
|
||||
|
||||
CloneModel {
|
||||
id: layer2NetworksClone
|
||||
|
||||
sourceModel: RootStore.layer2Networks
|
||||
roles: layer1NetworksClone.roles
|
||||
rolesOverride: layer1NetworksClone.rolesOverride
|
||||
}
|
||||
}
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "legacy"
|
||||
when: tabBar.currentIndex === 0
|
||||
PropertyChanges {
|
||||
target: multiChainList
|
||||
visible: false
|
||||
}
|
||||
PropertyChanges {
|
||||
target: contactsLabel
|
||||
visible: true
|
||||
}
|
||||
PropertyChanges {
|
||||
target: networksLabel
|
||||
visible: false
|
||||
}
|
||||
PropertyChanges {
|
||||
target: copyToClipBoard
|
||||
textToCopy: txtWalletAddress.text
|
||||
}
|
||||
PropertyChanges {
|
||||
target: d
|
||||
completeAddressWithNetworkPrefix: root.address
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "multichain"
|
||||
when: tabBar.currentIndex === 1
|
||||
PropertyChanges {
|
||||
target: multiChainList
|
||||
visible: true
|
||||
}
|
||||
PropertyChanges {
|
||||
target: contactsLabel
|
||||
visible: false
|
||||
}
|
||||
PropertyChanges {
|
||||
target: networksLabel
|
||||
visible: true
|
||||
}
|
||||
PropertyChanges {
|
||||
target: copyToClipBoard
|
||||
textToCopy: root.chainShortNames + txtWalletAddress.text
|
||||
}
|
||||
PropertyChanges {
|
||||
target: d
|
||||
completeAddressWithNetworkPrefix: root.chainShortNames + root.address
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -292,11 +292,15 @@ StatusMenu {
|
|||
}
|
||||
icon.name: "qr"
|
||||
onTriggered: {
|
||||
Global.openPopup(addressQr,
|
||||
{
|
||||
address: d.selectedAddress,
|
||||
chainShortNames: d.addressChains
|
||||
})
|
||||
onTriggered: Global.openShowQRPopup({
|
||||
showSingleAccount: true,
|
||||
switchingAccounsEnabled: false,
|
||||
changingPreferredChainsEnabled: false,
|
||||
hasFloatingButtons: false,
|
||||
name: d.addressName,
|
||||
address: d.selectedAddress,
|
||||
colorId: d.colorId,
|
||||
})
|
||||
}
|
||||
}
|
||||
StatusAction {
|
||||
|
@ -352,15 +356,4 @@ StatusMenu {
|
|||
icon.name: "send"
|
||||
onTriggered: root.openSendModal(d.selectedAddress)
|
||||
}
|
||||
|
||||
Component {
|
||||
id: addressQr
|
||||
ReceiveModal {
|
||||
anchors.centerIn: parent
|
||||
readOnly: true
|
||||
hasFloatingButtons: false
|
||||
advancedHeaderComponent: Item {}
|
||||
description: qsTr("Address")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -352,6 +352,10 @@ QtObject {
|
|||
walletSectionSavedAddresses.createOrUpdateSavedAddress(name, address, ens, colorId, chainShortNames)
|
||||
}
|
||||
|
||||
function updatePreferredChains(address, chainShortNames) {
|
||||
walletSectionSavedAddresses.updatePreferredChains(address, chainShortNames)
|
||||
}
|
||||
|
||||
function deleteSavedAddress(address) {
|
||||
root.deletingSavedAddress = true
|
||||
walletSectionSavedAddresses.deleteSavedAddress(address)
|
||||
|
@ -397,6 +401,10 @@ QtObject {
|
|||
return networksModule.getNetworkShortNames(chainIds)
|
||||
}
|
||||
|
||||
function getNetworkIds(shortNames) {
|
||||
return networksModule.getNetworkIds(shortNames)
|
||||
}
|
||||
|
||||
function updateWalletAccountPreferredChains(address, preferredChainIds) {
|
||||
if(areTestNetworksEnabled) {
|
||||
walletSectionAccounts.updateWalletAccountTestPreferredChains(address, preferredChainIds)
|
||||
|
|
|
@ -356,6 +356,10 @@ Item {
|
|||
function onOpenDeleteSavedAddressesPopup(params) {
|
||||
deleteSavedAddress.open(params)
|
||||
}
|
||||
|
||||
function onOpenShowQRPopup(params) {
|
||||
showQR.open(params)
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
|
@ -1817,6 +1821,88 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: showQR
|
||||
|
||||
active: false
|
||||
|
||||
property bool showSingleAccount: false
|
||||
property bool showForSavedAddress: false
|
||||
property var params
|
||||
property var selectedAccount: ({
|
||||
name: "",
|
||||
address: "",
|
||||
preferredSharingChainIds: "",
|
||||
colorId: "",
|
||||
emoji: ""
|
||||
})
|
||||
|
||||
function open(params = {}) {
|
||||
showQR.showSingleAccount = params.showSingleAccount?? false
|
||||
showQR.showForSavedAddress = params.showForSavedAddress?? false
|
||||
showQR.params = params
|
||||
|
||||
if (showQR.showSingleAccount || showQR.showForSavedAddress) {
|
||||
showQR.selectedAccount.name = params.name?? ""
|
||||
showQR.selectedAccount.address = params.address?? ""
|
||||
showQR.selectedAccount.preferredSharingChainIds = params.preferredSharingChainIds?? ""
|
||||
showQR.selectedAccount.colorId = params.colorId?? ""
|
||||
showQR.selectedAccount.emoji = params.emoji?? ""
|
||||
}
|
||||
|
||||
showQR.active = true
|
||||
}
|
||||
|
||||
function close() {
|
||||
showQR.active = false
|
||||
}
|
||||
|
||||
onLoaded: {
|
||||
showQR.item.switchingAccounsEnabled = showQR.params.switchingAccounsEnabled?? true
|
||||
showQR.item.changingPreferredChainsEnabled = showQR.params.changingPreferredChainsEnabled?? true
|
||||
showQR.item.hasFloatingButtons = showQR.params.hasFloatingButtons?? true
|
||||
|
||||
showQR.item.open()
|
||||
}
|
||||
|
||||
sourceComponent: WalletPopups.ReceiveModal {
|
||||
|
||||
accounts: {
|
||||
if (showQR.showSingleAccount || showQR.showForSavedAddress) {
|
||||
return null
|
||||
}
|
||||
return WalletStore.RootStore.receiveAccounts
|
||||
}
|
||||
|
||||
selectedAccount: {
|
||||
if (showQR.showSingleAccount || showQR.showForSavedAddress) {
|
||||
return showQR.selectedAccount
|
||||
}
|
||||
return WalletStore.RootStore.selectedReceiveAccount
|
||||
}
|
||||
|
||||
onSelectedAccountIndexChanged: {
|
||||
if (showQR.showSingleAccount || showQR.showForSavedAddress) {
|
||||
return
|
||||
}
|
||||
WalletStore.RootStore.switchReceiveAccount(selectedIndex)
|
||||
}
|
||||
|
||||
onUpdatePreferredChains: {
|
||||
if (showQR.showForSavedAddress) {
|
||||
let shortNames = WalletStore.RootStore.getNetworkShortNames(preferredChains)
|
||||
WalletStore.RootStore.updatePreferredChains(address, shortNames)
|
||||
return
|
||||
}
|
||||
WalletStore.RootStore.updateWalletAccountPreferredChains(address, preferredChains)
|
||||
}
|
||||
|
||||
onClosed: {
|
||||
showQR.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DropAreaPanel {
|
||||
id: rootDropAreaPanel
|
||||
|
||||
|
|
|
@ -43,11 +43,17 @@ StatusComboBox {
|
|||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: childrenRect.width
|
||||
spacing: 8
|
||||
component Padding: Item {
|
||||
width: 12
|
||||
height: 16
|
||||
}
|
||||
Padding {}
|
||||
StatusEmoji {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 16
|
||||
height: 16
|
||||
emojiId: StatusQUtils.Emoji.iconId(selectedAccount.emoji ?? "", StatusQUtils.Emoji.size.verySmall) || ""
|
||||
visible: !!emojiId
|
||||
}
|
||||
StatusBaseText {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
@ -59,9 +65,11 @@ StatusComboBox {
|
|||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 16
|
||||
height: width
|
||||
visible: !!root.model && root.model.count > 1
|
||||
icon: "chevron-down"
|
||||
color: Theme.palette.indirectColor1
|
||||
}
|
||||
Padding {}
|
||||
}
|
||||
|
||||
delegate: WalletAccountListItem {
|
||||
|
|
|
@ -86,6 +86,7 @@ QtObject {
|
|||
|
||||
signal openAddEditSavedAddressesPopup(var params)
|
||||
signal openDeleteSavedAddressesPopup(var params)
|
||||
signal openShowQRPopup(var params)
|
||||
|
||||
function openProfilePopup(publicKey, parentPopup, cb) {
|
||||
root.openProfilePopupRequested(publicKey, parentPopup, cb)
|
||||
|
|
Loading…
Reference in New Issue