2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2024-07-02 23:31:34 +00:00
|
|
|
import QtQml 2.15
|
2021-09-28 15:04:06 +00:00
|
|
|
|
2024-03-13 17:38:16 +00:00
|
|
|
import StatusQ 0.1
|
2022-07-19 13:17:35 +00:00
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
2022-08-03 12:51:47 +00:00
|
|
|
import StatusQ.Components 0.1
|
2022-07-19 13:17:35 +00:00
|
|
|
import StatusQ.Core.Theme 0.1
|
2023-04-26 15:53:49 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as StatusQUtils
|
2024-04-10 20:56:10 +00:00
|
|
|
import StatusQ.Popups 0.1
|
2022-07-19 13:17:35 +00:00
|
|
|
|
2024-03-13 17:38:16 +00:00
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
|
2021-09-28 15:04:06 +00:00
|
|
|
import utils 1.0
|
2021-10-05 20:50:22 +00:00
|
|
|
|
|
|
|
import "../controls"
|
2024-07-02 23:31:34 +00:00
|
|
|
import "../stores"
|
2020-05-28 13:49:28 +00:00
|
|
|
|
|
|
|
Item {
|
2022-07-19 13:17:35 +00:00
|
|
|
id: root
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2023-03-15 09:17:25 +00:00
|
|
|
property var networkConnectionStore
|
2023-04-13 09:59:17 +00:00
|
|
|
property var overview
|
2022-01-31 13:29:27 +00:00
|
|
|
property var store
|
2022-02-15 13:19:45 +00:00
|
|
|
property var walletStore
|
2020-06-03 19:59:18 +00:00
|
|
|
|
2023-12-26 10:19:41 +00:00
|
|
|
property alias headerButton: headerButton
|
|
|
|
property alias networkFilter: networkFilter
|
|
|
|
|
|
|
|
signal buttonClicked()
|
2023-04-26 15:53:49 +00:00
|
|
|
|
2022-09-13 16:17:54 +00:00
|
|
|
implicitHeight: 88
|
2020-05-28 13:49:28 +00:00
|
|
|
|
2022-07-19 13:17:35 +00:00
|
|
|
GridLayout {
|
|
|
|
width: parent.width
|
|
|
|
columns: 2
|
2023-04-26 15:53:49 +00:00
|
|
|
rowSpacing: 0
|
2020-05-28 13:49:28 +00:00
|
|
|
|
2022-07-19 13:17:35 +00:00
|
|
|
// account + balance
|
2022-09-13 16:17:54 +00:00
|
|
|
RowLayout {
|
2022-07-19 13:17:35 +00:00
|
|
|
spacing: Style.current.halfPadding
|
|
|
|
StatusBaseText {
|
2023-12-26 15:27:53 +00:00
|
|
|
objectName: "walletHeaderTitle"
|
2022-09-13 16:17:54 +00:00
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2023-04-26 15:53:49 +00:00
|
|
|
verticalAlignment: Text.AlignVCenter
|
2023-12-26 10:19:41 +00:00
|
|
|
color: {
|
|
|
|
if (root.walletStore.showSavedAddresses)
|
|
|
|
return Theme.palette.directColor1
|
|
|
|
|
|
|
|
return overview.isAllAccounts ? Theme.palette.directColor5 : Utils.getColorForId(overview.colorId)
|
|
|
|
}
|
2023-04-26 15:53:49 +00:00
|
|
|
lineHeightMode: Text.FixedHeight
|
|
|
|
lineHeight: 38
|
2022-07-19 13:17:35 +00:00
|
|
|
font.bold: true
|
2023-04-26 15:53:49 +00:00
|
|
|
font.pixelSize: 28
|
2023-12-26 10:19:41 +00:00
|
|
|
text: {
|
|
|
|
if (root.walletStore.showSavedAddresses)
|
|
|
|
return qsTr("Saved addresses")
|
|
|
|
|
2024-05-27 09:35:07 +00:00
|
|
|
return overview.isAllAccounts ? qsTr("All accounts") : overview.name
|
2023-12-26 10:19:41 +00:00
|
|
|
}
|
2022-07-19 13:17:35 +00:00
|
|
|
}
|
2023-04-26 15:53:49 +00:00
|
|
|
StatusEmoji {
|
2022-09-13 16:17:54 +00:00
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2023-04-26 15:53:49 +00:00
|
|
|
Layout.preferredWidth: 28
|
|
|
|
Layout.preferredHeight: 28
|
2023-12-26 10:19:41 +00:00
|
|
|
emojiId: !!root.overview && StatusQUtils.Emoji.iconId(root.overview.emoji ?? "", StatusQUtils.Emoji.size.big) || ""
|
|
|
|
visible: !root.walletStore.showSavedAddresses &&
|
|
|
|
!!root.overview && !root.overview.isAllAccounts
|
2022-07-19 13:17:35 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-28 13:49:28 +00:00
|
|
|
|
2023-04-26 15:53:49 +00:00
|
|
|
RowLayout {
|
|
|
|
spacing: 16
|
2022-07-19 13:17:35 +00:00
|
|
|
Layout.alignment: Qt.AlignTrailing
|
2023-04-26 15:53:49 +00:00
|
|
|
Layout.topMargin: 5
|
2024-07-02 23:31:34 +00:00
|
|
|
Row {
|
|
|
|
Layout.alignment: Qt.AlignRight | Qt.AlignTop
|
|
|
|
Layout.preferredHeight: 38
|
|
|
|
spacing: 8
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
id: reloadButton
|
|
|
|
size: StatusBaseButton.Size.Tiny
|
|
|
|
loadingIndicatorSize: size
|
|
|
|
height: parent.height
|
|
|
|
width: height
|
|
|
|
borderColor: Theme.palette.directColor7
|
|
|
|
borderWidth: 1
|
|
|
|
|
|
|
|
normalColor: Theme.palette.transparent
|
|
|
|
hoverColor: Theme.palette.baseColor2
|
|
|
|
|
|
|
|
icon.name: "refresh"
|
2024-07-11 08:16:26 +00:00
|
|
|
icon.color: {
|
|
|
|
if (!interactive) {
|
|
|
|
return Theme.palette.baseColor1;
|
|
|
|
}
|
|
|
|
if (hovered) {
|
|
|
|
return Theme.palette.directColor1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Theme.palette.baseColor1;
|
|
|
|
}
|
2024-07-02 23:31:34 +00:00
|
|
|
asset.mirror: true
|
|
|
|
|
|
|
|
loading: RootStore.isAccountTokensReloading
|
|
|
|
interactive: !loading && !throttleTimer.running
|
|
|
|
readonly property string lastReloadTimeFormated: !!RootStore.lastReloadTimestamp ?
|
|
|
|
LocaleUtils.formatRelativeTimestamp(
|
|
|
|
RootStore.lastReloadTimestamp * 1000) : ""
|
|
|
|
tooltip.text: qsTr("Last refreshed %1").arg(lastReloadTimeFormated)
|
|
|
|
|
|
|
|
onClicked: RootStore.walletSectionInst.reloadAccountTokens()
|
|
|
|
|
|
|
|
Timer {
|
|
|
|
id: throttleTimer
|
|
|
|
interval: 1000*60 //throttle for 1 min
|
|
|
|
running: true // Start the timer immediately to disable manual reload initially, as automatic refresh is performed upon entering the wallet.
|
|
|
|
}
|
|
|
|
|
|
|
|
onLastReloadTimeFormatedChanged: {
|
|
|
|
// Start the throttle timer whenever the tokens are reloaded,
|
|
|
|
// which can be triggered by either automatic or manual reload.
|
|
|
|
throttleTimer.restart()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-04-05 11:10:44 +00:00
|
|
|
|
2024-05-06 17:55:11 +00:00
|
|
|
DAppsWorkflow {
|
2024-04-10 20:56:10 +00:00
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
|
|
|
|
spacing: 8
|
2024-05-01 16:15:42 +00:00
|
|
|
|
2024-05-06 17:55:11 +00:00
|
|
|
visible: !root.walletStore.showSavedAddresses && Global.featureFlags.dappsEnabled
|
2024-05-06 20:22:43 +00:00
|
|
|
enabled: !!Global.walletConnectService
|
|
|
|
|
|
|
|
wcService: Global.walletConnectService
|
2024-07-11 21:00:15 +00:00
|
|
|
loginType: root.store.loginType
|
|
|
|
selectedAccountAddress: root.walletStore.selectedAddress
|
2024-04-10 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
2023-04-26 15:53:49 +00:00
|
|
|
StatusButton {
|
2023-12-26 10:19:41 +00:00
|
|
|
id: headerButton
|
2023-12-26 15:27:53 +00:00
|
|
|
objectName: "walletHeaderButton"
|
2023-04-26 15:53:49 +00:00
|
|
|
Layout.preferredHeight: 38
|
|
|
|
Layout.alignment: Qt.AlignTop
|
2023-03-08 13:44:47 +00:00
|
|
|
|
2023-04-26 15:53:49 +00:00
|
|
|
spacing: 8
|
|
|
|
size: StatusBaseButton.Size.Small
|
2023-12-26 10:19:41 +00:00
|
|
|
borderColor: root.walletStore.showSavedAddresses? "transparent" : Theme.palette.directColor7
|
|
|
|
normalColor: root.walletStore.showSavedAddresses? Theme.palette.primaryColor3 : Theme.palette.transparent
|
|
|
|
hoverColor: root.walletStore.showSavedAddresses? Theme.palette.primaryColor2 : Theme.palette.baseColor2
|
2023-04-26 15:53:49 +00:00
|
|
|
|
2023-12-26 10:19:41 +00:00
|
|
|
font.weight: root.walletStore.showSavedAddresses? Font.Medium : Font.Normal
|
2023-04-26 15:53:49 +00:00
|
|
|
textPosition: StatusBaseButton.TextPosition.Left
|
2023-12-26 10:19:41 +00:00
|
|
|
textColor: root.walletStore.showSavedAddresses? Theme.palette.primaryColor1 : Theme.palette.baseColor1
|
2023-04-26 15:53:49 +00:00
|
|
|
|
2023-12-26 10:19:41 +00:00
|
|
|
icon.name: root.walletStore.showSavedAddresses? "" : "invite-users"
|
2023-04-26 15:53:49 +00:00
|
|
|
icon.height: 16
|
|
|
|
icon.width: 16
|
|
|
|
icon.color: hovered ? Theme.palette.directColor1 : Theme.palette.baseColor1
|
2023-04-05 11:10:44 +00:00
|
|
|
}
|
2020-05-28 13:49:28 +00:00
|
|
|
|
2023-04-26 15:53:49 +00:00
|
|
|
// network filter
|
|
|
|
NetworkFilter {
|
|
|
|
id: networkFilter
|
|
|
|
|
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
|
2024-03-13 17:38:16 +00:00
|
|
|
flatNetworks: walletStore.filteredFlatModel
|
2024-06-15 21:33:12 +00:00
|
|
|
onToggleNetwork: walletStore.toggleNetwork(chainId)
|
2023-04-26 15:53:49 +00:00
|
|
|
|
2024-06-15 21:33:12 +00:00
|
|
|
Binding on selection {
|
|
|
|
value: chainIdsAggregator.value
|
|
|
|
}
|
|
|
|
|
|
|
|
FunctionAggregator {
|
|
|
|
id: chainIdsAggregator
|
|
|
|
|
|
|
|
readonly property SortFilterProxyModel enabledNetworksModel: SortFilterProxyModel{
|
|
|
|
sourceModel: walletStore.filteredFlatModel
|
|
|
|
filters: ValueFilter {
|
|
|
|
roleName: "isEnabled"
|
|
|
|
value: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
model: enabledNetworksModel
|
|
|
|
initialValue: []
|
|
|
|
roleName: "chainId"
|
|
|
|
|
|
|
|
aggregateFunction: (aggr, value) => [...aggr, value]
|
|
|
|
}
|
2023-04-26 15:53:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
spacing: 4
|
2023-12-26 10:19:41 +00:00
|
|
|
visible: !root.walletStore.showSavedAddresses &&
|
|
|
|
!!root.networkConnectionStore &&
|
|
|
|
!networkConnectionStore.accountBalanceNotAvailable
|
2023-04-26 15:53:49 +00:00
|
|
|
StatusTextWithLoadingState {
|
|
|
|
font.pixelSize: 28
|
|
|
|
font.bold: true
|
|
|
|
customColor: Theme.palette.directColor1
|
2023-12-26 10:19:41 +00:00
|
|
|
text: loading ?
|
|
|
|
Constants.dummyText :
|
|
|
|
!!root.overview?
|
|
|
|
LocaleUtils.currencyAmountToLocaleString(root.overview.currencyBalance) : ""
|
|
|
|
loading: !!root.overview && root.overview.balanceLoading
|
2023-04-26 15:53:49 +00:00
|
|
|
lineHeightMode: Text.FixedHeight
|
|
|
|
lineHeight: 38
|
|
|
|
}
|
2022-07-19 13:17:35 +00:00
|
|
|
}
|
2022-02-15 13:19:45 +00:00
|
|
|
}
|
2022-07-19 13:17:35 +00:00
|
|
|
}
|