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
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
2022-02-14 23:27:23 +00:00
import shared . stores 1.0 as SharedStores
2021-10-27 21:27:49 +00:00
//TODO remove this dependency!
2022-03-08 18:49:33 +00:00
import AppLayouts . Chat . stores 1.0
2020-09-29 08:41:27 +00:00
Item {
id: root
2022-02-14 23:27:23 +00:00
property var store
2020-09-29 08:41:27 +00:00
property var stickerPacks: StickerPackData { }
2021-12-08 21:20:43 +00:00
property int packId: - 1
2021-07-27 14:04:05 +00:00
2020-09-29 08:41:27 +00:00
signal backClicked
signal uninstallClicked ( int packId )
signal installClicked ( var stickers , int packId , int index )
signal cancelClicked ( int packId )
signal updateClicked ( int packId )
signal buyClicked ( int packId )
GridView {
id: availableStickerPacks
width: parent . width
height: 380
anchors.left: parent . left
anchors.leftMargin: Style . current . padding
anchors.right: parent . right
anchors.rightMargin: Style . current . padding
anchors.top: parent . top
anchors.topMargin: Style . current . padding
cellWidth: parent . width - ( Style . current . padding * 2 )
cellHeight: height - 72
model: stickerPacks
focus: true
clip: true
delegate: Item {
width: availableStickerPacks . cellWidth
height: availableStickerPacks . cellHeight
RoundedImage {
id: imgPreview
anchors.top: parent . top
anchors.left: parent . left
anchors.right: parent . right
height: 220
width: parent . width
radius: 12
2022-02-14 23:27:23 +00:00
source: model . preview
2020-09-29 08:41:27 +00:00
onClicked: {
stickerPackDetailsPopup . open ( )
}
}
2021-03-26 21:21:50 +00:00
2021-10-14 11:33:34 +00:00
// TODO: replace with StatusModal
2020-09-29 08:41:27 +00:00
ModalPopup {
id: stickerPackDetailsPopup
2021-07-26 11:36:49 +00:00
height: 540
2020-09-29 08:41:27 +00:00
header: StatusStickerPackDetails {
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
anchors.fill: parent
anchors.topMargin: Style . current . padding
model: stickers
2021-12-08 21:20:43 +00:00
packId: root . packId
2021-03-26 21:21:50 +00:00
}
2020-09-29 08:41:27 +00:00
footer: StatusStickerButton {
2021-03-26 21:21:50 +00:00
height: 44
2020-09-29 08:41:27 +00:00
anchors.right: parent . right
style: StatusStickerButton . StyleType . LargeNoIcon
packPrice: price
isInstalled: installed
isBought: bought
isPending: pending
onInstallClicked: root . installClicked ( stickers , packId , index )
onUninstallClicked: root . uninstallClicked ( packId )
onCancelClicked: root . cancelClicked ( packId )
onUpdateClicked: root . updateClicked ( packId )
onBuyClicked: {
2022-02-14 23:27:23 +00:00
Global . openPopup ( stickerPackPurchaseModal )
2020-09-29 08:41:27 +00:00
root . buyClicked ( packId )
}
}
}
2021-01-20 20:30:21 +00:00
Component {
2020-09-29 08:41:27 +00:00
id: stickerPackPurchaseModal
2021-07-27 14:04:05 +00:00
StatusSNTTransactionModal {
2022-02-14 23:27:23 +00:00
store: root . store
stickersStore: root . store . stickersStore
contractAddress: root . store . stickersStore . getStickersMarketAddress ( )
contactsStore: root . store . contactsStore
2021-07-27 14:04:05 +00:00
assetPrice: price
2022-05-19 08:53:57 +00:00
chainId: root . store . stickersStore . getChainIdForStickers ( )
2021-07-27 14:04:05 +00:00
estimateGasFunction: function ( selectedAccount , uuid ) {
if ( packId < 0 || ! selectedAccount || ! price ) return 325000
2022-02-14 23:27:23 +00:00
return root . store . stickersStore . estimate ( packId , selectedAccount . address , price , uuid )
2021-07-27 14:04:05 +00:00
}
2022-05-19 08:53:57 +00:00
onSendTransaction: function ( selectedAddress , gasLimit , gasPrice , tipLimit , overallLimit , password , eip1559Enabled ) {
2022-02-14 23:27:23 +00:00
return root . store . stickersStore . buy ( packId ,
2021-07-27 14:04:05 +00:00
selectedAddress ,
gasLimit ,
gasPrice ,
2021-07-05 12:34:56 +00:00
tipLimit ,
overallLimit ,
2022-05-19 08:53:57 +00:00
password ,
eip1559Enabled )
2021-07-27 14:04:05 +00:00
}
2020-11-03 10:29:56 +00:00
onClosed: {
2021-01-20 20:36:18 +00:00
destroy ( )
2020-11-03 10:29:56 +00:00
}
2022-02-14 23:27:23 +00:00
asyncGasEstimateTarget: root . store . stickersStore . stickersModule
2020-11-03 10:29:56 +00:00
width: stickerPackDetailsPopup . width
height: stickerPackDetailsPopup . height
2021-07-27 14:04:05 +00:00
}
}
2020-09-29 08:41:27 +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
anchors.right: parent . right
packThumb: thumbnail
packName: name
packAuthor: author
StatusStickerButton {
anchors.right: parent . right
packPrice: price
width: 75 // only needed for Qt Creator
isInstalled: installed
isBought: bought
isPending: pending
onInstallClicked: root . installClicked ( stickers , packId , index )
onUninstallClicked: root . uninstallClicked ( packId )
onCancelClicked: root . cancelClicked ( packId )
onUpdateClicked: root . updateClicked ( packId )
onBuyClicked: {
2022-02-14 23:27:23 +00:00
if ( ! SharedStores . RootStore . isWalletEnabled ) {
2021-08-25 08:09:33 +00:00
confirmationPopup . open ( )
return
}
2022-02-14 23:27:23 +00:00
Global . openPopup ( stickerPackPurchaseModal )
2020-09-29 08:41:27 +00:00
root . buyClicked ( packId )
}
}
}
2021-08-25 08:09:33 +00:00
ConfirmationDialog {
id: confirmationPopup
showCancelButton: true
confirmationText: qsTr ( "This feature is experimental and is meant for testing purposes by core contributors and the community. It's not meant for real use and makes no claims of security or integrity of funds or data. Use at your own risk." )
confirmButtonLabel: qsTr ( "I understand" )
onConfirmButtonClicked: {
2022-02-14 23:27:23 +00:00
SharedStores . RootStore . enableWallet ( ) ;
2021-08-25 08:09:33 +00:00
close ( )
2022-02-14 23:27:23 +00:00
Global . openPopup ( stickerPackPurchaseModal )
2021-08-25 08:09:33 +00:00
root . buyClicked ( packId )
}
onCancelButtonClicked: {
close ( )
}
}
2020-09-29 08:41:27 +00:00
}
}
Item {
id: footer
height: 44 - Style . current . padding
anchors.top: availableStickerPacks . bottom
RoundedIcon {
id: btnBack
anchors.top: parent . top
anchors.topMargin: Style . current . padding / 2
anchors.left: parent . left
anchors.leftMargin: Style . current . padding / 2
width: 28
height: 28
iconWidth: 17.5
iconHeight: 13.5
2021-03-26 21:21:50 +00:00
iconColor: Style . current . roundedButtonSecondaryForegroundColor
2021-09-28 15:04:06 +00:00
source: Style . svg ( "arrowUp" )
2020-09-29 08:41:27 +00:00
rotation: 270
onClicked: {
root . backClicked ( )
}
}
}
}
/ * # # ^ # #
Designer {
D { i: 0 ; height: 440 ; width: 360 }
}
# # ^ # # * /