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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
//TODO remove this dependency!
|
|
|
|
import "../../../app/AppLayouts/Chat/stores"
|
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
|
|
|
|
|
|
|
|
property int packId: -1
|
|
|
|
|
2022-02-14 23:27:23 +00:00
|
|
|
property var store
|
2021-03-08 19:24:39 +00:00
|
|
|
property string thumbnail: ""
|
|
|
|
property string name: ""
|
|
|
|
property string author: ""
|
|
|
|
property string price: ""
|
|
|
|
property bool installed: false;
|
|
|
|
property bool bought: false;
|
|
|
|
property bool pending: false;
|
|
|
|
property var stickers;
|
2021-12-08 21:20:43 +00:00
|
|
|
signal buyClicked(int 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();
|
2021-11-25 17:12:19 +00:00
|
|
|
name = stickersModule.stickerPacks.rowData(idx, "name")
|
|
|
|
author = stickersModule.stickerPacks.rowData(idx, "author")
|
|
|
|
thumbnail = stickersModule.stickerPacks.rowData(idx, "thumbnail")
|
|
|
|
price = stickersModule.stickerPacks.rowData(idx, "price")
|
|
|
|
stickers = stickersModule.stickerPacks.getStickers()
|
|
|
|
installed = stickersModule.stickerPacks.rowData(idx, "installed") === "true"
|
|
|
|
bought = stickersModule.stickerPacks.rowData(idx, "bought") === "true"
|
|
|
|
pending = stickersModule.stickerPacks.rowData(idx, "pending") === "true"
|
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
|
|
|
|
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
|
|
|
|
sendType: Constants.SendType.StickersBuy
|
|
|
|
preSelectedRecipient: stickerPackDetailsPopup.store.stickersStore.getStickersMarketAddress()
|
|
|
|
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(parseFloat(price))
|
|
|
|
preSelectedAsset: {
|
|
|
|
let assetsList = buyStickersPackModal.store.currentAccount.assets
|
|
|
|
for(var i=0; i< assetsList.count;i++) {
|
|
|
|
let symbol = JSON.parse(stickerPackDetailsPopup.store.stickersStore.getStatusToken()).symbol
|
|
|
|
if(symbol === assetsList.rowData(i, "symbol"))
|
|
|
|
return {
|
|
|
|
name: assetsList.rowData(i, "name"),
|
|
|
|
symbol: assetsList.rowData(i, "symbol"),
|
|
|
|
totalBalance: assetsList.rowData(i, "totalBalance"),
|
|
|
|
totalCurrencyBalance: assetsList.rowData(i, "totalCurrencyBalance"),
|
|
|
|
balances: assetsList.rowData(i, "balances"),
|
|
|
|
decimals: assetsList.rowData(i, "decimals")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return {}
|
2021-07-27 14:04:05 +00:00
|
|
|
}
|
2022-10-17 10:17:25 +00:00
|
|
|
sendTransaction: function() {
|
|
|
|
if(bestRoutes.length === 1) {
|
|
|
|
let path = bestRoutes[0]
|
|
|
|
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,
|
|
|
|
selectedAccount.address,
|
|
|
|
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
|
|
|
|
onTransactionWasSent: {
|
|
|
|
try {
|
|
|
|
let response = JSON.parse(txResult)
|
|
|
|
if (!response.success) {
|
2022-11-30 18:57:00 +00:00
|
|
|
if (response.result.includes(Constants.walletSection.cancelledMessage)) {
|
2022-10-17 10:17:25 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
buyStickersPackModal.sendingError.text = response.result
|
|
|
|
return buyStickersPackModal.sendingError.open()
|
|
|
|
}
|
|
|
|
let url = `${buyStickersPackModal.store.getEtherscanLink()}/${response.result}`;
|
|
|
|
Global.displayToastMessage(qsTr("Transaction pending..."),
|
|
|
|
qsTr("View on etherscan"),
|
|
|
|
"",
|
|
|
|
true,
|
|
|
|
Constants.ephemeralNotificationType.normal,
|
|
|
|
url)
|
|
|
|
buyStickersPackModal.close()
|
|
|
|
} catch (e) {
|
|
|
|
console.error('Error parsing the response', e)
|
|
|
|
}
|
|
|
|
}
|
2021-03-26 21:21:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-08 19:24:39 +00:00
|
|
|
footer: StatusStickerButton {
|
2021-03-26 21:21:50 +00:00
|
|
|
height: 44
|
2021-03-08 19:24:39 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
style: StatusStickerButton.StyleType.LargeNoIcon
|
|
|
|
packPrice: price
|
|
|
|
isInstalled: installed
|
|
|
|
isBought: bought
|
|
|
|
isPending: pending
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|