2022-03-23 11:08:49 +00:00
import QtQuick 2.14
import QtQuick . Controls 2.14
import QtQuick . Layouts 1.13
2024-07-17 16:07:57 +00:00
import QtQml 2.15
2022-03-23 11:08:49 +00:00
2024-07-17 14:55:52 +00:00
import StatusQ 0.1
2022-03-23 11:08:49 +00:00
import StatusQ . Popups 0.1
import StatusQ . Controls 0.1
2022-03-18 14:47:51 +00:00
import StatusQ . Core . Theme 0.1
2024-07-17 14:55:52 +00:00
import StatusQ . Core . Utils 0.1 as SQUtils
2022-03-23 11:08:49 +00:00
import utils 1.0
2023-04-04 11:31:04 +00:00
import shared . controls 1.0
2024-07-03 03:55:05 +00:00
import shared . stores . send 1.0
2022-03-23 11:08:49 +00:00
2023-03-15 09:17:25 +00:00
import "../controls"
2023-04-26 15:53:49 +00:00
import "../popups"
2022-03-23 11:08:49 +00:00
Rectangle {
2023-04-26 15:53:49 +00:00
id: root
2022-03-23 11:08:49 +00:00
2024-07-19 11:20:26 +00:00
readonly property alias anyActionAvailable: d . anyActionAvailable
2022-07-20 11:15:05 +00:00
property var walletStore
2023-03-15 09:17:25 +00:00
property var networkConnectionStore
2024-07-03 03:55:05 +00:00
required property TransactionStore transactionStore
2022-03-23 11:08:49 +00:00
2023-09-20 13:01:37 +00:00
// Community-token related properties:
required property bool isCommunityOwnershipTransfer
property string communityName: ""
2023-04-26 15:53:49 +00:00
signal launchShareAddressModal ( )
2024-07-19 11:20:26 +00:00
signal launchSendModal ( string fromAddress )
2023-08-31 10:27:15 +00:00
signal launchBridgeModal ( )
2024-05-13 17:23:01 +00:00
signal launchSwapModal ( )
2023-04-26 15:53:49 +00:00
2022-03-23 11:08:49 +00:00
color: Theme . palette . statusAppLayout . rightPanelBackgroundColor
2024-04-09 14:16:03 +00:00
QtObject {
id: d
2024-05-13 17:23:01 +00:00
readonly property bool isCollectibleViewed: ! ! walletStore . currentViewedHoldingID &&
( walletStore . currentViewedHoldingType === Constants . TokenType . ERC721 ||
walletStore . currentViewedHoldingType === Constants . TokenType . ERC1155 )
readonly property bool isCollectibleSoulbound: isCollectibleViewed && ! ! walletStore . currentViewedCollectible && walletStore . currentViewedCollectible . soulbound
2024-07-17 14:55:52 +00:00
2024-07-19 11:20:26 +00:00
readonly property var collectibleOwnership: isCollectibleViewed && walletStore . currentViewedCollectible ?
walletStore.currentViewedCollectible.ownership : null
2024-07-17 14:55:52 +00:00
2024-07-19 11:20:26 +00:00
readonly property string userOwnedAddressForCollectible: ! ! walletStore . currentViewedHoldingID ? getFirstUserOwnedAddress ( collectibleOwnership , root . walletStore . nonWatchAccounts ) : ""
2024-07-17 14:55:52 +00:00
2024-07-19 11:20:26 +00:00
readonly property bool hideCollectibleTransferActions: isCollectibleViewed && ! userOwnedAddressForCollectible
/// Actions available
readonly property bool anyActionAvailable: sendActionAvailable
|| receiveActionAvailable
|| bridgeActionAvailable
|| buyActionAvailable
|| swapActionAvailable
readonly property bool sendActionAvailable: ! walletStore . overview . isWatchOnlyAccount
&& walletStore . overview . canSend
&& ! d . hideCollectibleTransferActions
readonly property bool receiveActionAvailable: ! walletStore . showAllAccounts
2024-07-17 14:55:52 +00:00
2024-07-19 11:20:26 +00:00
readonly property bool bridgeActionAvailable: ! walletStore . overview . isWatchOnlyAccount
&& ! root . isCommunityOwnershipTransfer
&& walletStore . overview . canSend
&& ! root . walletStore . showAllAccounts
&& ! d . hideCollectibleTransferActions
readonly property bool buyActionAvailable: ! root . isCommunityOwnershipTransfer && ! root . walletStore . showAllAccounts
2024-07-31 14:02:03 +00:00
readonly property bool swapActionAvailable: Global . featureFlags . swapEnabled && ! walletStore . overview . isWatchOnlyAccount && walletStore . overview . canSend && ! d . hideCollectibleTransferActions
2024-07-19 11:20:26 +00:00
function getFirstUserOwnedAddress ( ownershipModel , accountsModel ) {
if ( ! ownershipModel ) return ""
for ( let i = 0 ; i < ownershipModel . rowCount ( ) ; i ++ ) {
const accountAddress = SQUtils . ModelUtils . get ( ownershipModel , i , "accountAddress" )
if ( SQUtils . ModelUtils . contains ( accountsModel , "address" , accountAddress , Qt . CaseInsensitive ) )
return accountAddress
}
return ""
2024-07-17 14:55:52 +00:00
}
2024-04-09 14:16:03 +00:00
}
2022-03-23 11:08:49 +00:00
StatusModalDivider {
anchors.top: parent . top
width: parent . width
}
RowLayout {
2024-07-19 11:20:26 +00:00
id: layout
2022-03-23 11:08:49 +00:00
anchors.centerIn: parent
2022-03-28 08:19:57 +00:00
height: parent . height
2024-07-19 11:20:26 +00:00
width: Math . min ( root . width , implicitWidth )
2022-03-23 11:08:49 +00:00
spacing: Style . current . padding
2024-03-12 15:44:27 +00:00
StatusFlatButton {
2024-07-19 11:20:26 +00:00
id: sendButton
2024-07-17 16:07:57 +00:00
Layout.fillWidth: true
Layout.maximumWidth: implicitWidth
2024-03-12 15:44:27 +00:00
objectName: "walletFooterSendButton"
icon.name: "send"
2023-09-20 13:01:37 +00:00
text: root . isCommunityOwnershipTransfer ? qsTr ( "Send Owner token to transfer %1 Community ownership" ) . arg ( root . communityName ) : qsTr ( "Send" )
2024-04-09 14:16:03 +00:00
interactive: ! d . isCollectibleSoulbound && networkConnectionStore . sendBuyBridgeEnabled
2024-07-03 03:55:05 +00:00
onClicked: {
2024-07-19 11:20:26 +00:00
root . transactionStore . setSenderAccount ( root . walletStore . selectedAddress )
root . launchSendModal ( d . userOwnedAddressForCollectible )
2024-07-03 03:55:05 +00:00
}
2024-04-09 14:16:03 +00:00
tooltip.text: d . isCollectibleSoulbound ? qsTr ( "Soulbound collectibles cannot be sent to another wallet" ) : networkConnectionStore . sendBuyBridgeToolTipText
2024-07-19 11:20:26 +00:00
visible: d . sendActionAvailable
2022-03-23 11:08:49 +00:00
}
StatusFlatButton {
icon.name: "receive"
2022-04-04 11:26:30 +00:00
text: qsTr ( "Receive" )
2024-07-19 11:20:26 +00:00
visible: d . receiveActionAvailable
2022-03-23 11:08:49 +00:00
onClicked: function ( ) {
2024-07-03 03:55:05 +00:00
root . transactionStore . setReceiverAccount ( root . walletStore . selectedAddress )
2023-04-26 15:53:49 +00:00
launchShareAddressModal ( )
2022-03-23 11:08:49 +00:00
}
}
2024-03-12 15:44:27 +00:00
StatusFlatButton {
icon.name: "bridge"
2023-04-04 11:31:04 +00:00
text: qsTr ( "Bridge" )
2024-05-13 17:23:01 +00:00
interactive: ! d . isCollectibleSoulbound && networkConnectionStore . sendBuyBridgeEnabled
2023-08-31 10:27:15 +00:00
onClicked: root . launchBridgeModal ( )
2024-05-13 17:23:01 +00:00
tooltip.text: d . isCollectibleSoulbound ? qsTr ( "Soulbound collectibles cannot be bridged to another wallet" ) : networkConnectionStore . sendBuyBridgeToolTipText
2024-07-19 11:20:26 +00:00
visible: d . bridgeActionAvailable
2022-11-23 17:58:22 +00:00
}
2024-02-02 09:55:56 +00:00
2022-12-13 13:42:52 +00:00
StatusFlatButton {
id: buySellBtn
2023-09-20 13:01:37 +00:00
2024-07-19 11:20:26 +00:00
visible: d . buyActionAvailable
2022-12-13 13:42:52 +00:00
icon.name: "token"
text: qsTr ( "Buy" )
2024-05-27 16:55:43 +00:00
onClicked: Global . openBuyCryptoModalRequested ( )
2024-07-17 16:07:57 +00:00
}
2024-05-07 14:18:08 +00:00
StatusFlatButton {
id: swap
2024-08-03 07:49:14 +00:00
interactive: ! d . isCollectibleViewed && networkConnectionStore . sendBuyBridgeEnabled
2024-07-19 11:20:26 +00:00
visible: d . swapActionAvailable
2024-08-03 07:49:14 +00:00
tooltip.text: d . isCollectibleViewed ? qsTr ( "Collectibles cannot be swapped" ) : networkConnectionStore . sendBuyBridgeToolTipText
2024-05-07 14:18:08 +00:00
icon.name: "swap"
text: qsTr ( "Swap" )
2024-05-13 17:23:01 +00:00
onClicked: root . launchSwapModal ( )
2022-12-13 13:42:52 +00:00
}
2022-03-23 11:08:49 +00:00
}
}