2017-06-22 15:49:39 +03:00
|
|
|
import QtQuick 2.2
|
2017-06-07 08:56:42 +03:00
|
|
|
import Sailfish.Silica 1.0
|
|
|
|
import "../../lib/API.js" as Logic
|
|
|
|
import "."
|
|
|
|
|
2020-05-29 21:05:05 +03:00
|
|
|
|
2017-06-07 08:56:42 +03:00
|
|
|
SilicaListView {
|
|
|
|
id: myList
|
2020-06-04 12:17:06 +03:00
|
|
|
|
2020-05-29 21:05:05 +03:00
|
|
|
property string type
|
2017-06-07 08:56:42 +03:00
|
|
|
property string title
|
|
|
|
property string description
|
|
|
|
property ListModel mdl: []
|
|
|
|
property variant params: []
|
|
|
|
property var locale: Qt.locale()
|
2020-05-29 21:05:05 +03:00
|
|
|
property bool autoLoadMore: true
|
|
|
|
property bool loadStarted: false
|
|
|
|
property int scrollOffset
|
2017-06-07 08:56:42 +03:00
|
|
|
property string action: ""
|
|
|
|
property variant vars
|
|
|
|
property variant conf
|
2020-05-29 21:05:05 +03:00
|
|
|
property bool notifier: false
|
2020-06-04 20:44:12 +03:00
|
|
|
|
2017-06-07 08:56:42 +03:00
|
|
|
model: mdl
|
2020-06-04 12:17:06 +03:00
|
|
|
|
2017-06-07 08:56:42 +03:00
|
|
|
signal notify (string what, int num)
|
|
|
|
onNotify: {
|
|
|
|
console.log(what + " - " + num)
|
|
|
|
}
|
|
|
|
signal openDrawer (bool setDrawer)
|
|
|
|
onOpenDrawer: {
|
|
|
|
//console.log("Open drawer: " + setDrawer)
|
|
|
|
}
|
|
|
|
signal send (string notice)
|
|
|
|
onSend: {
|
|
|
|
console.log("LIST send signal emitted with notice: " + notice)
|
|
|
|
}
|
|
|
|
|
|
|
|
header: PageHeader {
|
|
|
|
title: myList.title
|
|
|
|
description: myList.description
|
|
|
|
}
|
|
|
|
|
2020-07-06 11:28:42 +03:00
|
|
|
BusyLabel {
|
2020-07-12 10:12:34 +03:00
|
|
|
id: myListBusyLabel
|
2020-07-06 11:28:42 +03:00
|
|
|
running: model.count === 0
|
|
|
|
anchors {
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
}
|
2020-07-12 10:12:34 +03:00
|
|
|
|
|
|
|
Timer {
|
|
|
|
interval: 5000
|
|
|
|
running: true
|
|
|
|
onTriggered: {
|
|
|
|
myListBusyLabel.visible = false
|
|
|
|
loadStatusPlaceholder.visible = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ViewPlaceholder {
|
|
|
|
id: loadStatusPlaceholder
|
|
|
|
visible: false
|
|
|
|
enabled: model.count === 0
|
|
|
|
text: qsTr("Nothing found")
|
2017-06-07 08:56:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
PullDownMenu {
|
2020-07-12 10:12:34 +03:00
|
|
|
id: mainPulleyMenu
|
2017-06-07 08:56:42 +03:00
|
|
|
MenuItem {
|
2017-07-20 13:14:16 +03:00
|
|
|
text: qsTr("Settings")
|
2020-06-29 11:48:06 +03:00
|
|
|
visible: !profilePage
|
2017-06-07 08:56:42 +03:00
|
|
|
onClicked: {
|
2020-05-29 21:05:05 +03:00
|
|
|
pageStack.push(Qt.resolvedUrl("../SettingsPage.qml"), {})
|
2017-06-07 08:56:42 +03:00
|
|
|
}
|
|
|
|
}
|
2020-06-03 08:34:33 +03:00
|
|
|
|
2020-06-05 19:38:15 +03:00
|
|
|
MenuItem {
|
|
|
|
text: qsTr("New Toot")
|
2020-06-29 11:48:06 +03:00
|
|
|
visible: !profilePage
|
2020-06-05 19:38:15 +03:00
|
|
|
onClicked: {
|
|
|
|
pageStack.push(Qt.resolvedUrl("../ConversationPage.qml"), {
|
2020-06-15 11:42:10 +03:00
|
|
|
headerTitle: qsTr("New Toot"),
|
2020-06-05 19:38:15 +03:00
|
|
|
type: "new"
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-29 11:48:06 +03:00
|
|
|
MenuItem {
|
|
|
|
text: qsTr("Open in Browser")
|
|
|
|
visible: !mainPage
|
|
|
|
onClicked: {
|
|
|
|
Qt.openUrlExternally(url)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-07 08:56:42 +03:00
|
|
|
MenuItem {
|
2020-06-22 21:13:05 +03:00
|
|
|
text: qsTr("Reload")
|
2017-06-07 08:56:42 +03:00
|
|
|
onClicked: {
|
|
|
|
loadData("prepend")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-19 11:16:13 +03:00
|
|
|
delegate: VisualContainer {}
|
2017-06-07 08:56:42 +03:00
|
|
|
|
|
|
|
add: Transition {
|
|
|
|
NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: 800 }
|
|
|
|
NumberAnimation { property: "x"; duration: 800; easing.type: Easing.InOutBack }
|
|
|
|
}
|
|
|
|
|
2017-07-06 17:15:12 +03:00
|
|
|
remove: Transition {
|
2017-06-07 08:56:42 +03:00
|
|
|
NumberAnimation { properties: "x,y"; duration: 800; easing.type: Easing.InOutBack }
|
|
|
|
}
|
|
|
|
|
|
|
|
onCountChanged: {
|
2020-05-29 21:05:05 +03:00
|
|
|
loadStarted = false
|
2017-06-16 17:45:04 +03:00
|
|
|
/*contentY = scrollOffset
|
|
|
|
console.log("CountChanged!")*/
|
2017-06-07 08:56:42 +03:00
|
|
|
}
|
2017-10-26 00:45:15 +03:00
|
|
|
|
2020-06-22 21:13:05 +03:00
|
|
|
footer: Item {
|
2017-11-01 02:27:48 +03:00
|
|
|
visible: autoLoadMore
|
2017-06-16 17:45:04 +03:00
|
|
|
width: parent.width
|
|
|
|
height: Theme.itemSizeLarge
|
|
|
|
Button {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.margins: Theme.paddingSmall
|
|
|
|
anchors.bottomMargin: Theme.paddingLarge
|
|
|
|
visible: false
|
|
|
|
onClicked: {
|
|
|
|
loadData("append")
|
2017-10-25 01:37:33 +03:00
|
|
|
}
|
2017-06-16 17:45:04 +03:00
|
|
|
}
|
2020-06-04 12:17:06 +03:00
|
|
|
|
2017-06-16 17:45:04 +03:00
|
|
|
BusyIndicator {
|
2020-07-06 11:28:42 +03:00
|
|
|
running: loadStarted
|
2020-07-12 10:12:34 +03:00
|
|
|
visible: myListBusyLabel.running ? false : true
|
2017-06-16 17:45:04 +03:00
|
|
|
size: BusyIndicatorSize.Small
|
2020-07-06 11:28:42 +03:00
|
|
|
anchors {
|
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
2017-06-16 17:45:04 +03:00
|
|
|
}
|
|
|
|
}
|
2020-06-04 12:17:06 +03:00
|
|
|
|
2017-06-07 08:56:42 +03:00
|
|
|
onContentYChanged: {
|
2017-07-04 17:57:50 +03:00
|
|
|
if (Math.abs(contentY - scrollOffset) > Theme.itemSizeMedium) {
|
|
|
|
openDrawer(contentY - scrollOffset > 0 ? false : true )
|
|
|
|
scrollOffset = contentY
|
2017-06-07 08:56:42 +03:00
|
|
|
}
|
2020-06-18 09:32:52 +03:00
|
|
|
if(contentY+height > footerItem.y && !loadStarted && autoLoadMore) {
|
2017-06-16 17:45:04 +03:00
|
|
|
loadData("append")
|
2020-05-29 21:05:05 +03:00
|
|
|
loadStarted = true
|
2017-06-16 17:45:04 +03:00
|
|
|
}
|
2017-06-07 08:56:42 +03:00
|
|
|
}
|
2020-05-29 21:05:05 +03:00
|
|
|
|
2017-06-07 08:56:42 +03:00
|
|
|
VerticalScrollDecorator {}
|
|
|
|
|
|
|
|
WorkerScript {
|
|
|
|
id: worker
|
|
|
|
source: "../../lib/Worker.js"
|
|
|
|
onMessage: {
|
|
|
|
if (messageObject.error){
|
|
|
|
console.log(JSON.stringify(messageObject))
|
|
|
|
}
|
2017-06-14 17:42:28 +03:00
|
|
|
if (messageObject.fireNotification && notifier){
|
2017-10-26 00:45:15 +03:00
|
|
|
Logic.notifier(messageObject.data)
|
2017-06-07 08:56:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
2017-06-22 15:49:39 +03:00
|
|
|
loadData("prepend")
|
2017-06-07 08:56:42 +03:00
|
|
|
}
|
2017-06-14 17:42:28 +03:00
|
|
|
|
|
|
|
Timer {
|
2017-06-15 01:48:53 +03:00
|
|
|
triggeredOnStart: false; interval: 5*60*1000; running: true; repeat: true
|
2017-06-14 17:42:28 +03:00
|
|
|
onTriggered: {
|
|
|
|
console.log(title + ' ' +Date().toString())
|
|
|
|
loadData("prepend")
|
|
|
|
}
|
|
|
|
}
|
2020-06-04 12:17:06 +03:00
|
|
|
|
2020-06-18 09:32:52 +03:00
|
|
|
function loadData(mode) {
|
2020-05-29 21:05:05 +03:00
|
|
|
var p = []
|
2020-07-06 11:28:42 +03:00
|
|
|
if (params.length) {
|
2017-10-27 17:44:35 +03:00
|
|
|
for(var i = 0; i<params.length; i++)
|
|
|
|
p.push(params[i])
|
2020-07-06 11:28:42 +03:00
|
|
|
}
|
2020-06-18 09:32:52 +03:00
|
|
|
if (mode === "append" && model.count) {
|
2020-05-29 21:05:05 +03:00
|
|
|
p.push({name: 'max_id', data: model.get(model.count-1).id})
|
2017-06-07 08:56:42 +03:00
|
|
|
}
|
2020-06-18 09:32:52 +03:00
|
|
|
if (mode === "prepend" && model.count) {
|
2020-05-29 21:05:05 +03:00
|
|
|
p.push({name:'since_id', data: model.get(0).id})
|
2017-06-07 08:56:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
var msg = {
|
|
|
|
'action' : type,
|
|
|
|
'params' : p,
|
|
|
|
'model' : model,
|
|
|
|
'mode' : mode,
|
|
|
|
'conf' : Logic.conf
|
2020-07-03 11:45:30 +03:00
|
|
|
}
|
2020-06-22 21:13:05 +03:00
|
|
|
|
2018-05-24 12:14:02 +03:00
|
|
|
console.log(JSON.stringify(msg))
|
2017-06-22 15:49:39 +03:00
|
|
|
if (type !== "")
|
2020-05-29 21:05:05 +03:00
|
|
|
worker.sendMessage(msg)
|
2017-06-07 08:56:42 +03:00
|
|
|
}
|
|
|
|
}
|