2021-03-08 19:24:39 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import QtGraphicalEffects 1.0
|
2021-09-28 15:04:06 +00:00
|
|
|
|
2023-01-12 22:39:46 +00:00
|
|
|
import StatusQ.Core 0.1
|
2024-05-20 12:18:44 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as SQUtils
|
2023-01-12 22:39:46 +00:00
|
|
|
|
2021-09-28 15:04:06 +00:00
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared 1.0
|
|
|
|
import shared.popups 1.0
|
|
|
|
import shared.status 1.0
|
2022-02-14 23:27:23 +00:00
|
|
|
import shared.stores 1.0 as SharedStores
|
2023-09-05 15:27:30 +00:00
|
|
|
import shared.popups.send 1.0
|
2023-11-28 19:16:18 +00:00
|
|
|
import shared.stores.send 1.0
|
2022-02-14 23:27:23 +00:00
|
|
|
|
|
|
|
//TODO remove this dependency!
|
|
|
|
import "../../../app/AppLayouts/Chat/stores"
|
2024-02-05 16:44:49 +00:00
|
|
|
import AppLayouts.Wallet.stores 1.0
|
2021-03-08 19:24:39 +00:00
|
|
|
|
2021-10-14 11:33:34 +00:00
|
|
|
// TODO: replace with StatusModal
|
2021-03-08 19:24:39 +00:00
|
|
|
ModalPopup {
|
|
|
|
id: stickerPackDetailsPopup
|
|
|
|
|
2023-04-12 10:31:35 +00:00
|
|
|
property string packId
|
2021-03-08 19:24:39 +00:00
|
|
|
|
2022-02-14 23:27:23 +00:00
|
|
|
property var store
|
2023-11-28 19:16:18 +00:00
|
|
|
required property TransactionStore transactionStore
|
2024-02-05 16:44:49 +00:00
|
|
|
required property WalletAssetsStore walletAssetsStore
|
2021-03-08 19:24:39 +00:00
|
|
|
property string thumbnail: ""
|
|
|
|
property string name: ""
|
|
|
|
property string author: ""
|
2023-04-12 19:08:42 +00:00
|
|
|
property string price
|
2021-03-08 19:24:39 +00:00
|
|
|
property bool installed: false;
|
|
|
|
property bool bought: false;
|
|
|
|
property bool pending: false;
|
|
|
|
property var stickers;
|
2023-04-12 10:31:35 +00:00
|
|
|
signal buyClicked(string packId)
|
2021-03-08 19:24:39 +00:00
|
|
|
|
|
|
|
Component.onCompleted: {
|
2021-11-25 17:12:19 +00:00
|
|
|
const idx = stickersModule.stickerPacks.findIndexById(packId, false);
|
2021-03-08 19:24:39 +00:00
|
|
|
if(idx === -1) close();
|
2024-05-20 12:18:44 +00:00
|
|
|
const item = SQUtils.ModelUtils.get(stickersModule.stickerPacks, idx)
|
|
|
|
name = item.name
|
|
|
|
author = item.author
|
|
|
|
thumbnail = item.thumbnail
|
|
|
|
price = item.price
|
2021-11-25 17:12:19 +00:00
|
|
|
stickers = stickersModule.stickerPacks.getStickers()
|
2024-05-20 12:18:44 +00:00
|
|
|
installed = item.installed
|
|
|
|
bought = item.bought
|
|
|
|
pending = item.pending
|
2021-03-08 19:24:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
height: 472
|
|
|
|
header: StatusStickerPackDetails {
|
|
|
|
id: stickerGrid
|
|
|
|
packThumb: thumbnail
|
|
|
|
packName: name
|
|
|
|
packAuthor: author
|
|
|
|
packNameFontSize: 17
|
|
|
|
spacing: Style.current.padding / 2
|
|
|
|
}
|
2021-03-26 21:21:50 +00:00
|
|
|
|
|
|
|
contentWrapper.anchors.topMargin: 0
|
|
|
|
contentWrapper.anchors.bottomMargin: 0
|
2023-04-12 12:15:39 +00:00
|
|
|
contentWrapper.anchors.rightMargin: 0
|
2021-03-26 21:21:50 +00:00
|
|
|
StatusStickerList {
|
|
|
|
id: stickerGridInPopup
|
|
|
|
model: stickers
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.topMargin: Style.current.padding
|
2021-12-08 21:20:43 +00:00
|
|
|
packId: stickerPackDetailsPopup.packId
|
2021-03-26 21:21:50 +00:00
|
|
|
Component {
|
|
|
|
id: stickerPackPurchaseModal
|
2022-10-17 10:17:25 +00:00
|
|
|
SendModal {
|
|
|
|
id: buyStickersPackModal
|
|
|
|
interactive: false
|
2023-11-28 19:16:18 +00:00
|
|
|
store: stickerPackDetailsPopup.transactionStore
|
2023-09-20 16:07:09 +00:00
|
|
|
preSelectedSendType: Constants.SendType.StickersBuy
|
2022-10-17 10:17:25 +00:00
|
|
|
preSelectedRecipient: stickerPackDetailsPopup.store.stickersStore.getStickersMarketAddress()
|
|
|
|
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(parseFloat(price))
|
2024-02-05 16:44:49 +00:00
|
|
|
preSelectedHoldingID: {
|
|
|
|
let token = ModelUtils.getByKey(root.walletAssetsStore.groupedAccountAssetsModel, "tokensKey", stickerPackDetailsPopup.store.stickersStore.getStatusTokenKey())
|
|
|
|
return !!token && !!token.symbol ? token.symbol : ""
|
|
|
|
}
|
2023-11-07 22:45:47 +00:00
|
|
|
preSelectedHoldingType: Constants.TokenType.ERC20
|
2022-10-17 10:17:25 +00:00
|
|
|
sendTransaction: function() {
|
2023-08-15 18:21:51 +00:00
|
|
|
if(bestRoutes.count === 1) {
|
|
|
|
let path = bestRoutes.firstItem()
|
2022-10-17 10:17:25 +00:00
|
|
|
let eip1559Enabled = path.gasFees.eip1559Enabled
|
2022-11-30 12:59:21 +00:00
|
|
|
let maxFeePerGas = path.gasFees.maxFeePerGasM
|
2022-10-17 10:17:25 +00:00
|
|
|
stickerPackDetailsPopup.store.stickersStore.authenticateAndBuy(packId,
|
2024-07-03 03:55:05 +00:00
|
|
|
store.selectedSenderAccountAddress,
|
2022-10-17 10:17:25 +00:00
|
|
|
path.gasAmount,
|
|
|
|
eip1559Enabled ? "" : path.gasFees.gasPrice,
|
|
|
|
eip1559Enabled ? path.gasFees.maxPriorityFeePerGas : "",
|
|
|
|
eip1559Enabled ? maxFeePerGas : path.gasFees.gasPrice,
|
|
|
|
eip1559Enabled)
|
|
|
|
}
|
2021-07-27 14:04:05 +00:00
|
|
|
}
|
2022-10-17 10:17:25 +00:00
|
|
|
Connections {
|
|
|
|
target: stickerPackDetailsPopup.store.stickersStore.stickersModule
|
2023-08-15 18:21:51 +00:00
|
|
|
function onTransactionWasSent(chainId: int, txHash: string, error: string) {
|
|
|
|
if (!!error) {
|
|
|
|
if (error.includes(Constants.walletSection.cancelledMessage)) {
|
|
|
|
return
|
2022-10-17 10:17:25 +00:00
|
|
|
}
|
2023-08-15 18:21:51 +00:00
|
|
|
buyStickersPackModal.sendingError.text = error
|
|
|
|
return buyStickersPackModal.sendingError.open()
|
2022-10-17 10:17:25 +00:00
|
|
|
}
|
2023-08-15 18:21:51 +00:00
|
|
|
let url = "%1/%2".arg(buyStickersPackModal.store.getEtherscanLink(chainId)).arg(txHash)
|
|
|
|
Global.displayToastMessage(qsTr("Transaction pending..."),
|
|
|
|
qsTr("View on etherscan"),
|
|
|
|
"",
|
|
|
|
true,
|
|
|
|
Constants.ephemeralNotificationType.normal,
|
|
|
|
url)
|
|
|
|
buyStickersPackModal.close()
|
2022-10-17 10:17:25 +00:00
|
|
|
}
|
2021-03-26 21:21:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-08 19:24:39 +00:00
|
|
|
footer: StatusStickerButton {
|
|
|
|
anchors.right: parent.right
|
|
|
|
style: StatusStickerButton.StyleType.LargeNoIcon
|
|
|
|
packPrice: price
|
|
|
|
isInstalled: installed
|
|
|
|
isBought: bought
|
|
|
|
isPending: pending
|
2023-04-12 11:23:33 +00:00
|
|
|
greyedOut: !store.networkConnectionStore.stickersNetworkAvailable
|
2023-04-12 10:31:35 +00:00
|
|
|
tooltip.text: store.networkConnectionStore.stickersNetworkUnavailableText
|
2021-03-08 19:24:39 +00:00
|
|
|
onInstallClicked: {
|
2021-11-25 17:12:19 +00:00
|
|
|
stickersModule.install(packId);
|
2021-03-08 19:24:39 +00:00
|
|
|
stickerPackDetailsPopup.close();
|
|
|
|
}
|
|
|
|
onUninstallClicked: {
|
2021-11-25 17:12:19 +00:00
|
|
|
stickersModule.uninstall(packId);
|
2021-03-08 19:24:39 +00:00
|
|
|
stickerPackDetailsPopup.close();
|
|
|
|
}
|
|
|
|
onCancelClicked: function(){}
|
|
|
|
onUpdateClicked: function(){}
|
|
|
|
onBuyClicked: {
|
2021-12-08 21:20:43 +00:00
|
|
|
Global.openPopup(stickerPackPurchaseModal);
|
|
|
|
stickerPackDetailsPopup.buyClicked(packId);
|
2021-03-08 19:24:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|