2023-10-24 11:21:20 +00:00
|
|
|
|
import QtQuick 2.15
|
2024-01-04 12:05:54 +00:00
|
|
|
|
import QtQuick.Controls 2.15
|
2023-10-24 11:21:20 +00:00
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
|
|
2024-01-16 16:22:05 +00:00
|
|
|
|
import StatusQ 0.1
|
2024-01-04 12:05:54 +00:00
|
|
|
|
import StatusQ.Core 0.1
|
2023-10-24 11:21:20 +00:00
|
|
|
|
import StatusQ.Controls 0.1
|
2024-01-04 12:05:54 +00:00
|
|
|
|
import StatusQ.Components 0.1
|
2024-01-16 16:22:05 +00:00
|
|
|
|
import StatusQ.Models 0.1
|
2024-01-04 12:05:54 +00:00
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
import StatusQ.Popups.Dialog 0.1
|
2023-10-24 11:21:20 +00:00
|
|
|
|
|
|
|
|
|
import shared.controls 1.0
|
2024-01-04 12:05:54 +00:00
|
|
|
|
import shared.stores 1.0 as SharedStores
|
2023-11-17 14:08:43 +00:00
|
|
|
|
import utils 1.0
|
2023-10-24 11:21:20 +00:00
|
|
|
|
|
2023-10-25 10:40:10 +00:00
|
|
|
|
import AppLayouts.Profile.panels 1.0
|
2023-11-17 14:08:43 +00:00
|
|
|
|
import AppLayouts.Wallet.panels 1.0
|
2024-02-19 12:09:07 +00:00
|
|
|
|
import AppLayouts.Wallet.stores 1.0
|
|
|
|
|
|
2023-10-25 10:40:10 +00:00
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
|
Item {
|
2023-10-24 11:21:20 +00:00
|
|
|
|
id: root
|
|
|
|
|
|
2024-02-19 12:09:07 +00:00
|
|
|
|
required property TokensStore tokensStore
|
|
|
|
|
|
2024-02-01 12:01:07 +00:00
|
|
|
|
required property double tokenListUpdatedAt
|
2024-01-31 18:09:44 +00:00
|
|
|
|
required property var assetsController
|
|
|
|
|
required property var collectiblesController
|
|
|
|
|
|
2023-10-25 10:40:10 +00:00
|
|
|
|
required property var sourcesOfTokensModel // Expected roles: key, name, updatedAt, source, version, tokensCount, image
|
|
|
|
|
required property var tokensListModel // Expected roles: name, symbol, image, chainName, explorerUrl
|
|
|
|
|
|
2023-11-17 14:08:43 +00:00
|
|
|
|
required property var baseWalletAssetsModel
|
|
|
|
|
required property var baseWalletCollectiblesModel
|
|
|
|
|
|
2024-10-02 20:47:14 +00:00
|
|
|
|
property string currencySymbol: "USD"
|
2024-01-24 16:35:53 +00:00
|
|
|
|
property var getCurrencyAmount: function (balance, symbol) {}
|
|
|
|
|
property var getCurrentCurrencyAmount: function(balance){}
|
|
|
|
|
|
2023-12-06 10:54:36 +00:00
|
|
|
|
property alias currentIndex: tabBar.currentIndex
|
|
|
|
|
|
2024-02-19 12:09:07 +00:00
|
|
|
|
readonly property bool dirty: !!loader.item && loader.item.dirty
|
|
|
|
|
readonly property bool advancedTabVisible: tabBar.currentIndex === d.advancedTabIndex
|
2023-11-17 14:08:43 +00:00
|
|
|
|
|
2024-04-10 19:38:15 +00:00
|
|
|
|
function saveChanges(update) {
|
|
|
|
|
loader.item.saveSettings(update)
|
2023-11-17 14:08:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-19 12:09:07 +00:00
|
|
|
|
function resetChanges() {
|
|
|
|
|
loader.item.resetChanges()
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-11 12:00:25 +00:00
|
|
|
|
readonly property bool assetsPanelVisible: tabBar.currentIndex === d.assetsTabIndex
|
|
|
|
|
readonly property bool collectiblesPanelVisible: tabBar.currentIndex === d.collectiblesTabIndex
|
|
|
|
|
|
2023-11-17 14:08:43 +00:00
|
|
|
|
QtObject {
|
|
|
|
|
id: d
|
|
|
|
|
|
|
|
|
|
readonly property int assetsTabIndex: 0
|
|
|
|
|
readonly property int collectiblesTabIndex: 1
|
2024-01-16 16:22:05 +00:00
|
|
|
|
readonly property int hiddenTabIndex: 2
|
|
|
|
|
readonly property int advancedTabIndex: 3
|
2023-11-17 14:08:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
|
ColumnLayout {
|
|
|
|
|
anchors.fill: parent
|
2023-10-24 11:21:20 +00:00
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
|
StatusTabBar {
|
|
|
|
|
id: tabBar
|
2023-10-24 11:21:20 +00:00
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.topMargin: 5
|
|
|
|
|
|
|
|
|
|
StatusTabButton {
|
|
|
|
|
leftPadding: 0
|
|
|
|
|
width: implicitWidth
|
2024-07-19 06:43:44 +00:00
|
|
|
|
objectName: "assetsButton"
|
2024-01-26 15:39:42 +00:00
|
|
|
|
text: qsTr("Assets")
|
|
|
|
|
}
|
|
|
|
|
StatusTabButton {
|
|
|
|
|
width: implicitWidth
|
|
|
|
|
text: qsTr("Collectibles")
|
|
|
|
|
}
|
|
|
|
|
StatusTabButton {
|
|
|
|
|
width: implicitWidth
|
|
|
|
|
text: qsTr("Hidden")
|
|
|
|
|
}
|
|
|
|
|
StatusTabButton {
|
|
|
|
|
width: implicitWidth
|
|
|
|
|
text: qsTr("Advanced")
|
|
|
|
|
}
|
2023-10-24 11:21:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
|
// NB: we want to discard any pending unsaved changes when switching tabs or navigating away
|
|
|
|
|
Loader {
|
|
|
|
|
id: loader
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
active: visible
|
2023-11-17 14:08:43 +00:00
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
|
sourceComponent: {
|
|
|
|
|
switch (tabBar.currentIndex) {
|
|
|
|
|
case d.assetsTabIndex:
|
2024-02-13 16:08:38 +00:00
|
|
|
|
return assetsPanel
|
2024-01-26 15:39:42 +00:00
|
|
|
|
case d.collectiblesTabIndex:
|
|
|
|
|
return collectiblesPanel
|
|
|
|
|
case d.hiddenTabIndex:
|
|
|
|
|
return hiddenPanel
|
|
|
|
|
case d.advancedTabIndex:
|
|
|
|
|
return advancedTab
|
|
|
|
|
}
|
2023-11-17 14:08:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-10-24 11:21:20 +00:00
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
|
Component {
|
2024-02-13 16:08:38 +00:00
|
|
|
|
id: assetsPanel
|
2024-01-26 15:39:42 +00:00
|
|
|
|
ManageAssetsPanel {
|
|
|
|
|
getCurrencyAmount: function (balance, symbol) {
|
|
|
|
|
return root.getCurrencyAmount(balance, symbol)
|
|
|
|
|
}
|
|
|
|
|
getCurrentCurrencyAmount: function (balance) {
|
|
|
|
|
return root.getCurrentCurrencyAmount(balance)
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-31 18:09:44 +00:00
|
|
|
|
controller: root.assetsController
|
2024-01-24 16:35:53 +00:00
|
|
|
|
}
|
2023-10-24 11:21:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
|
Component {
|
|
|
|
|
id: collectiblesPanel
|
|
|
|
|
ManageCollectiblesPanel {
|
2024-01-31 18:09:44 +00:00
|
|
|
|
controller: root.collectiblesController
|
2024-01-26 15:39:42 +00:00
|
|
|
|
}
|
2023-10-24 11:21:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
|
Component {
|
|
|
|
|
id: hiddenPanel
|
|
|
|
|
ManageHiddenPanel {
|
|
|
|
|
getCurrencyAmount: function (balance, symbol) {
|
|
|
|
|
return root.getCurrencyAmount(balance, symbol)
|
|
|
|
|
}
|
|
|
|
|
getCurrentCurrencyAmount: function (balance) {
|
|
|
|
|
return root.getCurrentCurrencyAmount(balance)
|
|
|
|
|
}
|
2024-01-31 18:09:44 +00:00
|
|
|
|
assetsController: root.assetsController
|
|
|
|
|
collectiblesController: root.collectiblesController
|
2024-01-25 18:53:09 +00:00
|
|
|
|
}
|
2024-01-16 16:22:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
|
Component {
|
|
|
|
|
id: advancedTab
|
|
|
|
|
ColumnLayout {
|
2024-02-19 12:09:07 +00:00
|
|
|
|
id: advancedSettings
|
|
|
|
|
|
|
|
|
|
function saveSettings() {
|
|
|
|
|
if (showCommunityAssetsSwitch.checked !== root.tokensStore.showCommunityAssetsInSend)
|
|
|
|
|
root.tokensStore.toggleShowCommunityAssetsInSend()
|
|
|
|
|
if (displayThresholdSwitch.checked !== root.tokensStore.displayAssetsBelowBalance)
|
|
|
|
|
root.tokensStore.toggleDisplayAssetsBelowBalance()
|
|
|
|
|
const rawAmount = currencyAmount.value * Math.pow(10, thresholdCurrency.displayDecimals)
|
|
|
|
|
if (rawAmount !== thresholdCurrency.amount) {
|
|
|
|
|
root.tokensStore.setDisplayAssetsBelowBalanceThreshold(rawAmount)
|
|
|
|
|
}
|
|
|
|
|
dirty = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function resetChanges() {
|
|
|
|
|
showCommunityAssetsSwitch.checked = root.tokensStore.showCommunityAssetsInSend
|
|
|
|
|
displayThresholdSwitch.checked = root.tokensStore.displayAssetsBelowBalance
|
|
|
|
|
currencyAmount.value = getDisplayThresholdAmount()
|
|
|
|
|
dirty = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getDisplayThresholdAmount() {
|
|
|
|
|
return thresholdCurrency.amount / Math.pow(10, thresholdCurrency.displayDecimals)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
property bool dirty: false
|
|
|
|
|
|
2024-03-19 23:34:25 +00:00
|
|
|
|
readonly property var thresholdCurrency: root.tokensStore.getDisplayAssetsBelowBalanceThresholdCurrency()
|
2024-02-12 15:38:52 +00:00
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
|
spacing: 8
|
|
|
|
|
StatusListItem {
|
2024-08-01 10:17:36 +00:00
|
|
|
|
// Temporarily disabled, refer to https://github.com/status-im/status-desktop/issues/15955 for details.
|
|
|
|
|
visible: false
|
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
title: qsTr("Show community assets when sending tokens")
|
2024-01-04 12:05:54 +00:00
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
|
components: [
|
|
|
|
|
StatusSwitch {
|
|
|
|
|
id: showCommunityAssetsSwitch
|
2024-02-19 12:09:07 +00:00
|
|
|
|
checked: root.tokensStore.showCommunityAssetsInSend
|
2024-01-26 15:39:42 +00:00
|
|
|
|
onCheckedChanged: {
|
2024-02-19 12:09:07 +00:00
|
|
|
|
if (!advancedSettings.dirty && checked === root.tokensStore.showCommunityAssetsInSend) {
|
|
|
|
|
// Skipping initial value
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
advancedSettings.dirty = true
|
2024-01-26 15:39:42 +00:00
|
|
|
|
}
|
2024-01-04 12:05:54 +00:00
|
|
|
|
}
|
2024-01-26 15:39:42 +00:00
|
|
|
|
]
|
|
|
|
|
onClicked: {
|
|
|
|
|
showCommunityAssetsSwitch.checked = !showCommunityAssetsSwitch.checked
|
2024-01-04 12:05:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-01-26 15:39:42 +00:00
|
|
|
|
StatusDialogDivider {
|
2024-08-01 10:17:36 +00:00
|
|
|
|
visible: false
|
2024-01-26 15:39:42 +00:00
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
}
|
|
|
|
|
StatusListItem {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
title: qsTr("Don’t display assets with balance lower than")
|
2024-01-04 12:05:54 +00:00
|
|
|
|
|
2024-01-26 15:39:42 +00:00
|
|
|
|
components: [
|
|
|
|
|
CurrencyAmountInput {
|
2024-02-19 12:09:07 +00:00
|
|
|
|
id: currencyAmount
|
2024-01-26 15:39:42 +00:00
|
|
|
|
enabled: displayThresholdSwitch.checked
|
2024-10-02 20:47:14 +00:00
|
|
|
|
currencySymbol: root.currencySymbol
|
2024-02-19 12:09:07 +00:00
|
|
|
|
value: advancedSettings.getDisplayThresholdAmount()
|
|
|
|
|
onValueChanged: {
|
|
|
|
|
if (!advancedSettings.dirty && advancedSettings.getDisplayThresholdAmount() === value) {
|
|
|
|
|
// Skipping initial value
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
advancedSettings.dirty = true
|
|
|
|
|
}
|
2024-01-26 15:39:42 +00:00
|
|
|
|
},
|
|
|
|
|
StatusSwitch {
|
|
|
|
|
id: displayThresholdSwitch
|
2024-02-19 12:09:07 +00:00
|
|
|
|
checked: root.tokensStore.displayAssetsBelowBalance
|
2024-01-26 15:39:42 +00:00
|
|
|
|
onCheckedChanged: {
|
2024-02-19 12:09:07 +00:00
|
|
|
|
if (!advancedSettings.dirty && checked === root.tokensStore.displayAssetsBelowBalance) {
|
|
|
|
|
// Skipping initial value
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
advancedSettings.dirty = true
|
2024-01-26 15:39:42 +00:00
|
|
|
|
}
|
2024-01-04 12:05:54 +00:00
|
|
|
|
}
|
2024-01-26 15:39:42 +00:00
|
|
|
|
]
|
|
|
|
|
onClicked: {
|
|
|
|
|
displayThresholdSwitch.checked = !displayThresholdSwitch.checked
|
2024-01-04 12:05:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-01-26 15:39:42 +00:00
|
|
|
|
StatusDialogDivider {
|
2024-01-22 16:29:05 +00:00
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
}
|
2024-01-26 15:39:42 +00:00
|
|
|
|
RowLayout {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.preferredHeight: 64
|
|
|
|
|
Layout.topMargin: 18
|
2024-02-12 15:38:52 +00:00
|
|
|
|
Layout.bottomMargin: -6
|
2024-01-26 15:39:42 +00:00
|
|
|
|
StatusBaseText {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
text: qsTr("Token lists")
|
2024-10-15 19:26:12 +00:00
|
|
|
|
color: Theme.palette.textColor
|
2024-01-26 15:39:42 +00:00
|
|
|
|
}
|
|
|
|
|
StatusBaseText {
|
|
|
|
|
Layout.alignment: Qt.AlignRight
|
2024-02-01 12:01:07 +00:00
|
|
|
|
text: qsTr("Last updated %1 @%2").arg(LocaleUtils.formatDate(root.tokenListUpdatedAt * 1000)).arg(LocaleUtils.formatTime(root.tokenListUpdatedAt, Locale.ShortFormat))
|
2024-10-15 19:26:12 +00:00
|
|
|
|
font.pixelSize: Theme.additionalTextSize
|
|
|
|
|
color: Theme.palette.darkGrey
|
2024-01-26 15:39:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
SupportedTokenListsPanel {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
sourcesOfTokensModel: root.sourcesOfTokensModel
|
|
|
|
|
tokensListModel: root.tokensListModel
|
2024-01-22 16:29:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-10-24 11:21:20 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|