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.panels 1.0
|
2023-11-28 19:16:18 +00:00
|
|
|
import shared.stores.send 1.0
|
2021-10-21 15:07:13 +00:00
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
import StatusQ.Core 0.1
|
2022-11-23 13:40:03 +00:00
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
2021-10-25 19:37:44 +00:00
|
|
|
import StatusQ.Components 0.1
|
2021-10-01 15:58:36 +00:00
|
|
|
//TODO improve this!
|
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
|
|
|
|
|
|
|
Popup {
|
2020-12-14 07:01:09 +00:00
|
|
|
id: root
|
2022-11-23 13:40:03 +00:00
|
|
|
|
2024-05-22 08:13:39 +00:00
|
|
|
property ChatStores.RootStore 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
|
2022-11-23 13:40:03 +00:00
|
|
|
|
2022-08-10 19:18:20 +00:00
|
|
|
signal stickerSelected(string hashId, string packId, string url)
|
2022-11-23 13:40:03 +00:00
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
// FIXME: move me to store
|
|
|
|
readonly property int installedPacksCount: root.store.stickersModuleInst.numInstalledStickerPacks
|
|
|
|
readonly property var recentStickers: root.store.stickersModuleInst.recent
|
|
|
|
readonly property var stickerPackList: store.stickersModuleInst.stickerPacks
|
|
|
|
readonly property bool stickerPacksLoaded: store.stickersModuleInst.packsLoaded
|
|
|
|
readonly property bool stickerPacksLoadFailed: store.stickersModuleInst.packsLoadFailed
|
|
|
|
readonly property bool stickerPacksLoading: !stickerPacksLoaded && !stickerPacksLoadFailed
|
|
|
|
|
|
|
|
function loadStickers() {
|
|
|
|
store.stickersModuleInst.loadStickers()
|
|
|
|
}
|
2023-02-08 13:31:14 +00:00
|
|
|
|
|
|
|
function getRecentStickers() {
|
|
|
|
store.stickersModuleInst.getRecentStickers()
|
|
|
|
}
|
2023-02-08 14:05:06 +00:00
|
|
|
|
|
|
|
function getInstalledStickerPacks() {
|
|
|
|
store.stickersModuleInst.getInstalledStickerPacks()
|
|
|
|
}
|
2023-04-17 21:53:55 +00:00
|
|
|
|
|
|
|
readonly property bool online: root.store.networkConnectionStore.isOnline
|
|
|
|
onOnlineChanged: {
|
|
|
|
if (online)
|
|
|
|
d.loadStickers()
|
|
|
|
}
|
2022-11-23 13:40:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
enabled: !!d.recentStickers && !!d.stickerPackList
|
2020-12-04 12:14:18 +00:00
|
|
|
width: 360
|
|
|
|
height: 440
|
2020-09-29 08:41:27 +00:00
|
|
|
modal: false
|
|
|
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
|
|
|
|
background: Rectangle {
|
|
|
|
radius: Style.current.radius
|
|
|
|
color: Style.current.background
|
|
|
|
border.color: Style.current.border
|
|
|
|
layer.enabled: true
|
|
|
|
layer.effect: DropShadow {
|
|
|
|
verticalOffset: 3
|
|
|
|
radius: 8
|
|
|
|
samples: 15
|
|
|
|
fast: true
|
|
|
|
cached: true
|
|
|
|
color: "#22000000"
|
|
|
|
}
|
|
|
|
}
|
2022-11-23 13:40:03 +00:00
|
|
|
|
2023-02-08 13:31:14 +00:00
|
|
|
onAboutToShow: {
|
2023-02-08 14:05:06 +00:00
|
|
|
d.getInstalledStickerPacks()
|
2023-04-12 10:31:35 +00:00
|
|
|
if (!stickerGrid.packId) {
|
2023-02-08 13:31:14 +00:00
|
|
|
d.getRecentStickers()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-29 08:41:27 +00:00
|
|
|
onClosed: {
|
|
|
|
stickerMarket.visible = false
|
|
|
|
footerContent.visible = true
|
|
|
|
stickersContainer.visible = true
|
|
|
|
}
|
2022-11-23 13:40:03 +00:00
|
|
|
|
2023-05-31 20:58:23 +00:00
|
|
|
padding: 0
|
|
|
|
|
|
|
|
ColumnLayout {
|
2020-09-29 08:41:27 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
StatusStickerMarket {
|
|
|
|
id: stickerMarket
|
|
|
|
visible: false
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2022-02-14 23:27:23 +00:00
|
|
|
store: root.store
|
2023-11-28 19:16:18 +00:00
|
|
|
transactionStore: root.transactionStore
|
2024-02-05 16:44:49 +00:00
|
|
|
walletAssetsStore: root.walletAssetsStore
|
2022-11-23 13:40:03 +00:00
|
|
|
stickerPacks: d.stickerPackList
|
2021-12-08 21:20:43 +00:00
|
|
|
packId: stickerPackListView.selectedPackId
|
2023-04-17 21:53:55 +00:00
|
|
|
marketVisible: d.stickerPacksLoaded && d.online
|
2020-09-29 08:41:27 +00:00
|
|
|
onInstallClicked: {
|
2022-12-30 20:26:46 +00:00
|
|
|
//starts async task
|
2021-11-25 17:12:19 +00:00
|
|
|
stickersModule.install(packId)
|
2020-09-29 08:41:27 +00:00
|
|
|
}
|
|
|
|
onUninstallClicked: {
|
2021-11-25 17:12:19 +00:00
|
|
|
stickersModule.uninstall(packId)
|
2022-11-23 13:40:03 +00:00
|
|
|
stickerGrid.model = d.recentStickers
|
2022-12-01 10:24:25 +00:00
|
|
|
btnHistory.clicked(null)
|
2020-09-29 08:41:27 +00:00
|
|
|
}
|
|
|
|
onBackClicked: {
|
|
|
|
stickerMarket.visible = false
|
|
|
|
footerContent.visible = true
|
|
|
|
stickersContainer.visible = true
|
|
|
|
}
|
2021-11-23 13:59:49 +00:00
|
|
|
|
2022-12-30 20:26:46 +00:00
|
|
|
Connections {
|
|
|
|
target: root.store.stickersModuleInst
|
|
|
|
function onStickerPackInstalled(packId) {
|
|
|
|
const idx = stickersModule.stickerPacks.findIndexById(packId, false);
|
|
|
|
if (idx === -1) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
stickersModule.stickerPacks.findStickersById(packId)
|
|
|
|
stickerGrid.model = stickersModule.stickerPacks.getFoundStickers()
|
|
|
|
stickerPackListView.itemAt(idx).clicked()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-23 13:59:49 +00:00
|
|
|
Loader {
|
|
|
|
id: marketLoader
|
|
|
|
anchors.centerIn: parent
|
2022-11-23 13:40:03 +00:00
|
|
|
active: d.stickerPacksLoading
|
|
|
|
sourceComponent: loadingImageComponent
|
2021-11-23 13:59:49 +00:00
|
|
|
}
|
2022-11-23 13:46:02 +00:00
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: failedToLoadStickersInfo
|
|
|
|
|
|
|
|
anchors.centerIn: parent
|
2023-04-17 21:53:55 +00:00
|
|
|
visible: d.stickerPacksLoadFailed || !d.online
|
2022-11-23 13:46:02 +00:00
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
text: qsTr("Failed to load stickers")
|
|
|
|
color: Theme.palette.dangerColor1
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
objectName: "stickersPopupRetryButton"
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
text: qsTr("Try again")
|
2023-04-17 21:53:55 +00:00
|
|
|
enabled: d.online
|
2022-11-23 13:46:02 +00:00
|
|
|
|
|
|
|
onClicked: d.loadStickers()
|
|
|
|
}
|
|
|
|
}
|
2020-09-29 08:41:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: stickersContainer
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.leftMargin: 4
|
|
|
|
Layout.topMargin: 4
|
|
|
|
Layout.bottomMargin: 0
|
|
|
|
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
|
|
|
|
Layout.preferredHeight: 400 - 4
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: noStickerPacks
|
|
|
|
anchors.fill: parent
|
2023-04-17 21:53:55 +00:00
|
|
|
visible: d.installedPacksCount == 0 && stickersModule.recent.rowCount() === 0
|
2020-09-29 08:41:27 +00:00
|
|
|
|
|
|
|
Image {
|
|
|
|
id: imgNoStickers
|
|
|
|
width: 56
|
|
|
|
height: 56
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 134
|
2021-09-28 15:04:06 +00:00
|
|
|
source: Style.svg("stickers_sad_icon")
|
2020-09-29 08:41:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: noStickersContainer
|
|
|
|
width: parent.width
|
|
|
|
height: 22
|
|
|
|
anchors.top: imgNoStickers.bottom
|
|
|
|
anchors.topMargin: 8
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: lblNoStickersYet
|
|
|
|
anchors.fill: parent
|
|
|
|
font.pixelSize: 15
|
2023-04-17 21:53:55 +00:00
|
|
|
text: d.installedPacksCount === 0 || !d.online ? qsTr("You don't have any stickers yet")
|
|
|
|
: qsTr("Recently used stickers will appear here")
|
2020-09-29 08:41:27 +00:00
|
|
|
lineHeight: 22
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-23 13:40:03 +00:00
|
|
|
StatusButton {
|
2022-08-11 19:16:59 +00:00
|
|
|
objectName: "stickersPopupGetStickersButton"
|
2023-04-17 21:53:55 +00:00
|
|
|
visible: d.installedPacksCount === 0
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Get Stickers")
|
2023-04-17 21:53:55 +00:00
|
|
|
enabled: d.online
|
2020-09-29 08:41:27 +00:00
|
|
|
anchors.top: noStickersContainer.bottom
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
onClicked: {
|
|
|
|
stickersContainer.visible = false
|
|
|
|
stickerMarket.visible = true
|
|
|
|
footerContent.visible = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-04-17 21:53:55 +00:00
|
|
|
|
2020-09-29 08:41:27 +00:00
|
|
|
StatusStickerList {
|
|
|
|
id: stickerGrid
|
2022-08-11 19:16:59 +00:00
|
|
|
objectName: "statusStickerPopupStickerGrid"
|
2023-04-12 12:15:39 +00:00
|
|
|
anchors.fill: parent
|
2022-11-23 13:40:03 +00:00
|
|
|
model: d.recentStickers
|
2021-12-08 21:20:43 +00:00
|
|
|
packId: stickerPackListView.selectedPackId
|
2020-09-29 08:41:27 +00:00
|
|
|
onStickerClicked: {
|
2022-08-10 19:18:20 +00:00
|
|
|
root.stickerSelected(hash, packId, url)
|
2020-12-14 07:01:09 +00:00
|
|
|
root.close()
|
|
|
|
}
|
|
|
|
}
|
2021-02-09 13:57:53 +00:00
|
|
|
|
|
|
|
Component {
|
|
|
|
id: loadingImageComponent
|
2021-04-26 10:25:01 +00:00
|
|
|
StatusLoadingIndicator {
|
2021-02-09 13:57:53 +00:00
|
|
|
width: 50
|
|
|
|
height: 50
|
2020-09-29 08:41:27 +00:00
|
|
|
}
|
|
|
|
}
|
2021-02-09 13:57:53 +00:00
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: loadingGrid
|
2022-11-23 13:40:03 +00:00
|
|
|
active: d.stickerPacksLoading
|
2021-02-09 13:57:53 +00:00
|
|
|
sourceComponent: loadingImageComponent
|
|
|
|
anchors.centerIn: parent
|
|
|
|
}
|
2020-09-29 08:41:27 +00:00
|
|
|
}
|
|
|
|
|
2023-01-09 18:59:04 +00:00
|
|
|
RowLayout {
|
2020-09-29 08:41:27 +00:00
|
|
|
id: footerContent
|
|
|
|
Layout.fillWidth: true
|
2023-04-12 19:08:42 +00:00
|
|
|
Layout.preferredHeight: 44
|
2023-01-09 18:59:04 +00:00
|
|
|
Layout.rightMargin: Style.current.padding / 2
|
|
|
|
Layout.leftMargin: Style.current.padding / 2
|
2022-04-11 16:17:42 +00:00
|
|
|
spacing: Style.current.padding / 2
|
2020-09-29 08:41:27 +00:00
|
|
|
|
2023-04-12 19:08:42 +00:00
|
|
|
StatusRoundButton {
|
2020-09-29 08:41:27 +00:00
|
|
|
id: btnAddStickerPack
|
2023-04-12 10:38:38 +00:00
|
|
|
Layout.preferredWidth: 24
|
|
|
|
Layout.preferredHeight: 24
|
2021-10-25 19:37:44 +00:00
|
|
|
icon.name: "add"
|
2023-04-12 19:08:42 +00:00
|
|
|
type: StatusFlatRoundButton.Type.Secondary
|
|
|
|
loading: d.stickerPacksLoading
|
2020-09-29 08:41:27 +00:00
|
|
|
onClicked: {
|
|
|
|
stickersContainer.visible = false
|
|
|
|
stickerMarket.visible = true
|
|
|
|
footerContent.visible = false
|
|
|
|
}
|
|
|
|
}
|
2022-04-11 16:17:42 +00:00
|
|
|
|
2022-11-23 13:40:03 +00:00
|
|
|
StatusTabBarIconButton {
|
2020-09-29 08:41:27 +00:00
|
|
|
id: btnHistory
|
2022-04-11 16:17:42 +00:00
|
|
|
icon.name: "time"
|
|
|
|
highlighted: true
|
2020-09-29 08:41:27 +00:00
|
|
|
onClicked: {
|
2022-04-11 16:17:42 +00:00
|
|
|
highlighted = true
|
2023-04-12 10:31:35 +00:00
|
|
|
stickerPackListView.selectedPackId = ""
|
2023-02-08 13:31:14 +00:00
|
|
|
d.getRecentStickers()
|
2022-11-23 13:40:03 +00:00
|
|
|
stickerGrid.model = d.recentStickers
|
2020-09-29 08:41:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
StatusScrollView {
|
2023-05-31 20:58:23 +00:00
|
|
|
id: scrollView
|
|
|
|
|
2023-01-09 18:59:04 +00:00
|
|
|
Layout.fillWidth: true
|
2023-01-26 08:41:07 +00:00
|
|
|
Layout.fillHeight: true
|
2023-06-07 13:18:29 +00:00
|
|
|
padding: 0
|
|
|
|
contentHeight: availableHeight
|
2023-01-09 18:59:04 +00:00
|
|
|
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
|
2022-04-11 16:17:42 +00:00
|
|
|
|
2020-11-27 20:51:52 +00:00
|
|
|
RowLayout {
|
2023-06-07 13:18:29 +00:00
|
|
|
height: scrollView.availableHeight
|
2023-04-12 10:31:35 +00:00
|
|
|
spacing: footerContent.spacing
|
2022-07-20 14:54:30 +00:00
|
|
|
|
2020-11-27 20:51:52 +00:00
|
|
|
Repeater {
|
|
|
|
id: stickerPackListView
|
2023-04-12 10:31:35 +00:00
|
|
|
property string selectedPackId
|
2022-11-23 13:40:03 +00:00
|
|
|
model: d.stickerPackList
|
|
|
|
visible: d.stickerPacksLoaded
|
2020-09-29 08:41:27 +00:00
|
|
|
|
2020-11-27 20:51:52 +00:00
|
|
|
delegate: StatusStickerPackIconWithIndicator {
|
|
|
|
id: packIconWithIndicator
|
|
|
|
visible: installed
|
2023-06-07 13:18:29 +00:00
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2020-11-27 20:51:52 +00:00
|
|
|
selected: stickerPackListView.selectedPackId === packId
|
2022-02-14 23:27:23 +00:00
|
|
|
source: thumbnail
|
2020-11-27 20:51:52 +00:00
|
|
|
onClicked: {
|
2022-04-11 16:17:42 +00:00
|
|
|
btnHistory.highlighted = false
|
2020-11-27 20:51:52 +00:00
|
|
|
stickerPackListView.selectedPackId = packId
|
|
|
|
stickerGrid.model = stickers
|
|
|
|
}
|
2020-09-29 08:41:27 +00:00
|
|
|
}
|
|
|
|
}
|
2020-12-14 07:01:09 +00:00
|
|
|
Repeater {
|
|
|
|
id: loadingStickerPackListView
|
2022-11-23 13:40:03 +00:00
|
|
|
model: d.stickerPacksLoading ? 7 : 0
|
2020-12-14 07:01:09 +00:00
|
|
|
|
|
|
|
delegate: Rectangle {
|
2023-06-07 13:18:29 +00:00
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2023-04-12 10:38:38 +00:00
|
|
|
Layout.preferredWidth: 24
|
|
|
|
Layout.preferredHeight: 24
|
2020-12-14 07:01:09 +00:00
|
|
|
radius: width / 2
|
|
|
|
color: Style.current.backgroundHover
|
|
|
|
}
|
|
|
|
}
|
2022-08-10 07:51:04 +00:00
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2020-09-29 08:41:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|