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
import "../../imports"
import "../../shared"
import "../../shared/status"
import "../../app/AppLayouts/Chat/ChatColumn/samples"
Item {
id: root
property var stickerPacks: StickerPackData { }
2021-07-27 14:04:05 +00:00
property var stickerPurchasePopup
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
source: "https://ipfs.infura.io/ipfs/" + preview
onClicked: {
stickerPackDetailsPopup . open ( )
}
}
2021-03-26 21:21:50 +00:00
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
}
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: {
2021-07-27 14:04:05 +00:00
root . stickerPurchasePopup = 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 {
contractAddress: utilsModel . stickerMarketAddress
assetPrice: price
estimateGasFunction: function ( selectedAccount , uuid ) {
if ( packId < 0 || ! selectedAccount || ! price ) return 325000
return chatsModel . stickers . estimate ( packId , selectedAccount . address , price , uuid )
}
onSendTransaction: function ( selectedAddress , gasLimit , gasPrice , password ) {
return chatsModel . stickers . buy ( packId ,
selectedAddress ,
price ,
gasLimit ,
gasPrice ,
password )
}
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
}
width: stickerPackDetailsPopup . width
height: stickerPackDetailsPopup . height
2021-07-27 14:04:05 +00:00
}
}
Connections {
target: chatsModel . stickers
onGasEstimateReturned: {
stickerPurchasePopup . setAsyncGasLimitResult ( uuid , estimate )
2020-11-03 10:29:56 +00:00
}
2020-09-29 08:41:27 +00:00
}
2021-01-20 20:30:21 +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: {
2021-08-25 08:09:33 +00:00
if ( ! appSettings . isWalletEnabled ) {
confirmationPopup . open ( )
return
}
2021-07-27 14:04:05 +00:00
root . stickerPurchasePopup = openPopup ( stickerPackPurchaseModal )
2020-09-29 08:41:27 +00:00
root . buyClicked ( packId )
}
}
}
2021-08-25 08:09:33 +00:00
ConfirmationDialog {
id: confirmationPopup
height: 310
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: {
appSettings . isWalletEnabled = true
close ( )
root . stickerPurchasePopup = openPopup ( stickerPackPurchaseModal )
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
2020-09-29 08:41:27 +00:00
source: "../../app/img/arrowUp.svg"
rotation: 270
onClicked: {
root . backClicked ( )
}
}
}
}
/ * # # ^ # #
Designer {
D { i: 0 ; height: 440 ; width: 360 }
}
# # ^ # # * /