2022-03-18 14:47:51 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
import QtQuick.Dialogs 1.3
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
import shared.stores 1.0
|
|
|
|
|
2023-04-18 16:05:24 +00:00
|
|
|
import AppLayouts.Wallet 1.0
|
|
|
|
|
2022-03-18 14:47:51 +00:00
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2023-04-18 16:05:24 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as StatusQUtils
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2023-06-29 17:35:18 +00:00
|
|
|
import utils 1.0
|
|
|
|
|
2022-03-18 14:47:51 +00:00
|
|
|
import "../panels"
|
|
|
|
import "../controls"
|
|
|
|
import "../views"
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
clip: true
|
2023-05-10 11:19:25 +00:00
|
|
|
implicitHeight: visible ? accountSelectionTabBar.height + stackLayout.height : 0
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2023-04-06 12:59:24 +00:00
|
|
|
property var selectedAccount
|
2022-03-18 14:47:51 +00:00
|
|
|
property var store
|
|
|
|
|
2023-04-18 16:05:24 +00:00
|
|
|
signal recipientSelected(var recipient, int type)
|
|
|
|
|
|
|
|
enum Type {
|
|
|
|
Address,
|
|
|
|
Contact,
|
|
|
|
Account,
|
|
|
|
SavedAddress,
|
|
|
|
RecentsAddress,
|
|
|
|
None
|
|
|
|
}
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2022-05-23 11:45:29 +00:00
|
|
|
StatusTabBar {
|
2022-03-18 14:47:51 +00:00
|
|
|
id: accountSelectionTabBar
|
|
|
|
anchors.top: parent.top
|
2022-07-14 17:47:59 +00:00
|
|
|
anchors.left: parent.left
|
2022-03-18 14:47:51 +00:00
|
|
|
width: parent.width
|
2023-05-10 11:19:25 +00:00
|
|
|
|
2022-03-18 14:47:51 +00:00
|
|
|
StatusTabButton {
|
|
|
|
id: assetBtn
|
2022-05-23 11:45:29 +00:00
|
|
|
width: implicitWidth
|
|
|
|
text: qsTr("Saved")
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
StatusTabButton {
|
|
|
|
id: collectiblesBtn
|
2022-05-23 11:45:29 +00:00
|
|
|
width: implicitWidth
|
2022-07-21 12:15:02 +00:00
|
|
|
objectName: "myAccountsTab"
|
2022-05-23 11:45:29 +00:00
|
|
|
text: qsTr("My Accounts")
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
StatusTabButton {
|
|
|
|
id: historyBtn
|
2022-05-23 11:45:29 +00:00
|
|
|
width: implicitWidth
|
|
|
|
text: qsTr("Recent")
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StackLayout {
|
|
|
|
id: stackLayout
|
|
|
|
anchors.top: accountSelectionTabBar.bottom
|
2023-04-18 16:05:24 +00:00
|
|
|
anchors.topMargin: -5
|
2022-04-11 18:59:49 +00:00
|
|
|
height: currentIndex === 0 ? savedAddresses.height: currentIndex === 1 ? myAccounts.height : recents.height
|
2022-03-18 14:47:51 +00:00
|
|
|
width: parent.width
|
|
|
|
currentIndex: accountSelectionTabBar.currentIndex
|
|
|
|
|
|
|
|
// To-do adapt to new design and make block white/balck once the list items etc support new color scheme
|
|
|
|
Rectangle {
|
2022-04-11 18:59:49 +00:00
|
|
|
Layout.maximumWidth: parent.width
|
|
|
|
Layout.maximumHeight : savedAddresses.height
|
2022-07-20 14:13:23 +00:00
|
|
|
color: Theme.palette.indirectColor1
|
2022-03-18 14:47:51 +00:00
|
|
|
radius: 8
|
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
StatusListView {
|
2022-03-18 14:47:51 +00:00
|
|
|
id: savedAddresses
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.top: parent.top
|
2022-07-20 14:13:23 +00:00
|
|
|
implicitWidth: parent.width
|
2023-05-10 11:19:25 +00:00
|
|
|
height: savedAddresses.contentHeight
|
2022-03-18 14:47:51 +00:00
|
|
|
|
|
|
|
model: root.store.savedAddressesModel
|
2023-04-18 16:05:24 +00:00
|
|
|
header: savedAddresses.count > 0 ? search : nothingInList
|
2022-03-18 14:47:51 +00:00
|
|
|
headerPositioning: ListView.OverlayHeader
|
2023-04-18 16:05:24 +00:00
|
|
|
delegate: SavedAddressListItem {
|
|
|
|
implicitWidth: ListView.view.width
|
|
|
|
modelData: model
|
2022-03-18 14:47:51 +00:00
|
|
|
visible: !savedAddresses.headerItem.text || name.toLowerCase().includes(savedAddresses.headerItem.text)
|
2023-04-18 16:05:24 +00:00
|
|
|
onClicked: recipientSelected(modelData, TabAddressSelectorView.Type.SavedAddress)
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
Component {
|
|
|
|
id: search
|
2023-04-18 16:05:24 +00:00
|
|
|
SearchBoxWithRightIcon {
|
2022-03-18 14:47:51 +00:00
|
|
|
width: parent.width
|
2023-04-18 16:05:24 +00:00
|
|
|
placeholderText: qsTr("Search for saved address")
|
|
|
|
z: 2
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Component {
|
|
|
|
id: nothingInList
|
|
|
|
StatusBaseText {
|
2022-07-20 14:13:23 +00:00
|
|
|
width: savedAddresses.width
|
|
|
|
height: visible ? 56 : 0
|
2022-03-18 14:47:51 +00:00
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
text: qsTr("No Saved Address")
|
2022-07-20 14:13:23 +00:00
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Rectangle {
|
2022-04-11 18:59:49 +00:00
|
|
|
id: myAccountsRect
|
|
|
|
Layout.maximumWidth: parent.width
|
2023-06-29 17:35:18 +00:00
|
|
|
Layout.maximumHeight: myAccounts.height
|
2022-07-20 14:13:23 +00:00
|
|
|
color: Theme.palette.indirectColor1
|
2022-03-18 14:47:51 +00:00
|
|
|
radius: 8
|
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
StatusListView {
|
2022-03-18 14:47:51 +00:00
|
|
|
id: myAccounts
|
2022-07-21 12:15:02 +00:00
|
|
|
objectName: "myAccountsList"
|
2022-03-18 14:47:51 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.top: parent.top
|
|
|
|
width: parent.width
|
2023-05-10 11:19:25 +00:00
|
|
|
height: myAccounts.contentHeight
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2023-04-18 16:05:24 +00:00
|
|
|
delegate: WalletAccountListItem {
|
|
|
|
implicitWidth: ListView.view.width
|
|
|
|
modelData: model
|
2023-04-26 15:53:49 +00:00
|
|
|
chainShortNames: root.store.getAllNetworksSupportedPrefix()
|
2023-05-04 12:55:39 +00:00
|
|
|
onClicked: recipientSelected({name: modelData.name,
|
|
|
|
address: modelData.address,
|
|
|
|
color: modelData.color,
|
|
|
|
emoji: modelData.emoji,
|
|
|
|
walletType: modelData.walletType,
|
|
|
|
currencyBalance: modelData.currencyBalance}, TabAddressSelectorView.Type.Account )
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
model: root.store.accounts
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
2023-06-29 17:35:18 +00:00
|
|
|
id: recentsRect
|
2022-04-11 18:59:49 +00:00
|
|
|
Layout.maximumWidth: parent.width
|
|
|
|
Layout.maximumHeight : recents.height
|
2022-07-20 14:13:23 +00:00
|
|
|
color: Theme.palette.indirectColor1
|
2022-03-18 14:47:51 +00:00
|
|
|
radius: 8
|
|
|
|
|
2023-06-29 17:35:18 +00:00
|
|
|
onVisibleChanged: {
|
|
|
|
if (visible) {
|
|
|
|
updateRecentsActivity()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: root
|
|
|
|
function onSelectedAccountChanged() {
|
|
|
|
if (visible) {
|
|
|
|
recentsRect.updateRecentsActivity()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateRecentsActivity() {
|
|
|
|
if(root.selectedAccount) {
|
|
|
|
root.store.tmpActivityController.setFilterAddressesJson(JSON.stringify([root.selectedAccount.address]))
|
|
|
|
}
|
|
|
|
root.store.tmpActivityController.updateFilter()
|
|
|
|
}
|
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
StatusListView {
|
2022-03-18 14:47:51 +00:00
|
|
|
id: recents
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.top: parent.top
|
|
|
|
width: parent.width
|
2023-05-10 11:19:25 +00:00
|
|
|
height: recents.contentHeight
|
2022-03-18 14:47:51 +00:00
|
|
|
|
|
|
|
header: StatusBaseText {
|
2022-07-20 14:13:23 +00:00
|
|
|
height: visible ? 56 : 0
|
|
|
|
width: recents.width
|
2022-03-18 14:47:51 +00:00
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
text: qsTr("No Recents")
|
2022-07-20 14:13:23 +00:00
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
2022-03-18 14:47:51 +00:00
|
|
|
visible: recents.count <= 0
|
|
|
|
}
|
|
|
|
|
|
|
|
delegate: StatusListItem {
|
2023-04-18 16:05:24 +00:00
|
|
|
id: listItem
|
2023-06-29 17:35:18 +00:00
|
|
|
|
|
|
|
property var entry: activityEntry
|
|
|
|
property bool isIncoming: entry.txType === Constants.TransactionType.Receive
|
|
|
|
|
2023-04-18 16:05:24 +00:00
|
|
|
implicitWidth: ListView.view.width
|
2022-03-18 14:47:51 +00:00
|
|
|
height: visible ? 64 : 0
|
2023-06-29 17:35:18 +00:00
|
|
|
title: isIncoming ? StatusQUtils.Utils.elideText(entry.sender,6,4) : StatusQUtils.Utils.elideText(entry.recipient,6,4)
|
|
|
|
subTitle: LocaleUtils.getTimeDifference(new Date(parseInt(entry.timestamp) * 1000), new Date())
|
2022-03-18 14:47:51 +00:00
|
|
|
statusListItemTitle.elide: Text.ElideMiddle
|
|
|
|
statusListItemTitle.wrapMode: Text.NoWrap
|
|
|
|
radius: 0
|
2023-04-24 18:35:34 +00:00
|
|
|
color: sensor.containsMouse || highlighted ? Theme.palette.baseColor2 : "transparent"
|
2023-04-18 16:05:24 +00:00
|
|
|
statusListItemComponentsSlot.spacing: 5
|
2022-03-18 14:47:51 +00:00
|
|
|
components: [
|
|
|
|
StatusIcon {
|
|
|
|
id: transferIcon
|
|
|
|
height: 15
|
|
|
|
width: 15
|
2023-06-29 17:35:18 +00:00
|
|
|
color: listItem.isIncoming ? Style.current.success : Style.current.danger
|
|
|
|
icon: listItem.isIncoming ? "arrow-down" : "arrow-up"
|
2022-03-18 14:47:51 +00:00
|
|
|
rotation: 45
|
|
|
|
},
|
2023-04-18 16:05:24 +00:00
|
|
|
StatusTextWithLoadingState {
|
2022-03-18 14:47:51 +00:00
|
|
|
font.pixelSize: 15
|
2023-04-18 16:05:24 +00:00
|
|
|
customColor: Theme.palette.directColor1
|
2023-06-29 17:35:18 +00:00
|
|
|
text: LocaleUtils.currencyAmountToLocaleString(entry.amountCurrency)
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
]
|
2023-06-29 17:35:18 +00:00
|
|
|
onClicked: recipientSelected(entry, TabAddressSelectorView.Type.RecentsAddress)
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
|
2023-06-29 17:35:18 +00:00
|
|
|
model: root.store.tmpActivityController.model
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|