2020-09-29 08:41:27 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import QtGraphicalEffects 1.0
|
2022-06-21 08:56:12 +00:00
|
|
|
import QtQml.Models 2.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
2022-07-20 14:54:30 +00:00
|
|
|
import StatusQ.Core 0.1
|
2024-02-05 16:44:49 +00:00
|
|
|
import StatusQ.Core.Utils 0.1
|
2023-04-12 11:28:58 +00:00
|
|
|
import StatusQ.Controls 0.1
|
2022-07-20 14:54:30 +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.panels 1.0
|
|
|
|
import shared.popups 1.0
|
|
|
|
import shared.status 1.0
|
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
|
|
|
|
2021-10-27 21:27:49 +00:00
|
|
|
//TODO remove this dependency!
|
2024-05-22 08:13:39 +00:00
|
|
|
import AppLayouts.Chat.stores 1.0 as ChatStores
|
2024-02-05 16:44:49 +00:00
|
|
|
import AppLayouts.Wallet.stores 1.0
|
2020-09-29 08:41:27 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
2022-02-14 23:27:23 +00:00
|
|
|
|
2024-05-22 08:13:39 +00:00
|
|
|
property ChatStores.RootStore store
|
|
|
|
property var stickerPacks: ChatStores.StickerPackData {}
|
2023-11-28 19:16:18 +00:00
|
|
|
required property TransactionStore transactionStore
|
2024-02-05 16:44:49 +00:00
|
|
|
required property WalletAssetsStore walletAssetsStore
|
2023-04-12 10:31:35 +00:00
|
|
|
property string packId
|
2023-04-17 21:53:55 +00:00
|
|
|
property bool marketVisible
|
2024-10-02 09:08:52 +00:00
|
|
|
property bool isWalletEnabled
|
2021-07-27 14:04:05 +00:00
|
|
|
|
2020-09-29 08:41:27 +00:00
|
|
|
signal backClicked
|
2023-04-12 10:31:35 +00:00
|
|
|
signal uninstallClicked(string packId)
|
|
|
|
signal installClicked(var stickers, string packId, int index)
|
|
|
|
signal cancelClicked(string packId)
|
|
|
|
signal updateClicked(string packId)
|
|
|
|
signal buyClicked(string packId)
|
2020-09-29 08:41:27 +00:00
|
|
|
|
2022-07-20 14:54:30 +00:00
|
|
|
StatusGridView {
|
2020-09-29 08:41:27 +00:00
|
|
|
id: availableStickerPacks
|
2022-08-11 19:16:59 +00:00
|
|
|
objectName: "stickerMarketStatusGridView"
|
2020-09-29 08:41:27 +00:00
|
|
|
width: parent.width
|
|
|
|
height: 380
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
cellWidth: parent.width - (Style.current.padding * 2)
|
|
|
|
cellHeight: height - 72
|
2023-04-17 21:53:55 +00:00
|
|
|
visible: root.marketVisible
|
2022-06-21 08:56:12 +00:00
|
|
|
|
2023-04-12 11:28:58 +00:00
|
|
|
ScrollBar.vertical: StatusScrollBar {}
|
|
|
|
|
2020-09-29 08:41:27 +00:00
|
|
|
focus: true
|
2022-06-21 08:56:12 +00:00
|
|
|
model: DelegateModel {
|
|
|
|
id: delegateModel
|
|
|
|
|
|
|
|
function update() {
|
|
|
|
if (items.count > 0) {
|
|
|
|
items.setGroups(0, items.count, "items");
|
2020-09-29 08:41:27 +00:00
|
|
|
}
|
2021-03-26 21:21:50 +00:00
|
|
|
|
2022-06-21 08:56:12 +00:00
|
|
|
var visible = [];
|
|
|
|
for (var i = 0; i < items.count; ++i) {
|
|
|
|
var item = items.get(i);
|
|
|
|
if (delegateModel.walletEnabled ||
|
|
|
|
!delegateModel.walletEnabled && item.model.price == 0) {
|
|
|
|
visible.push(item);
|
|
|
|
}
|
2020-09-29 08:41:27 +00:00
|
|
|
}
|
2021-03-26 21:21:50 +00:00
|
|
|
|
2022-06-21 08:56:12 +00:00
|
|
|
for (i = 0; i < visible.length; ++i) {
|
|
|
|
item = visible[i];
|
|
|
|
item.inVisible = true;
|
|
|
|
if (item.visibleIndex !== i) {
|
|
|
|
visibleItems.move(item.visibleIndex, i, 1);
|
|
|
|
}
|
2021-03-26 21:21:50 +00:00
|
|
|
}
|
2022-06-21 08:56:12 +00:00
|
|
|
}
|
|
|
|
|
2024-10-02 09:08:52 +00:00
|
|
|
readonly property bool walletEnabled: root.isWalletEnabled
|
2022-06-21 08:56:12 +00:00
|
|
|
onWalletEnabledChanged: {
|
|
|
|
update()
|
|
|
|
}
|
|
|
|
|
|
|
|
model: stickerPacks
|
|
|
|
items.onChanged: update()
|
|
|
|
filterOnGroup: "visible"
|
|
|
|
groups: DelegateModelGroup {
|
|
|
|
id: visibleItems
|
2021-03-26 21:21:50 +00:00
|
|
|
|
2022-06-21 08:56:12 +00:00
|
|
|
name: "visible"
|
|
|
|
includeByDefault: false
|
|
|
|
}
|
|
|
|
|
|
|
|
delegate: Item {
|
2022-08-11 19:16:59 +00:00
|
|
|
objectName: "stickerMarketDelegateItem" + index
|
|
|
|
readonly property string packId: model.packId // This property is necessary for the tests
|
|
|
|
readonly property bool installed: model.installed // This property is necessary for the tests
|
2022-06-21 08:56:12 +00:00
|
|
|
width: availableStickerPacks.cellWidth
|
|
|
|
height: availableStickerPacks.cellHeight
|
|
|
|
RoundedImage {
|
|
|
|
id: imgPreview
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
2020-09-29 08:41:27 +00:00
|
|
|
anchors.right: parent.right
|
2022-06-21 08:56:12 +00:00
|
|
|
height: 220
|
|
|
|
width: parent.width
|
|
|
|
radius: 12
|
|
|
|
source: model.preview
|
|
|
|
onClicked: {
|
|
|
|
stickerPackDetailsPopup.open()
|
2020-09-29 08:41:27 +00:00
|
|
|
}
|
|
|
|
}
|
2022-06-21 08:56:12 +00:00
|
|
|
|
|
|
|
// TODO: replace with StatusModal
|
|
|
|
ModalPopup {
|
|
|
|
id: stickerPackDetailsPopup
|
|
|
|
height: 540
|
|
|
|
header: StatusStickerPackDetails {
|
|
|
|
packThumb: thumbnail
|
|
|
|
packName: name
|
|
|
|
packAuthor: author
|
|
|
|
packNameFontSize: 17
|
|
|
|
spacing: Style.current.padding / 2
|
2021-07-27 14:04:05 +00:00
|
|
|
}
|
2022-06-21 08:56:12 +00:00
|
|
|
|
|
|
|
contentWrapper.anchors.topMargin: 0
|
|
|
|
contentWrapper.anchors.bottomMargin: 0
|
2023-04-12 12:15:39 +00:00
|
|
|
contentWrapper.anchors.rightMargin: 0
|
2022-06-21 08:56:12 +00:00
|
|
|
StatusStickerList {
|
|
|
|
id: stickerGridInPopup
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
model: stickers
|
|
|
|
packId: root.packId
|
2021-07-27 14:04:05 +00:00
|
|
|
}
|
2022-06-21 08:56:12 +00:00
|
|
|
|
|
|
|
footer: StatusStickerButton {
|
2022-08-11 19:16:59 +00:00
|
|
|
objectName: "statusStickerMarketInstallButton"
|
2022-06-21 08:56:12 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
style: StatusStickerButton.StyleType.LargeNoIcon
|
|
|
|
packPrice: price
|
|
|
|
isInstalled: installed
|
|
|
|
isBought: bought
|
|
|
|
isPending: pending
|
2023-04-04 11:31:04 +00:00
|
|
|
greyedOut: !root.store.networkConnectionStore.stickersNetworkAvailable
|
|
|
|
tooltip.text: root.store.networkConnectionStore.stickersNetworkUnavailableText
|
2022-06-21 08:56:12 +00:00
|
|
|
onInstallClicked: root.installClicked(stickers, packId, index)
|
|
|
|
onUninstallClicked: root.uninstallClicked(packId)
|
|
|
|
onCancelClicked: root.cancelClicked(packId)
|
|
|
|
onUpdateClicked: root.updateClicked(packId)
|
|
|
|
onBuyClicked: {
|
2023-08-15 18:21:51 +00:00
|
|
|
Global.openPopup(stickerPackPurchaseModal, {price, packId})
|
2022-06-21 08:56:12 +00:00
|
|
|
root.buyClicked(packId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-07-27 14:04:05 +00:00
|
|
|
|
2022-06-21 08:56:12 +00:00
|
|
|
StatusStickerPackDetails {
|
|
|
|
id: stickerPackDetails
|
|
|
|
height: 64 - (Style.current.smallPadding * 2)
|
|
|
|
width: parent.width - (Style.current.padding * 2)
|
|
|
|
anchors.top: imgPreview.bottom
|
|
|
|
anchors.topMargin: Style.current.smallPadding
|
|
|
|
anchors.bottomMargin: Style.current.smallPadding
|
|
|
|
anchors.left: parent.left
|
2020-09-29 08:41:27 +00:00
|
|
|
anchors.right: parent.right
|
2022-06-21 08:56:12 +00:00
|
|
|
packThumb: thumbnail
|
|
|
|
packName: name
|
|
|
|
packAuthor: author
|
|
|
|
|
|
|
|
StatusStickerButton {
|
|
|
|
anchors.right: parent.right
|
2023-04-12 19:08:42 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2022-06-21 08:56:12 +00:00
|
|
|
packPrice: price
|
|
|
|
isInstalled: installed
|
|
|
|
isBought: bought
|
|
|
|
isPending: pending
|
2023-04-04 11:31:04 +00:00
|
|
|
greyedOut: !root.store.networkConnectionStore.stickersNetworkAvailable
|
|
|
|
tooltip.text: root.store.networkConnectionStore.stickersNetworkUnavailableText
|
2022-06-21 08:56:12 +00:00
|
|
|
onInstallClicked: root.installClicked(stickers, packId, index)
|
|
|
|
onUninstallClicked: root.uninstallClicked(packId)
|
|
|
|
onCancelClicked: root.cancelClicked(packId)
|
|
|
|
onUpdateClicked: root.updateClicked(packId)
|
|
|
|
onBuyClicked: {
|
2023-08-15 18:21:51 +00:00
|
|
|
Global.openPopup(stickerPackPurchaseModal, {price, packId})
|
2022-06-21 08:56:12 +00:00
|
|
|
root.buyClicked(packId)
|
2021-08-25 08:09:33 +00:00
|
|
|
}
|
2020-09-29 08:41:27 +00:00
|
|
|
}
|
|
|
|
}
|
2021-08-25 08:09:33 +00:00
|
|
|
}
|
2020-09-29 08:41:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-12 11:28:58 +00:00
|
|
|
Component {
|
|
|
|
id: stickerPackPurchaseModal
|
|
|
|
SendModal {
|
|
|
|
id: buyStickersModal
|
2023-04-12 12:59:39 +00:00
|
|
|
|
|
|
|
required property int price
|
2023-08-15 18:21:51 +00:00
|
|
|
required property string packId
|
2023-04-12 12:59:39 +00:00
|
|
|
|
2023-04-12 11:28:58 +00:00
|
|
|
interactive: false
|
2023-11-28 19:16:18 +00:00
|
|
|
store: root.transactionStore
|
2023-09-20 16:07:09 +00:00
|
|
|
preSelectedSendType: Constants.SendType.StickersBuy
|
2023-04-12 11:28:58 +00:00
|
|
|
preSelectedRecipient: root.store.stickersStore.getStickersMarketAddress()
|
|
|
|
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(parseFloat(price))
|
2024-07-25 13:30:51 +00:00
|
|
|
stickersPackId: packId
|
2024-02-05 16:44:49 +00:00
|
|
|
preSelectedHoldingID: {
|
|
|
|
let token = ModelUtils.getByKey(root.walletAssetsStore.groupedAccountAssetsModel, "tokensKey", root.store.stickersStore.getStatusTokenKey())
|
|
|
|
return !!token && !!token.symbol ? token.symbol : ""
|
|
|
|
}
|
2023-11-07 22:45:47 +00:00
|
|
|
preSelectedHoldingType: Constants.TokenType.ERC20
|
2024-09-25 12:48:04 +00:00
|
|
|
|
2023-04-12 11:28:58 +00:00
|
|
|
Connections {
|
|
|
|
target: root.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
|
2023-04-12 11:28:58 +00:00
|
|
|
}
|
2023-08-15 18:21:51 +00:00
|
|
|
buyStickersModal.sendingError.text = error
|
|
|
|
return buyStickersModal.sendingError.open()
|
2023-04-12 11:28:58 +00:00
|
|
|
}
|
2023-08-15 18:21:51 +00:00
|
|
|
let url = "%1/%2".arg(buyStickersModal.store.getEtherscanLink(chainId)).arg(txHash)
|
|
|
|
Global.displayToastMessage(qsTr("Transaction pending..."),
|
|
|
|
qsTr("View on etherscan"),
|
|
|
|
"",
|
|
|
|
true,
|
|
|
|
Constants.ephemeralNotificationType.normal,
|
|
|
|
url)
|
|
|
|
buyStickersModal.close()
|
2023-04-12 11:28:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-29 08:41:27 +00:00
|
|
|
Item {
|
|
|
|
id: footer
|
2023-04-12 19:08:42 +00:00
|
|
|
height: 44
|
2020-09-29 08:41:27 +00:00
|
|
|
anchors.top: availableStickerPacks.bottom
|
|
|
|
|
2023-04-12 19:08:42 +00:00
|
|
|
StatusBackButton {
|
2020-09-29 08:41:27 +00:00
|
|
|
id: btnBack
|
2023-04-12 19:08:42 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2020-09-29 08:41:27 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: Style.current.padding / 2
|
2023-04-12 19:08:42 +00:00
|
|
|
width: 24
|
|
|
|
height: 24
|
2024-07-23 15:26:13 +00:00
|
|
|
icon.width: 16
|
|
|
|
icon.height: 16
|
|
|
|
horizontalPadding: 0
|
|
|
|
verticalPadding: 0
|
2020-09-29 08:41:27 +00:00
|
|
|
onClicked: {
|
|
|
|
root.backClicked()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|