2022-06-22 12:16:21 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.3
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
import shared 1.0
|
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.popups 1.0
|
|
|
|
import shared.controls.chat 1.0
|
|
|
|
|
|
|
|
import "../../popups"
|
|
|
|
import "../../stores"
|
|
|
|
import "../../controls"
|
2022-08-10 08:34:56 +00:00
|
|
|
import "../../panels"
|
2022-06-22 12:16:21 +00:00
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: root
|
|
|
|
|
2023-03-08 01:56:41 +00:00
|
|
|
spacing: 20
|
|
|
|
|
2022-06-22 12:16:21 +00:00
|
|
|
property PrivacyStore privacyStore
|
|
|
|
property ProfileStore profileStore
|
|
|
|
property WalletStore walletStore
|
2023-02-28 15:00:10 +00:00
|
|
|
property var communitiesModel
|
2022-06-22 12:16:21 +00:00
|
|
|
|
2022-11-08 18:30:50 +00:00
|
|
|
property QtObject dirtyValues: QtObject {
|
|
|
|
property string displayName: descriptionPanel.displayName.text
|
|
|
|
property string bio: descriptionPanel.bio.text
|
|
|
|
property bool biomentricValue: biometricsSwitch.checked
|
2022-12-01 08:37:46 +00:00
|
|
|
property url profileLargeImage: profileHeader.previewIcon
|
2022-11-08 18:30:50 +00:00
|
|
|
}
|
|
|
|
|
2022-12-05 19:24:55 +00:00
|
|
|
readonly property bool dirty: (!descriptionPanel.isEnsName &&
|
|
|
|
descriptionPanel.displayName.text !== profileStore.displayName) ||
|
2022-08-10 08:34:56 +00:00
|
|
|
descriptionPanel.bio.text !== profileStore.bio ||
|
|
|
|
profileStore.socialLinksDirty ||
|
2022-11-15 13:54:26 +00:00
|
|
|
biometricsSwitch.checked !== biometricsSwitch.currentStoredValue ||
|
2022-11-08 18:30:50 +00:00
|
|
|
profileHeader.icon !== profileStore.profileLargeImage
|
2022-06-22 12:16:21 +00:00
|
|
|
|
2022-08-10 08:34:56 +00:00
|
|
|
readonly property bool valid: !!descriptionPanel.displayName.text && descriptionPanel.displayName.valid
|
2022-06-22 12:16:21 +00:00
|
|
|
|
|
|
|
function reset() {
|
2022-08-10 08:34:56 +00:00
|
|
|
descriptionPanel.displayName.text = Qt.binding(() => { return profileStore.displayName })
|
|
|
|
descriptionPanel.bio.text = Qt.binding(() => { return profileStore.bio })
|
|
|
|
profileStore.resetSocialLinks()
|
2022-06-22 12:16:21 +00:00
|
|
|
biometricsSwitch.checked = Qt.binding(() => { return biometricsSwitch.currentStoredValue })
|
2022-11-08 18:30:50 +00:00
|
|
|
profileHeader.icon = Qt.binding(() => { return profileStore.profileLargeImage })
|
2022-06-22 12:16:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function save() {
|
2022-12-05 19:24:55 +00:00
|
|
|
if (!descriptionPanel.isEnsName)
|
|
|
|
profileStore.setDisplayName(descriptionPanel.displayName.text)
|
2022-08-10 08:34:56 +00:00
|
|
|
profileStore.setBio(descriptionPanel.bio.text)
|
|
|
|
profileStore.saveSocialLinks()
|
2022-11-08 18:30:50 +00:00
|
|
|
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());
|
|
|
|
}
|
2022-12-23 15:11:27 +00:00
|
|
|
|
|
|
|
if (biometricsSwitch.checked && !biometricsSwitch.currentStoredValue)
|
2023-02-02 13:54:35 +00:00
|
|
|
root.privacyStore.tryStoreToKeyChain()
|
2022-12-23 15:11:27 +00:00
|
|
|
else if (!biometricsSwitch.checked)
|
2023-02-02 13:54:35 +00:00
|
|
|
root.privacyStore.tryRemoveFromKeyChain()
|
2022-11-08 18:30:50 +00:00
|
|
|
|
|
|
|
reset()
|
2022-06-22 12:16:21 +00:00
|
|
|
}
|
|
|
|
|
2023-02-02 13:54:35 +00:00
|
|
|
Connections {
|
|
|
|
target: Qt.platform.os === Constants.mac? root.privacyStore.privacyModule : null
|
2022-06-22 12:16:21 +00:00
|
|
|
|
2023-02-02 13:54:35 +00:00
|
|
|
function onStoreToKeychainError(errorDescription: string) {
|
|
|
|
root.reset()
|
|
|
|
}
|
|
|
|
|
|
|
|
function onStoreToKeychainSuccess() {
|
|
|
|
root.reset()
|
|
|
|
}
|
2022-06-22 12:16:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ProfileHeader {
|
2022-11-08 18:30:50 +00:00
|
|
|
id: profileHeader
|
2022-06-22 12:16:21 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.leftMargin: Style.current.padding
|
|
|
|
Layout.rightMargin: Style.current.padding
|
|
|
|
|
2022-08-07 21:05:25 +00:00
|
|
|
store: root.profileStore
|
|
|
|
|
2022-06-22 12:16:21 +00:00
|
|
|
displayName: profileStore.name
|
|
|
|
pubkey: profileStore.pubkey
|
2022-07-06 19:07:33 +00:00
|
|
|
icon: profileStore.profileLargeImage
|
2022-06-22 12:16:21 +00:00
|
|
|
imageSize: ProfileHeader.ImageSize.Big
|
2022-08-10 08:34:56 +00:00
|
|
|
|
2022-06-22 12:16:21 +00:00
|
|
|
displayNameVisible: false
|
|
|
|
pubkeyVisible: false
|
|
|
|
emojiHashVisible: false
|
|
|
|
editImageButtonVisible: true
|
|
|
|
}
|
|
|
|
|
2022-08-10 08:34:56 +00:00
|
|
|
ProfileDescriptionPanel {
|
|
|
|
id: descriptionPanel
|
|
|
|
|
2022-12-13 09:37:27 +00:00
|
|
|
readonly property bool isEnsName: profileStore.preferredName
|
2022-08-10 08:34:56 +00:00
|
|
|
|
2022-12-05 19:24:55 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
displayName.focus: !isEnsName
|
|
|
|
displayName.input.edit.readOnly: isEnsName
|
2022-12-13 09:37:27 +00:00
|
|
|
displayName.text: profileStore.name
|
|
|
|
displayName.validationMode: StatusInput.ValidationMode.Always
|
2022-12-05 19:24:55 +00:00
|
|
|
displayName.validators: isEnsName ? [] : Constants.validators.displayName
|
2022-08-10 08:34:56 +00:00
|
|
|
bio.text: profileStore.bio
|
2023-03-08 01:56:41 +00:00
|
|
|
}
|
2022-08-10 08:34:56 +00:00
|
|
|
|
2023-03-08 01:56:41 +00:00
|
|
|
Separator {
|
|
|
|
Layout.fillWidth: true
|
2022-08-10 08:34:56 +00:00
|
|
|
}
|
|
|
|
|
2023-03-08 01:56:41 +00:00
|
|
|
ProfileSocialLinksPanel {
|
|
|
|
id: socialLinksPanel
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
2022-08-10 08:34:56 +00:00
|
|
|
profileStore: root.profileStore
|
2023-03-08 01:56:41 +00:00
|
|
|
socialLinksModel: root.profileStore.temporarySocialLinksModel
|
|
|
|
}
|
2022-08-10 08:34:56 +00:00
|
|
|
|
2023-03-08 01:56:41 +00:00
|
|
|
Separator {
|
|
|
|
Layout.fillWidth: true
|
2022-06-22 12:16:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusListItem {
|
|
|
|
Layout.fillWidth: true
|
2023-02-28 15:00:10 +00:00
|
|
|
visible: Qt.platform.os === Constants.mac
|
2022-06-22 12:16:21 +00:00
|
|
|
title: qsTr("Biometric login and transaction authentication")
|
2022-08-11 11:55:08 +00:00
|
|
|
asset.name: "touch-id"
|
2022-06-22 12:16:21 +00:00
|
|
|
components: [ StatusSwitch {
|
|
|
|
id: biometricsSwitch
|
2022-07-13 09:17:18 +00:00
|
|
|
horizontalPadding: 0
|
2022-07-21 11:29:18 +00:00
|
|
|
readonly property bool currentStoredValue: localAccountSettings.storeToKeychainValue === Constants.keychain.storedValue.store
|
2022-06-22 12:16:21 +00:00
|
|
|
checked: currentStoredValue
|
|
|
|
} ]
|
2022-08-24 14:37:05 +00:00
|
|
|
onClicked: biometricsSwitch.toggle()
|
2022-06-22 12:16:21 +00:00
|
|
|
}
|
|
|
|
|
2023-03-08 01:56:41 +00:00
|
|
|
Separator {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
visible: Qt.platform.os === Constants.mac
|
|
|
|
}
|
|
|
|
|
2022-06-22 12:16:21 +00:00
|
|
|
StatusTabBar {
|
|
|
|
id: showcaseTabBar
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
function validateCurrentIndex() {
|
|
|
|
|
|
|
|
let processedButtons = 0;
|
|
|
|
|
|
|
|
while (!itemAt(currentIndex).enabled) {
|
2022-12-13 15:49:31 +00:00
|
|
|
if (++processedButtons === count) {
|
2022-06-22 12:16:21 +00:00
|
|
|
currentIndex = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
currentIndex = (currentIndex + 1) % count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusTabButton {
|
|
|
|
width: enabled ? implicitWidth : 0
|
|
|
|
text: qsTr("Communities")
|
|
|
|
onEnabledChanged: showcaseTabBar.validateCurrentIndex()
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusTabButton {
|
2023-03-15 13:35:03 +00:00
|
|
|
enabled: root.profileStore.isWalletEnabled
|
2022-06-22 12:16:21 +00:00
|
|
|
width: enabled ? implicitWidth : 0
|
|
|
|
text: qsTr("Accounts")
|
|
|
|
onEnabledChanged: showcaseTabBar.validateCurrentIndex()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StackLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
currentIndex: showcaseTabBar.currentIndex
|
|
|
|
|
|
|
|
Column {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
visible: communitiesRepeater.count == 0
|
|
|
|
width: parent.width
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
text: qsTr("You haven't joined any communities yet")
|
|
|
|
}
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
id: communitiesRepeater
|
2023-02-28 15:00:10 +00:00
|
|
|
model: root.communitiesModel
|
2022-06-22 12:16:21 +00:00
|
|
|
|
|
|
|
CommunityDelegate {
|
|
|
|
width: parent.width
|
|
|
|
visible: joined
|
|
|
|
community: model
|
2023-02-28 15:00:10 +00:00
|
|
|
sensor.enabled: false
|
2022-06-22 12:16:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Column {
|
|
|
|
StatusBaseText {
|
|
|
|
visible: accountsRepeater.count == 0
|
|
|
|
width: parent.width
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
text: qsTr("You don't have any wallet accounts yet")
|
|
|
|
}
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
id: accountsRepeater
|
|
|
|
model: root.walletStore.accounts
|
|
|
|
|
|
|
|
WalletAccountDelegate {
|
|
|
|
width: parent.width
|
|
|
|
account: model
|
|
|
|
showShevronIcon: false
|
2023-02-28 15:00:10 +00:00
|
|
|
sensor.enabled: false
|
2022-06-22 12:16:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|