2024-10-15 21:26:12 +02:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
import QtQuick.Controls 2.15
|
2021-09-28 18:04:06 +03:00
|
|
|
|
2024-08-27 16:35:52 +02:00
|
|
|
import StatusQ 0.1
|
2021-10-06 11:16:39 +02:00
|
|
|
import StatusQ.Core 0.1
|
2021-11-01 10:42:00 +01:00
|
|
|
import StatusQ.Core.Theme 0.1
|
2021-10-21 17:07:13 +02:00
|
|
|
import StatusQ.Controls 0.1 as StatusQControls
|
2021-10-06 11:16:39 +02:00
|
|
|
import StatusQ.Components 0.1
|
|
|
|
|
2021-09-28 18:04:06 +03:00
|
|
|
import utils 1.0
|
2021-10-28 00:27:49 +03:00
|
|
|
import shared.status 1.0
|
2022-10-17 12:17:25 +02:00
|
|
|
import shared.popups 1.0
|
2023-09-05 17:27:30 +02:00
|
|
|
import shared.popups.send 1.0
|
2023-11-28 20:16:18 +01:00
|
|
|
import shared.stores.send 1.0
|
2020-08-06 15:45:57 -04:00
|
|
|
|
2024-05-22 11:13:39 +03:00
|
|
|
import AppLayouts.Profile.stores 1.0
|
|
|
|
|
2020-08-06 15:45:57 -04:00
|
|
|
Item {
|
2021-10-06 11:16:39 +02:00
|
|
|
id: root
|
2024-05-22 11:13:39 +03:00
|
|
|
property EnsUsernamesStore ensUsernamesStore
|
2020-08-06 15:45:57 -04:00
|
|
|
property string username: ""
|
2023-01-11 19:10:13 +03:00
|
|
|
property string chainId: ""
|
2020-08-06 15:45:57 -04:00
|
|
|
|
2024-10-03 15:14:27 +02:00
|
|
|
signal backBtnClicked()
|
2024-10-29 10:55:46 +01:00
|
|
|
signal releaseUsernameRequested(string senderAddress)
|
2020-08-07 12:27:41 -04:00
|
|
|
|
2022-12-07 00:12:09 +03:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
2023-02-13 13:49:28 +01:00
|
|
|
property double expirationTimestamp: 0
|
2024-10-29 10:55:46 +01:00
|
|
|
property string walletAddress: "-"
|
|
|
|
property string key: "-"
|
2022-12-07 00:12:09 +03:00
|
|
|
}
|
|
|
|
|
2021-10-06 11:16:39 +02:00
|
|
|
StatusBaseText {
|
2020-08-06 15:45:57 -04:00
|
|
|
id: sectionTitle
|
|
|
|
text: username
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 24
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 24
|
|
|
|
font.weight: Font.Bold
|
|
|
|
font.pixelSize: 20
|
2021-11-01 10:42:00 +01:00
|
|
|
color: Theme.palette.directColor1
|
2020-08-06 15:45:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: loadingImageComponent
|
2021-04-26 12:25:01 +02:00
|
|
|
StatusLoadingIndicator {}
|
2020-08-06 15:45:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: loadingImg
|
|
|
|
active: false
|
|
|
|
sourceComponent: loadingImageComponent
|
|
|
|
anchors.right: parent.right
|
2024-10-15 21:26:12 +02:00
|
|
|
anchors.rightMargin: Theme.padding
|
2020-08-06 15:45:57 -04:00
|
|
|
anchors.top: parent.top
|
2024-10-15 21:26:12 +02:00
|
|
|
anchors.topMargin: Theme.padding
|
2020-08-06 15:45:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
2022-01-17 09:56:44 +01:00
|
|
|
target: root.ensUsernamesStore.ensUsernamesModule
|
2024-10-03 15:09:59 +02:00
|
|
|
function onDetailsObtained(chainId: int, ensName: string, address: string, pubkey: string, isStatus: bool, expirationTime: int) {
|
2022-07-18 04:34:11 -04:00
|
|
|
if(username != (isStatus ? ensName + ".stateofus.eth" : ensName))
|
2022-01-17 09:56:44 +01:00
|
|
|
return;
|
2024-10-29 10:55:46 +01:00
|
|
|
d.walletAddress = address
|
2022-01-17 09:56:44 +01:00
|
|
|
walletAddressLbl.subTitle = address;
|
2024-10-29 10:55:46 +01:00
|
|
|
walletAddressLbl.visible = !!address;
|
|
|
|
|
|
|
|
d.key = pubkey
|
2022-01-17 09:56:44 +01:00
|
|
|
keyLbl.subTitle = pubkey.substring(0, 20) + "..." + pubkey.substring(pubkey.length - 20);
|
2024-10-29 10:55:46 +01:00
|
|
|
keyLbl.visible = !!pubkey;
|
|
|
|
|
2022-01-17 09:56:44 +01:00
|
|
|
releaseBtn.visible = isStatus
|
2022-12-07 00:12:09 +03:00
|
|
|
removeButton.visible = true
|
|
|
|
releaseBtn.enabled = expirationTime > 0
|
|
|
|
&& (Date.now() / 1000) > expirationTime
|
|
|
|
&& root.ensUsernamesStore.preferredUsername !== username
|
|
|
|
d.expirationTimestamp = expirationTime * 1000
|
2020-08-06 15:45:57 -04:00
|
|
|
}
|
2023-01-18 11:25:36 +02:00
|
|
|
function onLoading(isLoading: bool) {
|
2020-08-06 15:45:57 -04:00
|
|
|
loadingImg.active = isLoading
|
2022-12-07 00:12:09 +03:00
|
|
|
if (!isLoading)
|
|
|
|
return;
|
2020-08-06 15:45:57 -04:00
|
|
|
walletAddressLbl.visible = false;
|
|
|
|
keyLbl.visible = false;
|
2021-08-09 18:23:52 -04:00
|
|
|
releaseBtn.visible = false;
|
2022-12-07 00:12:09 +03:00
|
|
|
removeButton.visible = false;
|
|
|
|
d.expirationTimestamp = 0;
|
2020-08-06 15:45:57 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-06 11:16:39 +02:00
|
|
|
StatusDescriptionListItem {
|
2020-08-06 15:45:57 -04:00
|
|
|
id: walletAddressLbl
|
2021-10-06 11:16:39 +02:00
|
|
|
title: qsTr("Wallet address")
|
2020-08-06 15:45:57 -04:00
|
|
|
visible: false
|
|
|
|
anchors.top: sectionTitle.bottom
|
|
|
|
anchors.topMargin: 24
|
2022-08-11 14:55:08 +03:00
|
|
|
asset.name: "copy"
|
2021-10-06 11:16:39 +02:00
|
|
|
tooltip.text: qsTr("Copied to clipboard!")
|
|
|
|
iconButton.onClicked: {
|
2024-08-27 16:35:52 +02:00
|
|
|
ClipboardUtils.setText(subTitle)
|
2021-10-06 11:16:39 +02:00
|
|
|
tooltip.visible = !tooltip.visible
|
|
|
|
}
|
2020-08-06 15:45:57 -04:00
|
|
|
}
|
2021-10-06 11:16:39 +02:00
|
|
|
StatusDescriptionListItem {
|
2020-08-06 15:45:57 -04:00
|
|
|
id: keyLbl
|
2021-10-06 11:16:39 +02:00
|
|
|
title: qsTr("Key")
|
2020-08-06 15:45:57 -04:00
|
|
|
visible: false
|
|
|
|
anchors.top: walletAddressLbl.bottom
|
|
|
|
anchors.topMargin: 24
|
2022-08-11 14:55:08 +03:00
|
|
|
asset.name: "copy"
|
2021-10-06 11:16:39 +02:00
|
|
|
tooltip.text: qsTr("Copied to clipboard!")
|
|
|
|
iconButton.onClicked: {
|
2024-08-27 16:35:52 +02:00
|
|
|
ClipboardUtils.setText(subTitle)
|
2021-10-06 11:16:39 +02:00
|
|
|
tooltip.visible = !tooltip.visible
|
|
|
|
}
|
2020-08-06 15:45:57 -04:00
|
|
|
}
|
|
|
|
|
2022-12-07 00:12:09 +03:00
|
|
|
RowLayout {
|
|
|
|
id: actionsLayout
|
|
|
|
|
2021-08-09 18:23:52 -04:00
|
|
|
anchors.top: keyLbl.bottom
|
|
|
|
anchors.topMargin: 24
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 24
|
2022-12-07 00:12:09 +03:00
|
|
|
|
|
|
|
StatusQControls.StatusButton {
|
|
|
|
id: removeButton
|
|
|
|
visible: false
|
|
|
|
type: StatusQControls.StatusBaseButton.Type.Danger
|
|
|
|
text: qsTr("Remove username")
|
|
|
|
onClicked: {
|
2023-01-11 19:10:13 +03:00
|
|
|
root.ensUsernamesStore.removeEnsUsername(root.chainId, root.username)
|
2022-12-07 00:12:09 +03:00
|
|
|
root.backBtnClicked()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusQControls.StatusButton {
|
|
|
|
id: releaseBtn
|
|
|
|
visible: false
|
|
|
|
enabled: false
|
|
|
|
text: qsTr("Release username")
|
|
|
|
onClicked: {
|
2024-10-29 10:55:46 +01:00
|
|
|
root.releaseUsernameRequested(d.walletAddress)
|
2022-12-07 00:12:09 +03:00
|
|
|
}
|
2021-08-09 18:23:52 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
visible: releaseBtn.visible && !releaseBtn.enabled
|
2022-12-07 00:12:09 +03:00
|
|
|
anchors.top: actionsLayout.bottom
|
2021-08-09 18:23:52 -04:00
|
|
|
anchors.topMargin: 2
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 24
|
2022-12-07 00:12:09 +03:00
|
|
|
text: {
|
2024-10-29 10:55:46 +01:00
|
|
|
if (d.expirationTimestamp === 0)
|
|
|
|
return ""
|
2023-01-12 23:39:46 +01:00
|
|
|
const formattedDate = LocaleUtils.formatDate(d.expirationTimestamp, Locale.ShortFormat)
|
2022-12-07 00:12:09 +03:00
|
|
|
return qsTr("Username locked. You won't be able to release it until %1").arg(formattedDate)
|
|
|
|
}
|
2024-10-15 21:26:12 +02:00
|
|
|
color: Theme.palette.darkGrey
|
2021-08-09 18:23:52 -04:00
|
|
|
}
|
|
|
|
|
2021-10-21 17:07:13 +02:00
|
|
|
StatusQControls.StatusButton {
|
2020-08-06 15:45:57 -04:00
|
|
|
anchors.bottom: parent.bottom
|
2024-10-15 21:26:12 +02:00
|
|
|
anchors.bottomMargin: Theme.padding
|
2020-08-06 15:45:57 -04:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2022-04-04 13:26:30 +02:00
|
|
|
text: qsTr("Back")
|
2020-08-07 12:27:41 -04:00
|
|
|
onClicked: backBtnClicked()
|
2020-08-06 15:45:57 -04:00
|
|
|
}
|
2020-09-14 14:12:47 +02:00
|
|
|
}
|