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
|
|
|
|
2024-06-07 12:27:56 +00:00
|
|
|
import StatusQ 0.1
|
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-06-07 12:27:56 +00:00
|
|
|
import AppLayouts.Wallet 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-03-13 17:38:16 +00:00
|
|
|
property string qrImageSource: store.getQrCode(d.visibleAddress)
|
2024-02-27 12:12:01 +00:00
|
|
|
property var getNetworkShortNames: function(chainIDsString) {
|
2024-03-13 17:38:16 +00:00
|
|
|
return store.getNetworkShortNames(chainIDsString)
|
2024-02-27 12:12:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
property var store: RootStore
|
|
|
|
|
2024-06-07 12:27:56 +00:00
|
|
|
signal updateSelectedAddress(string address)
|
2024-01-15 09:19:25 +00:00
|
|
|
signal updatePreferredChains(string address, string preferredChains)
|
2023-05-23 08:44:35 +00:00
|
|
|
|
2024-01-15 09:19:25 +00:00
|
|
|
onSelectedAccountChanged: {
|
2024-06-15 21:33:12 +00:00
|
|
|
d.preferredChainIdsArray = root.selectedAccount.preferredSharingChainIds.split(":").filter(Boolean).map(Number)
|
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
|
2024-06-07 12:27:56 +00:00
|
|
|
advancedHeaderComponent: Item {
|
|
|
|
implicitWidth: accountSelector.implicitWidth
|
|
|
|
implicitHeight: accountSelector.implicitHeight
|
|
|
|
AccountSelectorHeader {
|
|
|
|
id: accountSelector
|
|
|
|
control.enabled: root.switchingAccounsEnabled && model.count > 1
|
|
|
|
width: implicitWidth
|
|
|
|
model: SortFilterProxyModel {
|
|
|
|
sourceModel: root.accounts
|
|
|
|
|
|
|
|
sorters: RoleSorter { roleName: "position"; sortOrder: Qt.AscendingOrder }
|
|
|
|
proxyRoles: [
|
|
|
|
FastExpressionRole {
|
|
|
|
name: "colorizedChainPrefixes"
|
|
|
|
function getChainShortNames(chainIds) {
|
|
|
|
const chainShortNames = root.getNetworkShortNames(chainIds)
|
|
|
|
return WalletUtils.colorizedChainPrefix(chainShortNames)
|
|
|
|
}
|
|
|
|
expression: getChainShortNames(model.preferredSharingChainIds)
|
|
|
|
expectedRoles: ["preferredSharingChainIds"]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
selectedAddress: !!root.selectedAccount ? root.selectedAccount.address : ""
|
|
|
|
onCurrentAccountAddressChanged: {
|
|
|
|
root.updateSelectedAddress(currentAccountAddress)
|
|
|
|
}
|
2024-01-15 09:19:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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: {
|
2024-03-13 17:38:16 +00:00
|
|
|
store.addressWasShown(root.selectedAccount.address)
|
2024-01-15 09:19:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
readonly property bool multiChainView: tabBar.currentIndex === 1
|
|
|
|
readonly property int advanceFooterHeight: 88
|
|
|
|
|
2024-06-15 21:33:12 +00:00
|
|
|
property var preferredChainIdsArray: []
|
|
|
|
Binding on preferredChainIdsArray {
|
|
|
|
value: root.selectedAccount.preferredSharingChainIds.split(":").filter(Boolean).map(Number)
|
|
|
|
}
|
|
|
|
onPreferredChainIdsArrayChanged: {
|
|
|
|
if (preferredChainIdsArray !== selectPopup.selection) {
|
|
|
|
selectPopup.selection = preferredChainIdsArray
|
|
|
|
}
|
|
|
|
}
|
2024-01-15 09:19:25 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2024-05-17 14:34:25 +00:00
|
|
|
charactersLen: 1
|
2024-01-15 09:19:25 +00:00
|
|
|
isLetterIdenticon: root.selectedAccount.name && !root.selectedAccount.emoji
|
2024-05-17 17:45:27 +00:00
|
|
|
letterIdenticonBgWithAlpha: 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 {
|
2024-03-13 17:38:16 +00:00
|
|
|
model: root.store.filteredFlatModel
|
|
|
|
delegate: StatusNetworkListItemTag {
|
|
|
|
enabled: false
|
|
|
|
button.visible: false
|
|
|
|
title: model.shortName
|
2024-06-15 21:33:12 +00:00
|
|
|
asset.name: model.isTest ? Style.svg(model.iconUrl + "-test") : Style.svg(model.iconUrl)
|
|
|
|
visible: d.preferredChainIdsArray.includes(model.chainId)
|
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-03-13 17:38:16 +00:00
|
|
|
flatNetworks: root.store.filteredFlatModel
|
2024-06-15 21:33:12 +00:00
|
|
|
selection: d.preferredChainIdsArray
|
|
|
|
multiSelection: true
|
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-06-15 21:33:12 +00:00
|
|
|
onSelectionChanged: {
|
|
|
|
if (selection !== d.preferredChainIdsArray)
|
|
|
|
d.preferredChainIdsArray = selection
|
|
|
|
}
|
2023-07-21 08:41:24 +00:00
|
|
|
|
2024-01-15 09:19:25 +00:00
|
|
|
onClosed: {
|
|
|
|
root.updatePreferredChains(root.selectedAccount.address, d.preferredChainIds)
|
|
|
|
}
|
2022-05-18 21:58:07 +00:00
|
|
|
}
|
|
|
|
}
|
2024-01-15 09:19:25 +00:00
|
|
|
}
|
2020-08-14 19:19:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|