2021-07-21 08:26:31 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import QtGraphicalEffects 1.0
|
2021-10-21 15:07:13 +00:00
|
|
|
|
2021-07-21 08:26:31 +00:00
|
|
|
import StatusQ.Components 0.1
|
2021-10-25 11:48:23 +00:00
|
|
|
import StatusQ.Controls 0.1
|
2024-07-12 09:46:43 +00:00
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Backpressure 0.1
|
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
|
2021-12-08 21:20:43 +00:00
|
|
|
import shared.stores 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.controls 1.0
|
2021-07-21 08:26:31 +00:00
|
|
|
|
2022-08-30 16:33:43 +00:00
|
|
|
import "./StatusGifPopup"
|
|
|
|
|
2021-07-21 08:26:31 +00:00
|
|
|
Popup {
|
2022-08-16 08:55:56 +00:00
|
|
|
id: root
|
|
|
|
|
2021-07-21 08:26:31 +00:00
|
|
|
property var gifSelected: function () {}
|
|
|
|
property var searchGif: Backpressure.debounce(searchBox, 500, function (query) {
|
2022-01-13 08:58:42 +00:00
|
|
|
RootStore.searchGifs(query)
|
2022-08-16 08:55:56 +00:00
|
|
|
})
|
2021-08-03 08:48:06 +00:00
|
|
|
property var toggleCategory: function(newCategory) {
|
|
|
|
previousCategory = currentCategory
|
|
|
|
currentCategory = newCategory
|
|
|
|
searchBox.text = ""
|
2022-08-30 16:33:43 +00:00
|
|
|
if (currentCategory === GifPopupDefinitions.Category.Trending) {
|
2022-01-13 08:58:42 +00:00
|
|
|
RootStore.getTrendingsGifs()
|
2022-08-30 16:33:43 +00:00
|
|
|
} else if(currentCategory === GifPopupDefinitions.Category.Favorite) {
|
2022-01-13 08:58:42 +00:00
|
|
|
RootStore.getFavoritesGifs()
|
2022-08-30 16:33:43 +00:00
|
|
|
} else if(currentCategory === GifPopupDefinitions.Category.Recent) {
|
2022-01-13 08:58:42 +00:00
|
|
|
RootStore.getRecentsGifs()
|
|
|
|
}
|
2021-08-03 08:48:06 +00:00
|
|
|
}
|
|
|
|
property var toggleFavorite: function(item) {
|
2022-08-30 16:33:43 +00:00
|
|
|
RootStore.toggleFavoriteGif(item.id, currentCategory === GifPopupDefinitions.Category.Favorite)
|
2021-08-03 08:48:06 +00:00
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
property alias searchString: searchBox.text
|
2022-08-30 16:33:43 +00:00
|
|
|
property int currentCategory: GifPopupDefinitions.Category.Trending
|
|
|
|
property int previousCategory: GifPopupDefinitions.Category.Trending
|
2023-03-20 18:58:20 +00:00
|
|
|
property bool loading: RootStore.gifLoading
|
2021-08-03 08:48:06 +00:00
|
|
|
|
2021-07-21 08:26:31 +00:00
|
|
|
modal: false
|
|
|
|
width: 360
|
|
|
|
|
|
|
|
background: Rectangle {
|
|
|
|
radius: Style.current.radius
|
|
|
|
color: Style.current.background
|
|
|
|
border.color: Style.current.border
|
|
|
|
layer.enabled: true
|
2022-07-05 07:20:57 +00:00
|
|
|
layer.effect: DropShadow {
|
2021-07-21 08:26:31 +00:00
|
|
|
verticalOffset: 3
|
|
|
|
radius: 8
|
|
|
|
samples: 15
|
|
|
|
cached: true
|
|
|
|
color: "#22000000"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-03 22:12:17 +00:00
|
|
|
onAboutToShow: {
|
2021-07-21 08:26:31 +00:00
|
|
|
searchBox.text = ""
|
2022-07-05 07:20:57 +00:00
|
|
|
searchBox.input.edit.forceActiveFocus()
|
2023-10-18 09:03:32 +00:00
|
|
|
if (RootStore.gifUnfurlingEnabled) {
|
2022-01-13 08:58:42 +00:00
|
|
|
RootStore.getTrendingsGifs()
|
2021-08-02 07:11:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onClosed: {
|
2022-08-30 16:33:43 +00:00
|
|
|
root.currentCategory = GifPopupDefinitions.Category.Trending
|
|
|
|
root.previousCategory = GifPopupDefinitions.Category.Trending
|
2021-09-20 12:19:20 +00:00
|
|
|
|
2022-08-30 16:33:43 +00:00
|
|
|
if (confirmationPopupLoader.active) {
|
|
|
|
confirmationPopupLoader.active = false
|
2021-08-02 07:11:28 +00:00
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
}
|
|
|
|
|
2023-05-31 20:58:23 +00:00
|
|
|
padding: 0
|
|
|
|
|
|
|
|
Item {
|
2021-07-21 08:26:31 +00:00
|
|
|
anchors.fill: parent
|
2022-08-16 08:55:56 +00:00
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
Item {
|
2022-10-03 22:12:17 +00:00
|
|
|
readonly property int headerMargin: 8
|
2022-08-16 08:55:56 +00:00
|
|
|
|
|
|
|
id: gifHeader
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: searchBox.height + gifHeader.headerMargin
|
|
|
|
|
|
|
|
SearchBox {
|
|
|
|
id: searchBox
|
|
|
|
placeholderText: qsTr("Search")
|
2023-10-18 09:03:32 +00:00
|
|
|
enabled: RootStore.gifUnfurlingEnabled
|
2022-08-16 08:55:56 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: gifHeader.headerMargin
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: gifHeader.headerMargin
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: gifHeader.headerMargin
|
2022-10-03 22:12:17 +00:00
|
|
|
input.edit.onTextChanged: {
|
2022-08-16 08:55:56 +00:00
|
|
|
if (searchBox.text === "") {
|
2022-10-03 22:12:17 +00:00
|
|
|
toggleCategory(GifPopupDefinitions.Category.Trending)
|
2022-08-16 08:55:56 +00:00
|
|
|
return
|
|
|
|
}
|
2022-08-30 16:33:43 +00:00
|
|
|
if (root.currentCategory !== GifPopupDefinitions.Category.Search) {
|
2022-08-16 08:55:56 +00:00
|
|
|
root.previousCategory = root.currentCategory
|
2022-08-30 16:33:43 +00:00
|
|
|
root.currentCategory = GifPopupDefinitions.Category.Search
|
2022-08-16 08:55:56 +00:00
|
|
|
}
|
|
|
|
Qt.callLater(searchGif, searchBox.text)
|
2021-08-03 08:48:06 +00:00
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-16 08:55:56 +00:00
|
|
|
StatusBaseText {
|
|
|
|
id: headerText
|
|
|
|
text: {
|
2022-08-30 16:33:43 +00:00
|
|
|
if (currentCategory === GifPopupDefinitions.Category.Trending) {
|
2022-08-16 08:55:56 +00:00
|
|
|
return qsTr("TRENDING")
|
2022-08-30 16:33:43 +00:00
|
|
|
} else if(currentCategory === GifPopupDefinitions.Category.Favorite) {
|
2022-08-16 08:55:56 +00:00
|
|
|
return qsTr("FAVORITES")
|
2022-08-30 16:33:43 +00:00
|
|
|
} else if(currentCategory === GifPopupDefinitions.Category.Recent) {
|
2022-08-16 08:55:56 +00:00
|
|
|
return qsTr("RECENT")
|
|
|
|
}
|
|
|
|
return ""
|
2021-08-03 08:48:06 +00:00
|
|
|
}
|
2022-08-16 08:55:56 +00:00
|
|
|
visible: searchBox.text === ""
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
font.pixelSize: 13
|
|
|
|
topPadding: gifHeader.headerMargin
|
|
|
|
leftPadding: gifHeader.headerMargin
|
2021-08-03 08:48:06 +00:00
|
|
|
}
|
2021-08-02 07:11:28 +00:00
|
|
|
|
2022-08-16 08:55:56 +00:00
|
|
|
Loader {
|
|
|
|
id: gifsLoader
|
2023-10-18 09:03:32 +00:00
|
|
|
active: root.opened && RootStore.gifUnfurlingEnabled
|
2022-08-16 08:55:56 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
|
|
|
|
Layout.preferredHeight: {
|
|
|
|
const headerTextHeight = searchBox.text === "" ? headerText.height : 0
|
|
|
|
return 400 - gifHeader.height - headerTextHeight
|
|
|
|
}
|
2022-08-30 16:33:43 +00:00
|
|
|
sourceComponent: RootStore.gifColumnA.rowCount() === 0 ? emptyPlaceholderComponent : gifItemsComponent
|
2021-08-03 08:48:06 +00:00
|
|
|
}
|
2021-10-25 11:48:23 +00:00
|
|
|
|
2022-08-16 08:55:56 +00:00
|
|
|
Row {
|
|
|
|
id: categorySelector
|
|
|
|
Layout.fillWidth: true
|
|
|
|
leftPadding: Style.current.smallPadding / 2
|
|
|
|
rightPadding: Style.current.smallPadding / 2
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
|
|
|
|
StatusTabBarIconButton {
|
|
|
|
icon.name: "flash"
|
2022-08-30 16:33:43 +00:00
|
|
|
highlighted: GifPopupDefinitions.Category.Trending === root.currentCategory
|
2022-08-16 08:55:56 +00:00
|
|
|
onClicked: {
|
2022-08-30 16:33:43 +00:00
|
|
|
toggleCategory(GifPopupDefinitions.Category.Trending)
|
2022-08-16 08:55:56 +00:00
|
|
|
}
|
2023-10-18 09:03:32 +00:00
|
|
|
enabled: RootStore.gifUnfurlingEnabled
|
2021-08-03 08:48:06 +00:00
|
|
|
}
|
2021-10-25 11:48:23 +00:00
|
|
|
|
2022-08-16 08:55:56 +00:00
|
|
|
StatusTabBarIconButton {
|
|
|
|
icon.name: "time"
|
2022-08-30 16:33:43 +00:00
|
|
|
highlighted: GifPopupDefinitions.Category.Recent === root.currentCategory
|
2022-08-16 08:55:56 +00:00
|
|
|
onClicked: {
|
2022-08-30 16:33:43 +00:00
|
|
|
toggleCategory(GifPopupDefinitions.Category.Recent)
|
2022-08-16 08:55:56 +00:00
|
|
|
}
|
2023-10-18 09:03:32 +00:00
|
|
|
enabled: RootStore.gifUnfurlingEnabled
|
2021-08-03 08:48:06 +00:00
|
|
|
}
|
2021-10-25 11:48:23 +00:00
|
|
|
|
2022-08-16 08:55:56 +00:00
|
|
|
StatusTabBarIconButton {
|
|
|
|
icon.name: "favourite"
|
2022-08-30 16:33:43 +00:00
|
|
|
highlighted: GifPopupDefinitions.Category.Favorite === root.currentCategory
|
2022-08-16 08:55:56 +00:00
|
|
|
onClicked: {
|
2022-08-30 16:33:43 +00:00
|
|
|
toggleCategory(GifPopupDefinitions.Category.Favorite)
|
2022-08-16 08:55:56 +00:00
|
|
|
}
|
2023-10-18 09:03:32 +00:00
|
|
|
enabled: RootStore.gifUnfurlingEnabled
|
2021-08-03 08:48:06 +00:00
|
|
|
}
|
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
}
|
2022-08-16 08:55:56 +00:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
color: 'black'
|
|
|
|
opacity: 0.4
|
|
|
|
radius: Style.current.radius
|
|
|
|
anchors.fill: parent
|
2022-08-30 16:33:43 +00:00
|
|
|
visible: confirmationPopupLoader.active
|
2022-08-16 08:55:56 +00:00
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
}
|
|
|
|
|
2022-08-30 16:33:43 +00:00
|
|
|
Loader {
|
|
|
|
id: confirmationPopupLoader
|
2022-08-16 08:55:56 +00:00
|
|
|
|
2021-08-02 07:11:28 +00:00
|
|
|
anchors.centerIn: parent
|
|
|
|
|
2022-08-30 16:33:43 +00:00
|
|
|
sourceComponent: ConfirmationPopup {
|
|
|
|
visible: true
|
2021-08-02 07:11:28 +00:00
|
|
|
}
|
2023-10-18 09:03:32 +00:00
|
|
|
active: !RootStore.gifUnfurlingEnabled
|
2021-07-21 08:26:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
2022-08-30 16:33:43 +00:00
|
|
|
id: gifItemsComponent
|
2021-09-20 08:20:05 +00:00
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
StatusScrollView {
|
2023-05-31 20:58:23 +00:00
|
|
|
id: scrollView
|
|
|
|
contentWidth: availableWidth
|
2021-07-21 08:26:31 +00:00
|
|
|
|
2021-07-29 13:33:22 +00:00
|
|
|
Row {
|
2021-09-23 02:52:17 +00:00
|
|
|
id: gifs
|
2023-05-31 20:58:23 +00:00
|
|
|
width: scrollView.availableWidth
|
2021-08-02 07:11:28 +00:00
|
|
|
spacing: Style.current.halfPadding
|
2021-07-21 08:26:31 +00:00
|
|
|
|
2021-09-23 02:52:17 +00:00
|
|
|
property string lastHoveredId
|
|
|
|
|
2021-07-29 13:33:22 +00:00
|
|
|
StatusGifColumn {
|
2022-01-13 08:58:42 +00:00
|
|
|
gifList.model: RootStore.gifColumnA
|
2022-08-16 08:55:56 +00:00
|
|
|
gifWidth: (root.width / 3) - Style.current.padding
|
|
|
|
gifSelected: root.gifSelected
|
|
|
|
toggleFavorite: root.toggleFavorite
|
2021-09-23 02:52:17 +00:00
|
|
|
lastHoveredId: gifs.lastHoveredId
|
2022-01-13 08:58:42 +00:00
|
|
|
store: RootStore
|
2021-09-23 02:52:17 +00:00
|
|
|
onGifHovered: {
|
|
|
|
gifs.lastHoveredId = id
|
|
|
|
}
|
2021-07-29 13:33:22 +00:00
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
|
2021-07-29 13:33:22 +00:00
|
|
|
StatusGifColumn {
|
2022-01-13 08:58:42 +00:00
|
|
|
gifList.model: RootStore.gifColumnB
|
2022-08-16 08:55:56 +00:00
|
|
|
gifWidth: (root.width / 3) - Style.current.padding
|
|
|
|
gifSelected: root.gifSelected
|
|
|
|
toggleFavorite: root.toggleFavorite
|
2021-09-23 02:52:17 +00:00
|
|
|
lastHoveredId: gifs.lastHoveredId
|
2022-01-13 08:58:42 +00:00
|
|
|
store: RootStore
|
2021-09-23 02:52:17 +00:00
|
|
|
onGifHovered: {
|
|
|
|
gifs.lastHoveredId = id
|
|
|
|
}
|
2021-07-29 13:33:22 +00:00
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
|
2021-07-29 13:33:22 +00:00
|
|
|
StatusGifColumn {
|
2022-01-13 08:58:42 +00:00
|
|
|
gifList.model: RootStore.gifColumnC
|
2022-08-16 08:55:56 +00:00
|
|
|
gifWidth: (root.width / 3) - Style.current.padding
|
|
|
|
gifSelected: root.gifSelected
|
|
|
|
toggleFavorite: root.toggleFavorite
|
2021-09-23 02:52:17 +00:00
|
|
|
lastHoveredId: gifs.lastHoveredId
|
2022-01-13 08:58:42 +00:00
|
|
|
store: RootStore
|
2021-09-23 02:52:17 +00:00
|
|
|
onGifHovered: {
|
|
|
|
gifs.lastHoveredId = id
|
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-08-30 16:33:43 +00:00
|
|
|
|
|
|
|
Component {
|
|
|
|
id: emptyPlaceholderComponent
|
|
|
|
|
|
|
|
EmptyPlaceholder {
|
2023-05-31 20:58:23 +00:00
|
|
|
Layout.margins: Style.current.smallPadding
|
2022-08-30 16:33:43 +00:00
|
|
|
currentCategory: root.currentCategory
|
2023-03-20 18:58:20 +00:00
|
|
|
loading: root.loading
|
2022-08-30 16:33:43 +00:00
|
|
|
onDoRetry: searchBox.text === ""
|
|
|
|
? RootStore.getTrendingsGifs()
|
|
|
|
: searchGif(searchBox.text)
|
|
|
|
}
|
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
}
|