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
|
2024-03-03 16:34:08 +00:00
|
|
|
import QtQml 2.15
|
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
|
2024-02-28 12:19:14 +00:00
|
|
|
import StatusQ.Core.Utils 0.1
|
2021-09-09 14:03:17 +00:00
|
|
|
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-28 12:19:14 +00:00
|
|
|
import AppLayouts.Profile.helpers 1.0
|
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-03-04 22:07:09 +00:00
|
|
|
required property WalletAssetsStore walletAssetsStore
|
2024-01-13 03:24:57 +00:00
|
|
|
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,
|
2024-03-04 22:07:09 +00:00
|
|
|
//Assets = 4,
|
2024-02-28 11:59:18 +00:00
|
|
|
Web = 4
|
2024-02-23 09:22:50 +00:00
|
|
|
}
|
|
|
|
|
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-03-08 20:11:48 +00:00
|
|
|
dirty: priv.isIdentityTabDirty ||
|
2024-02-15 18:58:54 +00:00
|
|
|
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-03-12 15:44:27 +00:00
|
|
|
toast.saveChangesTooltipText: saveChangesButtonEnabled ? "" : qsTr("Invalid changes made to Identity")
|
2024-03-04 12:41:54 +00:00
|
|
|
autoscrollWhenDirty: profileTabBar.currentIndex === MyProfileView.Identity
|
2024-02-12 16:39:06 +00:00
|
|
|
|
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")
|
|
|
|
}
|
|
|
|
|
2024-03-04 22:07:09 +00:00
|
|
|
// TODO: Uncomment when assets tab is implemented
|
|
|
|
// StatusTabButton {
|
|
|
|
// objectName: "assetsTabButton"
|
|
|
|
// width: implicitWidth
|
|
|
|
// text: qsTr("Assets")
|
|
|
|
// }
|
|
|
|
|
2024-02-04 11:50:26 +00:00
|
|
|
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
|
|
|
|
|
2024-02-28 12:19:14 +00:00
|
|
|
property bool hasAnyProfileShowcaseChanges: showcaseModels.dirty
|
2024-03-08 20:11:48 +00:00
|
|
|
property bool isIdentityTabDirty: (!descriptionPanel.isEnsName &&
|
2024-03-13 09:46:40 +00:00
|
|
|
descriptionPanel.displayName.text !== profileStore.displayName) ||
|
|
|
|
descriptionPanel.bio.text !== profileStore.bio ||
|
|
|
|
profileStore.socialLinksDirty ||
|
|
|
|
profileHeader.icon !== profileStore.profileLargeImage
|
2024-02-28 12:19:14 +00:00
|
|
|
|
|
|
|
property ProfileShowcaseModels showcaseModels: ProfileShowcaseModels {
|
|
|
|
communitiesSourceModel: root.communitiesModel
|
2024-03-11 18:40:52 +00:00
|
|
|
communitiesShowcaseModel: root.profileStore.showcasePreferencesCommunitiesModel
|
2024-03-03 16:34:08 +00:00
|
|
|
communitiesSearcherText: profileShowcaseCommunitiesPanel.searcherText
|
2024-02-28 12:19:14 +00:00
|
|
|
|
2024-03-13 11:10:36 +00:00
|
|
|
accountsSourceModel: root.walletStore.ownAccounts
|
2024-03-11 18:40:52 +00:00
|
|
|
accountsShowcaseModel: root.profileStore.showcasePreferencesAccountsModel
|
2024-03-03 16:34:08 +00:00
|
|
|
accountsSearcherText: profileShowcaseAccountsPanel.searcherText
|
2024-02-28 12:19:14 +00:00
|
|
|
|
|
|
|
collectiblesSourceModel: root.profileStore.collectiblesModel
|
2024-03-11 18:40:52 +00:00
|
|
|
collectiblesShowcaseModel: root.profileStore.showcasePreferencesCollectiblesModel
|
2024-03-03 16:34:08 +00:00
|
|
|
collectiblesSearcherText: profileShowcaseCollectiblesPanel.searcherText
|
2024-03-08 09:27:45 +00:00
|
|
|
|
2024-03-11 18:40:52 +00:00
|
|
|
socialLinksSourceModel: root.profileStore.showcasePreferencesSocialLinksModel
|
2024-02-28 12:19:14 +00:00
|
|
|
}
|
2024-02-04 11:50:26 +00:00
|
|
|
|
|
|
|
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 })
|
|
|
|
|
2024-02-28 12:19:14 +00:00
|
|
|
priv.showcaseModels.revert()
|
2024-02-04 11:50:26 +00:00
|
|
|
root.profileStore.requestProfileShowcasePreferences()
|
|
|
|
}
|
|
|
|
|
|
|
|
function save() {
|
2024-03-08 20:11:48 +00:00
|
|
|
// Accounts, Communities, Assets, Collectibles and social links info
|
2024-03-13 09:46:40 +00:00
|
|
|
if (hasAnyProfileShowcaseChanges) {
|
2024-03-08 20:11:48 +00:00
|
|
|
root.profileStore.saveProfileShowcasePreferences(showcaseModels.buildJSONModelsCurrentState())
|
2024-03-13 09:46:40 +00:00
|
|
|
}
|
2024-03-08 20:11:48 +00:00
|
|
|
|
|
|
|
// Identity info
|
2024-03-13 09:46:40 +00:00
|
|
|
if (isIdentityTabDirty) {
|
2024-03-08 20:11:48 +00:00
|
|
|
root.profileStore.saveIdentityInfo(descriptionPanel.displayName.text,
|
|
|
|
descriptionPanel.bio.text.trim(),
|
|
|
|
profileHeader.icon,
|
2024-03-13 09:46:40 +00:00
|
|
|
profileHeader.cropRect.x,
|
|
|
|
profileHeader.cropRect.y,
|
|
|
|
(profileHeader.cropRect.x + profileHeader.cropRect.width),
|
|
|
|
(profileHeader.cropRect.y + profileHeader.cropRect.height))
|
|
|
|
profileHeader.icon = Qt.binding(() => { return profileStore.profileLargeImage })
|
|
|
|
}
|
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
|
2024-02-28 12:19:14 +00:00
|
|
|
inShowcaseModel: priv.showcaseModels.communitiesVisibleModel
|
2024-03-03 16:34:08 +00:00
|
|
|
hiddenModel: priv.showcaseModels.communitiesHiddenModel
|
2024-03-08 20:11:48 +00:00
|
|
|
showcaseLimit: root.profileStore.getProfileShowcaseEntriesLimit()
|
2024-02-28 12:19:14 +00:00
|
|
|
|
2024-02-29 07:43:38 +00:00
|
|
|
onChangePositionRequested: function (from, to) {
|
|
|
|
priv.showcaseModels.changeCommunityPosition(from, to)
|
2024-02-28 12:19:14 +00:00
|
|
|
}
|
|
|
|
onSetVisibilityRequested: function (key, toVisibility) {
|
|
|
|
priv.showcaseModels.setCommunityVisibility(key, toVisibility)
|
|
|
|
}
|
2024-02-15 18:58:54 +00:00
|
|
|
}
|
2024-02-04 11:50:26 +00:00
|
|
|
|
2024-02-15 18:58:54 +00:00
|
|
|
// accounts
|
|
|
|
ProfileShowcaseAccountsPanel {
|
|
|
|
id: profileShowcaseAccountsPanel
|
2024-02-28 12:19:14 +00:00
|
|
|
inShowcaseModel: priv.showcaseModels.accountsVisibleModel
|
|
|
|
hiddenModel: priv.showcaseModels.accountsHiddenModel
|
2024-03-08 20:11:48 +00:00
|
|
|
showcaseLimit: root.profileStore.getProfileShowcaseEntriesLimit()
|
2024-02-15 18:58:54 +00:00
|
|
|
currentWallet: root.walletStore.overview.mixedcaseAddress
|
2024-02-28 12:19:14 +00:00
|
|
|
|
2024-02-29 07:43:38 +00:00
|
|
|
onChangePositionRequested: function (from, to) {
|
|
|
|
priv.showcaseModels.changeAccountPosition(from, to)
|
2024-02-28 12:19:14 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
onSetVisibilityRequested: function (key, toVisibility) {
|
|
|
|
priv.showcaseModels.setAccountVisibility(key, toVisibility)
|
|
|
|
}
|
2024-02-15 18:58:54 +00:00
|
|
|
}
|
2024-02-09 11:05:51 +00:00
|
|
|
|
2024-02-15 18:58:54 +00:00
|
|
|
// collectibles
|
|
|
|
ProfileShowcaseCollectiblesPanel {
|
|
|
|
id: profileShowcaseCollectiblesPanel
|
2024-02-28 12:19:14 +00:00
|
|
|
inShowcaseModel: priv.showcaseModels.collectiblesVisibleModel
|
|
|
|
hiddenModel: priv.showcaseModels.collectiblesHiddenModel
|
2024-03-08 20:11:48 +00:00
|
|
|
showcaseLimit: root.profileStore.getProfileShowcaseEntriesLimit()
|
2024-03-04 22:07:09 +00:00
|
|
|
addAccountsButtonVisible: priv.showcaseModels.accountsHiddenModel.count > 0
|
|
|
|
|
|
|
|
onNavigateToAccountsTab: profileTabBar.currentIndex = MyProfileView.TabIndex.Accounts
|
|
|
|
|
2024-02-29 07:43:38 +00:00
|
|
|
onChangePositionRequested: function (from, to) {
|
|
|
|
priv.showcaseModels.changeCollectiblePosition(from, to)
|
2024-02-28 12:19:14 +00:00
|
|
|
}
|
2022-11-11 16:46:35 +00:00
|
|
|
|
2024-02-28 12:19:14 +00:00
|
|
|
onSetVisibilityRequested: function (key, toVisibility) {
|
|
|
|
priv.showcaseModels.setCollectibleVisibility(key, toVisibility)
|
|
|
|
}
|
2024-02-15 18:58:54 +00:00
|
|
|
}
|
|
|
|
|
2024-03-04 22:07:09 +00:00
|
|
|
// assets
|
|
|
|
// TODO: Integrate the assets tab with the new backend
|
|
|
|
// 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)
|
|
|
|
// }
|
|
|
|
|
|
|
|
// onShowcaseEntryChanged: priv.hasAnyProfileShowcaseChanges = true
|
|
|
|
// onNavigateToAccountsTab: profileTabBar.currentIndex = MyProfileView.TabIndex.Accounts
|
|
|
|
// }
|
|
|
|
|
2024-02-15 18:58:54 +00:00
|
|
|
// web
|
|
|
|
ProfileSocialLinksPanel {
|
2024-03-08 20:11:48 +00:00
|
|
|
showcaseLimit: root.profileStore.getProfileShowcaseSocialLinksLimit()
|
2024-03-08 09:27:45 +00:00
|
|
|
socialLinksModel: priv.showcaseModels.socialLinksVisibleModel
|
|
|
|
|
|
|
|
onAddSocialLink: function(url, text) {
|
|
|
|
priv.showcaseModels.appendSocialLink({ showcaseKey: "", text: text, url: url })
|
|
|
|
}
|
|
|
|
|
|
|
|
onUpdateSocialLink: function(index, url, text) {
|
|
|
|
priv.showcaseModels.updateSocialLink(index, { text: text, url: url })
|
|
|
|
}
|
|
|
|
|
|
|
|
onRemoveSocialLink: function(index) {
|
|
|
|
priv.showcaseModels.removeSocialLink(index)
|
|
|
|
}
|
|
|
|
|
|
|
|
onChangePosition: function(from, to) {
|
|
|
|
priv.showcaseModels.changeSocialLinkPosition(from, to)
|
|
|
|
}
|
2024-02-15 18:58:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|