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
|
2024-06-07 12:27:56 +00:00
|
|
|
import shared.controls 1.0 as SharedControls
|
2022-03-18 14:47:51 +00:00
|
|
|
import shared.stores 1.0
|
2024-07-02 11:19:37 +00:00
|
|
|
import shared.popups.send 1.0
|
2022-03-18 14:47:51 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
import "../controls"
|
|
|
|
import "../views"
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
|
2024-07-02 11:19:37 +00:00
|
|
|
property var savedAddressesModel
|
|
|
|
property var myAccountsModel
|
|
|
|
property var recentRecipientsModel
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2024-07-02 11:19:37 +00:00
|
|
|
readonly property bool recentRecipientsTabVisible: recipientTypeTabBar.currentIndex === 2 // Recent tab
|
|
|
|
|
|
|
|
// This should only pass a `key` role to identify the object but not necessary to pass the complete object structure
|
|
|
|
// TODO issue: #15492
|
2023-04-18 16:05:24 +00:00
|
|
|
signal recipientSelected(var recipient, int type)
|
2024-07-02 11:19:37 +00:00
|
|
|
signal recentRecipientsTabSelected
|
2023-04-18 16:05:24 +00:00
|
|
|
|
|
|
|
enum Type {
|
|
|
|
Address,
|
|
|
|
Account,
|
|
|
|
SavedAddress,
|
|
|
|
RecentsAddress,
|
|
|
|
None
|
|
|
|
}
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2022-05-23 11:45:29 +00:00
|
|
|
StatusTabBar {
|
2024-07-02 11:19:37 +00:00
|
|
|
id: recipientTypeTabBar
|
2024-07-11 07:39:32 +00:00
|
|
|
objectName: "recipientTypeTabBar"
|
2024-07-02 11:19:37 +00:00
|
|
|
|
2022-03-18 14:47:51 +00:00
|
|
|
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 {
|
2022-05-23 11:45:29 +00:00
|
|
|
width: implicitWidth
|
2024-07-02 11:19:37 +00:00
|
|
|
objectName: "savedAddressesTab"
|
2022-05-23 11:45:29 +00:00
|
|
|
text: qsTr("Saved")
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
StatusTabButton {
|
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 {
|
2022-05-23 11:45:29 +00:00
|
|
|
width: implicitWidth
|
2024-07-02 11:19:37 +00:00
|
|
|
objectName: "recentAddressesTab"
|
2022-05-23 11:45:29 +00:00
|
|
|
text: qsTr("Recent")
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-12 16:44:35 +00:00
|
|
|
// To-do adapt to new design and make block white/black once the list items etc support new color scheme
|
|
|
|
Rectangle {
|
2024-07-02 11:19:37 +00:00
|
|
|
anchors.top: recipientTypeTabBar.bottom
|
2023-04-18 16:05:24 +00:00
|
|
|
anchors.topMargin: -5
|
2024-07-02 11:19:37 +00:00
|
|
|
height: parent.height - recipientTypeTabBar.height
|
2022-03-18 14:47:51 +00:00
|
|
|
width: parent.width
|
2024-02-12 16:44:35 +00:00
|
|
|
color: Theme.palette.indirectColor1
|
|
|
|
radius: 8
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2024-02-12 16:44:35 +00:00
|
|
|
StackLayout {
|
2024-07-02 11:19:37 +00:00
|
|
|
currentIndex: recipientTypeTabBar.currentIndex
|
2024-02-12 16:44:35 +00:00
|
|
|
anchors.fill: parent
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
StatusListView {
|
2022-03-18 14:47:51 +00:00
|
|
|
id: savedAddresses
|
2024-07-02 11:19:37 +00:00
|
|
|
objectName: "savedAddressesList"
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2024-07-02 11:19:37 +00:00
|
|
|
model: root.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)
|
2024-07-02 11:19:37 +00:00
|
|
|
// This should only pass a `key` role to identify the saved addresses object but not necessary to pass the complete object structure
|
|
|
|
// TODO issue: #15492
|
|
|
|
onClicked: recipientSelected(modelData, Helpers.RecipientAddressObjectType.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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2024-06-07 12:27:56 +00:00
|
|
|
delegate: SharedControls.WalletAccountListItem {
|
|
|
|
required property var model
|
|
|
|
|
2023-04-18 16:05:24 +00:00
|
|
|
implicitWidth: ListView.view.width
|
2024-06-07 12:27:56 +00:00
|
|
|
name: model.name
|
|
|
|
address: model.address
|
|
|
|
|
|
|
|
emoji: model.emoji
|
|
|
|
walletColor: Utils.getColorForId(model.colorId)
|
|
|
|
currencyBalance: model.currencyBalance
|
|
|
|
walletType: model.walletType
|
|
|
|
migratedToKeycard: model.migratedToKeycard ?? false
|
|
|
|
accountBalance: model.accountBalance ?? null
|
2024-07-02 11:19:37 +00:00
|
|
|
chainShortNames: model.colorizedChainShortNames ?? ""
|
|
|
|
// This should only pass a `key` role to identify the accounts object but not necessary to pass the complete object structure
|
|
|
|
// TODO issue: #15492
|
2024-06-07 12:27:56 +00:00
|
|
|
onClicked: recipientSelected({name: model.name,
|
|
|
|
address: model.address,
|
2024-07-02 11:19:37 +00:00
|
|
|
color: model.color,
|
2024-07-08 18:07:29 +00:00
|
|
|
colorId: model.colorId,
|
2024-06-07 12:27:56 +00:00
|
|
|
emoji: model.emoji,
|
|
|
|
walletType: model.walletType,
|
|
|
|
currencyBalance: model.currencyBalance,
|
2024-07-08 18:07:29 +00:00
|
|
|
preferredSharingChainIds: model.preferredSharingChainIds,
|
|
|
|
migratedToKeycard: model.migratedToKeycard
|
|
|
|
},
|
2024-07-02 11:19:37 +00:00
|
|
|
Helpers.RecipientAddressObjectType.Account)
|
2022-03-18 14:47:51 +00:00
|
|
|
|
2024-07-02 11:19:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
model: root.myAccountsModel
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
2023-06-29 17:35:18 +00:00
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
StatusListView {
|
2022-03-18 14:47:51 +00:00
|
|
|
id: recents
|
2024-07-02 11:19:37 +00:00
|
|
|
objectName: "recentReceiversList"
|
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
|
|
|
}
|
|
|
|
]
|
2024-07-02 11:19:37 +00:00
|
|
|
// This should only pass a `key` role to identify the recent activity object but not necessary to pass the complete object structure
|
|
|
|
// TODO issue: #15492
|
|
|
|
onClicked: recipientSelected(entry, Helpers.RecipientAddressObjectType.RecentsAddress)
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
|
2024-07-02 11:19:37 +00:00
|
|
|
model: root.recentRecipientsModel
|
2024-02-12 16:44:35 +00:00
|
|
|
|
|
|
|
onVisibleChanged: {
|
|
|
|
if (visible) {
|
2024-07-02 11:19:37 +00:00
|
|
|
root.recentRecipientsTabSelected()
|
2024-02-12 16:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
2022-03-18 14:47:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|