2020-07-21 21:03:22 +00:00
|
|
|
import QtQuick 2.13
|
2022-03-28 09:38:58 +00:00
|
|
|
import QtQuick.Controls 2.3
|
2020-07-21 21:03:22 +00:00
|
|
|
import QtQuick.Layouts 1.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared 1.0
|
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.popups 1.0
|
2024-01-13 03:24:57 +00:00
|
|
|
import shared.stores 1.0
|
2022-03-16 21:20:03 +00:00
|
|
|
import shared.controls.chat 1.0
|
2020-07-21 21:03:22 +00:00
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
import "../popups"
|
2021-12-30 12:39:47 +00:00
|
|
|
import "../stores"
|
2022-06-22 12:16:21 +00:00
|
|
|
import "../controls"
|
|
|
|
import "./profile"
|
2021-10-06 09:16:39 +00:00
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
2021-09-09 14:03:17 +00:00
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Components 0.1
|
2021-10-18 10:34:16 +00:00
|
|
|
import StatusQ.Controls 0.1
|
2021-09-09 14:03:17 +00:00
|
|
|
|
2024-02-04 11:50:26 +00:00
|
|
|
import AppLayouts.Profile.panels 1.0
|
2024-01-13 03:24:57 +00:00
|
|
|
import AppLayouts.Wallet.stores 1.0
|
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
SettingsContentBase {
|
2021-10-06 09:16:39 +00:00
|
|
|
id: root
|
|
|
|
|
2022-06-22 12:16:21 +00:00
|
|
|
property WalletStore walletStore
|
2021-12-30 12:39:47 +00:00
|
|
|
property ProfileStore profileStore
|
2022-06-22 12:16:21 +00:00
|
|
|
property PrivacyStore privacyStore
|
2022-09-27 21:26:26 +00:00
|
|
|
property ContactsStore contactsStore
|
2024-02-02 09:55:56 +00:00
|
|
|
property NetworkConnectionStore networkConnectionStore
|
2024-01-13 03:24:57 +00:00
|
|
|
required property WalletAssetsStore walletAssetsStore
|
|
|
|
required property CurrenciesStore currencyStore
|
|
|
|
|
2023-02-28 15:00:10 +00:00
|
|
|
property var communitiesModel
|
2022-06-22 12:16:21 +00:00
|
|
|
|
2024-02-07 09:54:45 +00:00
|
|
|
property bool sideBySidePreview
|
|
|
|
|
|
|
|
property QtObject dirtyValues: QtObject {
|
|
|
|
property string displayName: descriptionPanel.displayName.text
|
|
|
|
property string bio: descriptionPanel.bio.text
|
|
|
|
property url profileLargeImage: profileHeader.previewIcon
|
|
|
|
}
|
|
|
|
|
2024-02-23 09:22:50 +00:00
|
|
|
enum TabIndex {
|
|
|
|
Identity = 0,
|
|
|
|
Communities = 1,
|
|
|
|
Accounts = 2,
|
|
|
|
Collectibles = 3,
|
|
|
|
Assets = 4,
|
|
|
|
Web = 5
|
|
|
|
}
|
|
|
|
|
2024-02-07 09:54:45 +00:00
|
|
|
titleRowComponentLoader.sourceComponent: StatusButton {
|
|
|
|
text: qsTr("Preview")
|
|
|
|
onClicked: Global.openPopup(profilePreview)
|
|
|
|
visible: !root.sideBySidePreview
|
2022-06-22 12:16:21 +00:00
|
|
|
}
|
|
|
|
|
2024-02-04 11:50:26 +00:00
|
|
|
dirty: (!descriptionPanel.isEnsName &&
|
|
|
|
descriptionPanel.displayName.text !== profileStore.displayName) ||
|
2024-02-15 18:58:54 +00:00
|
|
|
descriptionPanel.bio.text !== profileStore.bio ||
|
|
|
|
profileStore.socialLinksDirty ||
|
|
|
|
profileHeader.icon !== profileStore.profileLargeImage ||
|
|
|
|
priv.hasAnyProfileShowcaseChanges
|
2024-02-04 11:50:26 +00:00
|
|
|
saveChangesButtonEnabled: !!descriptionPanel.displayName.text && descriptionPanel.displayName.valid
|
2022-06-22 12:16:21 +00:00
|
|
|
|
2024-02-12 16:39:06 +00:00
|
|
|
toast.saveChangesTooltipVisible: root.dirty
|
|
|
|
toast.saveChangesTooltipText: qsTr("Invalid changes made to Identity")
|
|
|
|
|
2024-02-04 11:50:26 +00:00
|
|
|
onResetChangesClicked: priv.reset()
|
|
|
|
|
|
|
|
onSaveChangesClicked: priv.save()
|
2020-07-21 21:03:22 +00:00
|
|
|
|
2022-10-20 13:41:18 +00:00
|
|
|
bottomHeaderComponents: StatusTabBar {
|
2024-02-04 11:50:26 +00:00
|
|
|
id: profileTabBar
|
|
|
|
|
2022-10-20 13:41:18 +00:00
|
|
|
StatusTabButton {
|
2024-02-09 04:05:14 +00:00
|
|
|
objectName: "identityTabButton"
|
2024-02-04 11:50:26 +00:00
|
|
|
width: implicitWidth
|
2023-09-22 09:58:02 +00:00
|
|
|
leftPadding: 0
|
2024-02-04 11:50:26 +00:00
|
|
|
text: qsTr("Identity")
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusTabButton {
|
2024-02-09 04:05:14 +00:00
|
|
|
objectName: "communitiesTabButton"
|
2022-10-20 13:41:18 +00:00
|
|
|
width: implicitWidth
|
2024-02-04 11:50:26 +00:00
|
|
|
text: qsTr("Communities")
|
2022-10-20 13:41:18 +00:00
|
|
|
}
|
2024-02-04 11:50:26 +00:00
|
|
|
|
2022-10-20 13:41:18 +00:00
|
|
|
StatusTabButton {
|
2024-02-09 04:05:14 +00:00
|
|
|
objectName: "accountsTabButton"
|
2022-10-20 13:41:18 +00:00
|
|
|
width: implicitWidth
|
2024-02-04 11:50:26 +00:00
|
|
|
text: qsTr("Accounts")
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusTabButton {
|
2024-02-09 04:05:14 +00:00
|
|
|
objectName: "collectiblesTabButton"
|
2024-02-04 11:50:26 +00:00
|
|
|
width: implicitWidth
|
|
|
|
text: qsTr("Collectibles")
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusTabButton {
|
2024-02-09 04:05:14 +00:00
|
|
|
objectName: "assetsTabButton"
|
2024-02-04 11:50:26 +00:00
|
|
|
width: implicitWidth
|
|
|
|
text: qsTr("Assets")
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusTabButton {
|
2024-02-09 04:05:14 +00:00
|
|
|
objectName: "webTabButton"
|
2024-02-04 11:50:26 +00:00
|
|
|
width: implicitWidth
|
|
|
|
text: qsTr("Web")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onVisibleChanged: if (visible) profileStore.requestProfileShowcasePreferences()
|
|
|
|
Component.onCompleted: profileStore.requestProfileShowcasePreferences()
|
|
|
|
|
|
|
|
readonly property var priv: QtObject {
|
|
|
|
id: priv
|
|
|
|
|
|
|
|
property bool hasAnyProfileShowcaseChanges: false
|
|
|
|
|
|
|
|
function reset() {
|
|
|
|
descriptionPanel.displayName.text = Qt.binding(() => { return profileStore.displayName })
|
|
|
|
descriptionPanel.bio.text = Qt.binding(() => { return profileStore.bio })
|
|
|
|
profileStore.resetSocialLinks()
|
|
|
|
profileHeader.icon = Qt.binding(() => { return profileStore.profileLargeImage })
|
|
|
|
|
|
|
|
profileShowcaseCommunitiesPanel.reset()
|
|
|
|
profileShowcaseAccountsPanel.reset()
|
|
|
|
profileShowcaseCollectiblesPanel.reset()
|
|
|
|
profileShowcaseAssetsPanel.reset()
|
|
|
|
root.profileStore.requestProfileShowcasePreferences()
|
|
|
|
hasAnyProfileShowcaseChanges = false
|
|
|
|
}
|
|
|
|
|
|
|
|
function save() {
|
|
|
|
if (hasAnyProfileShowcaseChanges)
|
|
|
|
profileStore.storeProfileShowcasePreferences()
|
|
|
|
|
|
|
|
if (!descriptionPanel.isEnsName)
|
|
|
|
profileStore.setDisplayName(descriptionPanel.displayName.text)
|
|
|
|
profileStore.setBio(descriptionPanel.bio.text.trim())
|
|
|
|
profileStore.saveSocialLinks()
|
|
|
|
if (profileHeader.icon === "") {
|
|
|
|
root.profileStore.removeImage()
|
|
|
|
} else {
|
|
|
|
profileStore.uploadImage(profileHeader.icon,
|
|
|
|
profileHeader.cropRect.x.toFixed(),
|
|
|
|
profileHeader.cropRect.y.toFixed(),
|
|
|
|
(profileHeader.cropRect.x + profileHeader.cropRect.width).toFixed(),
|
|
|
|
(profileHeader.cropRect.y + profileHeader.cropRect.height).toFixed());
|
|
|
|
}
|
|
|
|
|
|
|
|
reset()
|
2022-10-20 13:41:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-15 18:58:54 +00:00
|
|
|
StackLayout {
|
|
|
|
id: stackLayout
|
|
|
|
|
2024-03-03 12:06:52 +00:00
|
|
|
width: root.contentWidth
|
|
|
|
height: profileTabBar.currentIndex === MyProfileView.Web ? implicitHeight : root.contentHeight
|
2024-02-15 18:58:54 +00:00
|
|
|
currentIndex: profileTabBar.currentIndex
|
|
|
|
|
2024-02-23 09:22:50 +00:00
|
|
|
onCurrentIndexChanged: {
|
|
|
|
if(root.profileStore.isFirstShowcaseInteraction && currentIndex !== MyProfileView.TabIndex.Identity) {
|
|
|
|
root.profileStore.setIsFirstShowcaseInteraction()
|
|
|
|
Global.openPopup(profileShowcaseInfoPopup)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-15 18:58:54 +00:00
|
|
|
// identity
|
|
|
|
ColumnLayout {
|
|
|
|
objectName: "myProfileSettingsView"
|
|
|
|
ProfileHeader {
|
|
|
|
id: profileHeader
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.leftMargin: Style.current.padding
|
|
|
|
Layout.rightMargin: Style.current.padding
|
|
|
|
|
|
|
|
store: root.profileStore
|
|
|
|
|
|
|
|
displayName: profileStore.name
|
|
|
|
pubkey: profileStore.pubkey
|
|
|
|
icon: profileStore.profileLargeImage
|
|
|
|
imageSize: ProfileHeader.ImageSize.Big
|
|
|
|
|
|
|
|
displayNameVisible: false
|
|
|
|
pubkeyVisible: false
|
|
|
|
emojiHashVisible: false
|
|
|
|
editImageButtonVisible: true
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|
2022-03-16 21:20:03 +00:00
|
|
|
|
2024-02-15 18:58:54 +00:00
|
|
|
ProfileDescriptionPanel {
|
|
|
|
id: descriptionPanel
|
2024-02-04 11:50:26 +00:00
|
|
|
|
2024-02-15 18:58:54 +00:00
|
|
|
readonly property bool isEnsName: profileStore.preferredName
|
2024-02-04 11:50:26 +00:00
|
|
|
|
2024-02-15 18:58:54 +00:00
|
|
|
Layout.fillWidth: true
|
2024-02-12 16:56:59 +00:00
|
|
|
|
2024-02-15 18:58:54 +00:00
|
|
|
displayName.focus: !isEnsName
|
|
|
|
displayName.input.edit.readOnly: isEnsName
|
|
|
|
displayName.text: profileStore.name
|
|
|
|
displayName.validationMode: StatusInput.ValidationMode.Always
|
|
|
|
displayName.validators: isEnsName ? [] : Constants.validators.displayName
|
|
|
|
bio.text: profileStore.bio
|
2024-02-04 11:50:26 +00:00
|
|
|
}
|
2024-02-15 18:58:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// communities
|
|
|
|
ProfileShowcaseCommunitiesPanel {
|
|
|
|
id: profileShowcaseCommunitiesPanel
|
|
|
|
baseModel: root.communitiesModel
|
|
|
|
showcaseModel: root.profileStore.profileShowcaseCommunitiesModel
|
|
|
|
onShowcaseEntryChanged: priv.hasAnyProfileShowcaseChanges = true
|
|
|
|
}
|
2024-02-04 11:50:26 +00:00
|
|
|
|
2024-02-15 18:58:54 +00:00
|
|
|
// accounts
|
|
|
|
ProfileShowcaseAccountsPanel {
|
|
|
|
id: profileShowcaseAccountsPanel
|
|
|
|
baseModel: root.walletStore.accounts
|
|
|
|
showcaseModel: root.profileStore.profileShowcaseAccountsModel
|
|
|
|
currentWallet: root.walletStore.overview.mixedcaseAddress
|
|
|
|
onShowcaseEntryChanged: priv.hasAnyProfileShowcaseChanges = true
|
|
|
|
}
|
2024-02-09 11:05:51 +00:00
|
|
|
|
2024-02-15 18:58:54 +00:00
|
|
|
// collectibles
|
|
|
|
ProfileShowcaseCollectiblesPanel {
|
|
|
|
id: profileShowcaseCollectiblesPanel
|
|
|
|
baseModel: root.profileStore.collectiblesModel
|
|
|
|
showcaseModel: root.profileStore.profileShowcaseCollectiblesModel
|
2024-02-23 09:22:50 +00:00
|
|
|
addAccountsButtonVisible: root.profileStore.profileShowcaseAccountsModel.hiddenCount > 0
|
2024-02-09 11:05:51 +00:00
|
|
|
|
2024-02-23 09:22:50 +00:00
|
|
|
onShowcaseEntryChanged: priv.hasAnyProfileShowcaseChanges = true
|
|
|
|
onNavigateToAccountsTab: profileTabBar.currentIndex = MyProfileView.TabIndex.Accounts
|
2024-02-15 18:58:54 +00:00
|
|
|
}
|
2022-11-11 16:46:35 +00:00
|
|
|
|
2024-02-15 18:58:54 +00:00
|
|
|
// assets
|
|
|
|
ProfileShowcaseAssetsPanel {
|
|
|
|
id: profileShowcaseAssetsPanel
|
|
|
|
|
|
|
|
baseModel: root.walletAssetsStore.groupedAccountAssetsModel // TODO: instantiate an assets model in profile module
|
|
|
|
showcaseModel: root.profileStore.profileShowcaseAssetsModel
|
|
|
|
addAccountsButtonVisible: root.profileStore.profileShowcaseAccountsModel.hiddenCount > 0
|
|
|
|
formatCurrencyAmount: function(amount, symbol) {
|
|
|
|
return root.currencyStore.formatCurrencyAmount(amount, symbol)
|
2024-02-04 11:50:26 +00:00
|
|
|
}
|
2022-11-11 16:46:35 +00:00
|
|
|
|
2024-02-15 18:58:54 +00:00
|
|
|
onShowcaseEntryChanged: priv.hasAnyProfileShowcaseChanges = true
|
2024-02-23 09:22:50 +00:00
|
|
|
onNavigateToAccountsTab: profileTabBar.currentIndex = MyProfileView.TabIndex.Accounts
|
2024-02-15 18:58:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// web
|
|
|
|
ProfileSocialLinksPanel {
|
|
|
|
profileStore: root.profileStore
|
|
|
|
socialLinksModel: root.profileStore.temporarySocialLinksModel
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: profilePreview
|
|
|
|
ProfileDialog {
|
|
|
|
publicKey: root.contactsStore.myPublicKey
|
|
|
|
profileStore: root.profileStore
|
|
|
|
contactsStore: root.contactsStore
|
|
|
|
networkConnectionStore: root.networkConnectionStore
|
|
|
|
onClosed: destroy()
|
2024-02-04 11:50:26 +00:00
|
|
|
}
|
2020-08-19 21:01:22 +00:00
|
|
|
}
|
2024-02-23 09:22:50 +00:00
|
|
|
|
|
|
|
Component {
|
|
|
|
id: profileShowcaseInfoPopup
|
|
|
|
|
|
|
|
ProfileShowcaseInfoPopup {
|
|
|
|
destroyOnClose: true
|
|
|
|
}
|
|
|
|
}
|
2020-08-19 21:01:22 +00:00
|
|
|
}
|
2020-07-21 21:03:22 +00:00
|
|
|
}
|