2020-08-14 19:19:08 +00:00
|
|
|
import QtQuick 2.13
|
2022-03-15 19:34:28 +00:00
|
|
|
import QtGraphicalEffects 1.13
|
2022-05-18 21:58:07 +00:00
|
|
|
import QtQuick.Layouts 1.13
|
2022-11-11 09:24:26 +00:00
|
|
|
import QtQuick.Controls 2.14
|
2023-06-28 09:16:30 +00:00
|
|
|
import SortFilterProxyModel 0.2
|
2021-09-28 15:04:06 +00:00
|
|
|
|
2022-03-15 19:34:28 +00:00
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2021-10-27 10:25:42 +00:00
|
|
|
import StatusQ.Controls 0.1
|
2022-03-15 19:34:28 +00:00
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
import StatusQ.Components 0.1
|
2022-05-18 21:58:07 +00:00
|
|
|
import StatusQ.Core.Utils 0.1
|
2021-10-27 10:25:42 +00:00
|
|
|
|
2021-09-28 15:04:06 +00:00
|
|
|
import utils 1.0
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.controls 1.0
|
2022-11-11 09:24:26 +00:00
|
|
|
import shared.popups 1.0
|
2023-09-05 15:27:30 +00:00
|
|
|
import shared.popups.send.controls 1.0
|
2022-03-15 19:34:28 +00:00
|
|
|
|
2023-04-05 11:10:44 +00:00
|
|
|
import AppLayouts.stores 1.0
|
2024-02-27 12:12:01 +00:00
|
|
|
import AppLayouts.Wallet.controls 1.0
|
|
|
|
|
2024-01-15 09:19:25 +00:00
|
|
|
import ".."
|
2021-10-05 20:50:22 +00:00
|
|
|
import "../stores"
|
2020-08-14 19:19:08 +00:00
|
|
|
|
2022-03-15 19:34:28 +00:00
|
|
|
StatusModal {
|
2022-11-12 09:18:18 +00:00
|
|
|
id: root
|
2020-08-14 19:19:08 +00:00
|
|
|
|
2024-01-15 09:19:25 +00:00
|
|
|
property var accounts
|
|
|
|
property var selectedAccount
|
2023-05-23 08:44:35 +00:00
|
|
|
|
2024-01-15 09:19:25 +00:00
|
|
|
property bool switchingAccounsEnabled: true
|
|
|
|
property bool changingPreferredChainsEnabled: true
|
2023-05-23 08:44:35 +00:00
|
|
|
|
2024-02-27 12:12:01 +00:00
|
|
|
property string qrImageSource: RootStore.getQrCode(d.visibleAddress)
|
|
|
|
property var getNetworkShortNames: function(chainIDsString) {
|
|
|
|
return RootStore.getNetworkShortNames(chainIDsString)
|
|
|
|
}
|
|
|
|
|
|
|
|
property var store: RootStore
|
|
|
|
|
2024-01-15 09:19:25 +00:00
|
|
|
signal selectedAccountIndexChanged(int selectedIndex)
|
|
|
|
signal updatePreferredChains(string address, string preferredChains)
|
2023-05-23 08:44:35 +00:00
|
|
|
|
2024-01-15 09:19:25 +00:00
|
|
|
onSelectedAccountChanged: {
|
|
|
|
d.preferredChainIdsArray = root.selectedAccount.preferredSharingChainIds.split(":").filter(Boolean)
|
2022-05-18 21:58:07 +00:00
|
|
|
}
|
2022-03-15 19:34:28 +00:00
|
|
|
|
|
|
|
width: 556
|
2024-01-15 09:19:25 +00:00
|
|
|
contentHeight: content.implicitHeight + d.advanceFooterHeight
|
2022-05-18 21:58:07 +00:00
|
|
|
|
|
|
|
hasFloatingButtons: true
|
2024-01-15 09:19:25 +00:00
|
|
|
|
|
|
|
showHeader: false
|
|
|
|
showAdvancedHeader: hasFloatingButtons
|
2022-11-11 09:24:26 +00:00
|
|
|
advancedHeaderComponent: AccountsModalHeader {
|
2024-01-15 09:19:25 +00:00
|
|
|
control.enabled: root.switchingAccounsEnabled && model.count > 1
|
2023-06-28 09:16:30 +00:00
|
|
|
model: SortFilterProxyModel {
|
2024-01-15 09:19:25 +00:00
|
|
|
sourceModel: root.accounts
|
2023-06-28 09:16:30 +00:00
|
|
|
|
|
|
|
sorters: RoleSorter { roleName: "position"; sortOrder: Qt.AscendingOrder }
|
|
|
|
}
|
2024-01-15 09:19:25 +00:00
|
|
|
|
|
|
|
selectedAccount: root.selectedAccount
|
2024-02-27 12:12:01 +00:00
|
|
|
getNetworkShortNames: root.getNetworkShortNames
|
2024-01-15 09:19:25 +00:00
|
|
|
onSelectedIndexChanged: {
|
|
|
|
root.selectedAccountIndexChanged(selectedIndex)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
showFooter: false
|
|
|
|
showAdvancedFooter: true
|
|
|
|
advancedFooterComponent: Rectangle {
|
|
|
|
width: parent.width
|
2024-02-27 12:12:01 +00:00
|
|
|
height: rowLayout.height + 56 // Makes it totally 88 for one liner text as per design
|
2024-01-15 09:19:25 +00:00
|
|
|
color: Theme.palette.baseColor4
|
2024-02-27 12:12:01 +00:00
|
|
|
radius: 8
|
2024-01-15 09:19:25 +00:00
|
|
|
|
2024-02-27 12:12:01 +00:00
|
|
|
// Hide round corners of the upper part
|
2024-01-15 09:19:25 +00:00
|
|
|
Rectangle {
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.top: parent.top
|
|
|
|
width: parent.width
|
|
|
|
height: parent.radius
|
|
|
|
color: parent.color
|
|
|
|
}
|
|
|
|
|
2024-02-27 12:12:01 +00:00
|
|
|
// Divider
|
2024-01-15 09:19:25 +00:00
|
|
|
Rectangle {
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.top: parent.top
|
|
|
|
width: parent.width
|
|
|
|
height: 1
|
|
|
|
color: Theme.palette.baseColor2
|
|
|
|
}
|
|
|
|
|
2024-02-27 12:12:01 +00:00
|
|
|
Item { // Needed to avoid binding loop warnings
|
|
|
|
anchors.centerIn: parent
|
|
|
|
height: childrenRect.height
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
id: rowLayout
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.leftMargin: Style.current.bigPadding
|
|
|
|
Layout.preferredWidth: parent.width - copyButton.width
|
|
|
|
Layout.fillWidth: true
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
textFormat: TextEdit.RichText
|
|
|
|
wrapMode: Text.WrapAnywhere
|
|
|
|
text: WalletUtils.colorizedChainPrefix(d.preferredChainShortNames) + root.selectedAccount.address
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
2024-01-15 09:19:25 +00:00
|
|
|
|
2024-02-27 12:12:01 +00:00
|
|
|
CopyButtonWithCircle {
|
|
|
|
id: copyButton
|
|
|
|
|
|
|
|
Layout.rightMargin: Style.current.bigPadding
|
|
|
|
Layout.preferredWidth: 32
|
|
|
|
Layout.preferredHeight: 32
|
|
|
|
Layout.fillWidth: true
|
|
|
|
textToCopy: d.visibleAddress
|
|
|
|
successCircleVisible: true
|
|
|
|
}
|
|
|
|
}
|
2024-01-15 09:19:25 +00:00
|
|
|
}
|
2022-05-18 21:58:07 +00:00
|
|
|
}
|
|
|
|
|
2024-01-15 09:19:25 +00:00
|
|
|
onOpened: {
|
|
|
|
RootStore.addressWasShown(root.selectedAccount.address)
|
|
|
|
}
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
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(":")
|
|
|
|
|
2024-02-27 12:12:01 +00:00
|
|
|
readonly property string preferredChainShortNames: d.multiChainView? root.getNetworkShortNames(d.preferredChainIds) : ""
|
2024-01-15 09:19:25 +00:00
|
|
|
readonly property string visibleAddress: "%1%2".arg(d.preferredChainShortNames).arg(root.selectedAccount.address)
|
|
|
|
|
|
|
|
readonly property var networkProxies: [layer1NetworksClone, layer2NetworksClone]
|
|
|
|
}
|
|
|
|
|
|
|
|
Column {
|
|
|
|
id: content
|
|
|
|
width: parent.width
|
|
|
|
height: childrenRect.height
|
2020-08-14 19:19:08 +00:00
|
|
|
|
2022-05-18 21:58:07 +00:00
|
|
|
topPadding: Style.current.xlPadding
|
2024-01-15 09:19:25 +00:00
|
|
|
bottomPadding: Style.current.xlPadding
|
2022-03-15 19:34:28 +00:00
|
|
|
spacing: Style.current.bigPadding
|
2020-08-14 19:19:08 +00:00
|
|
|
|
2022-05-18 21:58:07 +00:00
|
|
|
StatusSwitchTabBar {
|
|
|
|
id: tabBar
|
2020-08-14 19:19:08 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2023-06-13 10:56:16 +00:00
|
|
|
currentIndex: 1
|
2024-01-15 09:19:25 +00:00
|
|
|
|
2022-05-18 21:58:07 +00:00
|
|
|
StatusSwitchTabButton {
|
|
|
|
text: qsTr("Legacy")
|
|
|
|
}
|
|
|
|
StatusSwitchTabButton {
|
|
|
|
text: qsTr("Multichain")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
2024-01-15 09:19:25 +00:00
|
|
|
id: qrCode
|
|
|
|
height: 320
|
|
|
|
width: 320
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2022-05-18 21:58:07 +00:00
|
|
|
|
2024-01-15 09:19:25 +00:00
|
|
|
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
|
2022-03-15 19:34:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-15 09:19:25 +00:00
|
|
|
Image {
|
|
|
|
id: qrCodeImage
|
2022-03-15 19:34:28 +00:00
|
|
|
anchors.centerIn: parent
|
2024-01-15 09:19:25 +00:00
|
|
|
height: parent.height
|
|
|
|
width: parent.width
|
|
|
|
asynchronous: true
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
mipmap: true
|
|
|
|
smooth: false
|
2024-02-27 12:12:01 +00:00
|
|
|
source: root.qrImageSource
|
2024-01-15 09:19:25 +00:00
|
|
|
}
|
2022-03-15 19:34:28 +00:00
|
|
|
|
2024-01-15 09:19:25 +00:00
|
|
|
Rectangle {
|
|
|
|
anchors.centerIn: qrCodeImage
|
2024-02-27 12:12:01 +00:00
|
|
|
width: 88
|
|
|
|
height: 88
|
2024-01-15 09:19:25 +00:00
|
|
|
color: "white"
|
2024-02-27 12:12:01 +00:00
|
|
|
radius: width / 2
|
2024-01-15 09:19:25 +00:00
|
|
|
StatusSmartIdenticon {
|
2022-03-15 19:34:28 +00:00
|
|
|
anchors.centerIn: parent
|
2024-01-15 09:19:25 +00:00
|
|
|
name: root.selectedAccount.name
|
|
|
|
asset {
|
2024-02-27 12:12:01 +00:00
|
|
|
width: 72
|
|
|
|
height: 72
|
2024-01-15 09:19:25 +00:00
|
|
|
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
|
2022-05-18 21:58:07 +00:00
|
|
|
}
|
2022-03-15 19:34:28 +00:00
|
|
|
}
|
2020-08-20 04:45:29 +00:00
|
|
|
}
|
|
|
|
}
|
2020-08-14 19:19:08 +00:00
|
|
|
|
2024-01-15 09:19:25 +00:00
|
|
|
|
|
|
|
Item {
|
2022-03-15 19:34:28 +00:00
|
|
|
width: parent.width
|
2024-01-15 09:19:25 +00:00
|
|
|
height: Math.max(flow.height, editButton.height)
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2024-01-15 12:27:47 +00:00
|
|
|
visible: d.multiChainView && (d.preferredChainIdsArray.length > 0 || root.changingPreferredChainsEnabled)
|
2024-01-15 09:19:25 +00:00
|
|
|
|
|
|
|
Flow {
|
|
|
|
id: flow
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
spacing: 5
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
model: d.networkProxies.length
|
|
|
|
delegate: Repeater {
|
|
|
|
model: d.networkProxies[index]
|
2024-02-27 12:12:01 +00:00
|
|
|
delegate: StatusNetworkListItemTag {
|
|
|
|
enabled: false
|
|
|
|
button.visible: false
|
|
|
|
title: model.shortName
|
2024-02-20 09:04:39 +00:00
|
|
|
asset.name: Style.svg("tiny/" + model.iconUrl)
|
2024-01-15 09:19:25 +00:00
|
|
|
visible: d.preferredChainIdsArray.includes(model.chainId.toString())
|
2022-05-18 21:58:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-03-15 19:34:28 +00:00
|
|
|
}
|
2024-01-15 09:19:25 +00:00
|
|
|
|
|
|
|
StatusRoundButton {
|
|
|
|
id: editButton
|
|
|
|
width: 32
|
|
|
|
height: 32
|
2022-03-15 19:34:28 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.bigPadding
|
2024-01-15 09:19:25 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
icon.name: "edit_pencil"
|
|
|
|
type: StatusRoundButton.Type.Tertiary
|
|
|
|
visible: root.changingPreferredChainsEnabled
|
|
|
|
highlighted: selectPopup.visible
|
|
|
|
onClicked: selectPopup.open()
|
2022-05-18 21:58:07 +00:00
|
|
|
|
2024-01-15 09:19:25 +00:00
|
|
|
NetworkSelectPopup {
|
|
|
|
id: selectPopup
|
2022-11-12 09:18:18 +00:00
|
|
|
|
2024-01-15 09:19:25 +00:00
|
|
|
x: editButton.width - width
|
2024-02-27 12:12:01 +00:00
|
|
|
y: editButton.height + 2
|
|
|
|
|
|
|
|
margins: -1 // to allow positioning outside the bounds of the dialog
|
2022-11-12 09:18:18 +00:00
|
|
|
|
2024-01-15 09:19:25 +00:00
|
|
|
layer1Networks: layer1NetworksClone
|
|
|
|
layer2Networks: layer2NetworksClone
|
|
|
|
preferredNetworksMode: true
|
|
|
|
preferredSharingNetworks: d.preferredChainIdsArray
|
2023-07-21 08:41:24 +00:00
|
|
|
|
2024-01-15 09:19:25 +00:00
|
|
|
useEnabledRole: false
|
2022-05-18 21:58:07 +00:00
|
|
|
|
2024-01-15 09:19:25 +00:00
|
|
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
2023-04-05 11:10:44 +00:00
|
|
|
|
2024-01-15 09:19:25 +00:00
|
|
|
onToggleNetwork: (network, networkModel, index) => {
|
|
|
|
d.preferredChainIdsArray = RootStore.processPreferredSharingNetworkToggle(d.preferredChainIdsArray, network)
|
|
|
|
}
|
2023-07-21 08:41:24 +00:00
|
|
|
|
2024-01-15 09:19:25 +00:00
|
|
|
onClosed: {
|
|
|
|
root.updatePreferredChains(root.selectedAccount.address, d.preferredChainIds)
|
|
|
|
}
|
2023-04-05 11:10:44 +00:00
|
|
|
|
2024-01-15 09:19:25 +00:00
|
|
|
CloneModel {
|
|
|
|
id: layer1NetworksClone
|
2023-04-05 11:10:44 +00:00
|
|
|
|
2024-02-27 12:12:01 +00:00
|
|
|
sourceModel: root.store.layer1Networks
|
2024-01-15 09:19:25 +00:00
|
|
|
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)
|
|
|
|
}]
|
|
|
|
}
|
2023-04-05 11:10:44 +00:00
|
|
|
|
2024-01-15 09:19:25 +00:00
|
|
|
CloneModel {
|
|
|
|
id: layer2NetworksClone
|
2023-04-05 11:10:44 +00:00
|
|
|
|
2024-02-27 12:12:01 +00:00
|
|
|
sourceModel: root.store.layer2Networks
|
2024-01-15 09:19:25 +00:00
|
|
|
roles: layer1NetworksClone.roles
|
|
|
|
rolesOverride: layer1NetworksClone.rolesOverride
|
|
|
|
}
|
2022-05-18 21:58:07 +00:00
|
|
|
}
|
|
|
|
}
|
2024-01-15 09:19:25 +00:00
|
|
|
}
|
2020-08-14 19:19:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|