app cover and infinite scrolling
This commit is contained in:
parent
305457091e
commit
81b1874e6e
10 changed files with 182 additions and 17 deletions
|
@ -1,5 +1,6 @@
|
||||||
1
|
1
|
||||||
35
|
36
|
||||||
|
AppCover.qml
|
||||||
icons/bell-slash.png
|
icons/bell-slash.png
|
||||||
icons/bell.png
|
icons/bell.png
|
||||||
icons/comments.png
|
icons/comments.png
|
||||||
|
|
30
assets/AppCover.qml
Normal file
30
assets/AppCover.qml
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
import bb.cascades 1.4
|
||||||
|
|
||||||
|
Container {
|
||||||
|
topPadding: ui.du(3)
|
||||||
|
leftPadding: ui.du(3)
|
||||||
|
Container {
|
||||||
|
layout: StackLayout {
|
||||||
|
orientation: LayoutOrientation.LeftToRight
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
text: "Unread global:"
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
objectName: "global_label"
|
||||||
|
text: "0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Container {
|
||||||
|
layout: StackLayout {
|
||||||
|
orientation: LayoutOrientation.LeftToRight
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
text: "Unread home:"
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
objectName: "home_label"
|
||||||
|
text: "0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,6 +26,7 @@ NavigationPane {
|
||||||
|
|
||||||
property string stream_type
|
property string stream_type
|
||||||
property string endpoint
|
property string endpoint
|
||||||
|
property int unread: -1
|
||||||
property bool refreshpull: false
|
property bool refreshpull: false
|
||||||
|
|
||||||
Page {
|
Page {
|
||||||
|
@ -83,6 +84,23 @@ NavigationPane {
|
||||||
function delRepost(pid) {
|
function delRepost(pid) {
|
||||||
pnut.deleteRepost(pid);
|
pnut.deleteRepost(pid);
|
||||||
}
|
}
|
||||||
|
attachedObjects: [
|
||||||
|
ListScrollStateHandler {
|
||||||
|
onAtEndChanged: {
|
||||||
|
if (atEnd) {
|
||||||
|
console.log("I'm at the end!!!")
|
||||||
|
pnut.getStream(endpoint, Pnut.STREAM_OLDER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onAtBeginningChanged: {
|
||||||
|
if (atBeginning) {
|
||||||
|
console.log("I'm at the top!!!")
|
||||||
|
unread = 0
|
||||||
|
nav.parent.unreadContentCount = unread
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
actions: [
|
actions: [
|
||||||
|
@ -94,15 +112,26 @@ NavigationPane {
|
||||||
newPostSheet.input.requestFocus();
|
newPostSheet.input.requestFocus();
|
||||||
}
|
}
|
||||||
imageSource: "asset:///icons/ic_compose.png"
|
imageSource: "asset:///icons/ic_compose.png"
|
||||||
|
shortcuts: [
|
||||||
|
SystemShortcut {
|
||||||
|
type: SystemShortcuts.CreateNew
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
ActionItem {
|
ActionItem {
|
||||||
title: qsTr("Load Newer")
|
title: qsTr("To Top")
|
||||||
ActionBar.placement: ActionBarPlacement.InOverflow
|
ActionBar.placement: ActionBarPlacement.InOverflow
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
refreshpull = true
|
//refreshpull = true
|
||||||
pnut.getStream(endpoint, Pnut.STREAM_NEWER);
|
//pnut.getStream(endpoint, Pnut.STREAM_NEWER);
|
||||||
|
streamView.scrollToPosition(ScrollPosition.Beginning, ScrollAnimation.None);
|
||||||
}
|
}
|
||||||
imageSource: "asset:///icons/ic_to_top.png"
|
imageSource: "asset:///icons/ic_to_top.png"
|
||||||
|
shortcuts: [
|
||||||
|
SystemShortcut {
|
||||||
|
type: SystemShortcuts.JumpToTop
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
ActionItem {
|
ActionItem {
|
||||||
title: qsTr("Reload")
|
title: qsTr("Reload")
|
||||||
|
@ -116,13 +145,18 @@ NavigationPane {
|
||||||
imageSource: "asset:///icons/ic_reload.png"
|
imageSource: "asset:///icons/ic_reload.png"
|
||||||
},
|
},
|
||||||
ActionItem {
|
ActionItem {
|
||||||
title: qsTr("Load Older")
|
title: qsTr("To Bottom")
|
||||||
ActionBar.placement: ActionBarPlacement.InOverflow
|
ActionBar.placement: ActionBarPlacement.InOverflow
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
streamView.scrollToPosition(ScrollPosition.End, ScrollAnimation.None);
|
streamView.scrollToPosition(ScrollPosition.End, ScrollAnimation.None);
|
||||||
pnut.getStream(endpoint, Pnut.STREAM_OLDER);
|
//pnut.getStream(endpoint, Pnut.STREAM_OLDER);
|
||||||
}
|
}
|
||||||
imageSource: "asset:///icons/ic_to_bottom.png"
|
imageSource: "asset:///icons/ic_to_bottom.png"
|
||||||
|
shortcuts: [
|
||||||
|
SystemShortcut {
|
||||||
|
type: SystemShortcuts.JumpToBottom
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
actionBarAutoHideBehavior: ActionBarAutoHideBehavior.HideOnScroll
|
actionBarAutoHideBehavior: ActionBarAutoHideBehavior.HideOnScroll
|
||||||
|
@ -161,6 +195,7 @@ NavigationPane {
|
||||||
id: pnut
|
id: pnut
|
||||||
|
|
||||||
onStreamReceived: {
|
onStreamReceived: {
|
||||||
|
//nav.parent.unreadContentCount = stream.length
|
||||||
switch (rtype) {
|
switch (rtype) {
|
||||||
case Pnut.STREAM_OLDER:
|
case Pnut.STREAM_OLDER:
|
||||||
//streamView.scrollToPosition(ScrollPosition.End, ScrollAnimation.None);
|
//streamView.scrollToPosition(ScrollPosition.End, ScrollAnimation.None);
|
||||||
|
@ -168,6 +203,9 @@ NavigationPane {
|
||||||
break;
|
break;
|
||||||
case Pnut.STREAM_NEWER:
|
case Pnut.STREAM_NEWER:
|
||||||
postModel.insert(0, stream);
|
postModel.insert(0, stream);
|
||||||
|
if (stream.length > 0) {
|
||||||
|
update_app_cover(stream.length)
|
||||||
|
}
|
||||||
if (refreshpull) {
|
if (refreshpull) {
|
||||||
refreshpull = false
|
refreshpull = false
|
||||||
streamView.scrollToPosition(ScrollPosition.Beginning, ScrollAnimation.None);
|
streamView.scrollToPosition(ScrollPosition.Beginning, ScrollAnimation.None);
|
||||||
|
@ -208,6 +246,15 @@ NavigationPane {
|
||||||
pnut.sinceId = 0
|
pnut.sinceId = 0
|
||||||
pnut.getStream(endpoint, Pnut.STREAM_OLDER)
|
pnut.getStream(endpoint, Pnut.STREAM_OLDER)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function update_app_cover(count) {
|
||||||
|
if (count > 0 && unread >=0) {
|
||||||
|
unread += count
|
||||||
|
} else {
|
||||||
|
unread = 0
|
||||||
|
}
|
||||||
|
nav.parent.unreadContentCount = unread
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
onPopTransitionEnded: {
|
onPopTransitionEnded: {
|
||||||
|
|
|
@ -50,6 +50,9 @@ TabbedPane {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
imageSource: "asset:///icons/home.png"
|
imageSource: "asset:///icons/home.png"
|
||||||
|
onUnreadContentCountChanged: {
|
||||||
|
_activeFrame.setHomeUnread(unreadContentCount)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Tab {
|
Tab {
|
||||||
|
@ -62,6 +65,9 @@ TabbedPane {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
imageSource: "asset:///icons/globe.png"
|
imageSource: "asset:///icons/globe.png"
|
||||||
|
onUnreadContentCountChanged: {
|
||||||
|
_activeFrame.setGlobalUnread(unreadContentCount)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
2
buildnum
2
buildnum
|
@ -1 +1 @@
|
||||||
128
|
138
|
|
@ -66,6 +66,7 @@ simulator {
|
||||||
|
|
||||||
config_pri_assets {
|
config_pri_assets {
|
||||||
OTHER_FILES += \
|
OTHER_FILES += \
|
||||||
|
$$quote($$BASEDIR/assets/AppCover.qml) \
|
||||||
$$quote($$BASEDIR/assets/LoginSheet.qml) \
|
$$quote($$BASEDIR/assets/LoginSheet.qml) \
|
||||||
$$quote($$BASEDIR/assets/NewPostSheet.qml) \
|
$$quote($$BASEDIR/assets/NewPostSheet.qml) \
|
||||||
$$quote($$BASEDIR/assets/PostItem.qml) \
|
$$quote($$BASEDIR/assets/PostItem.qml) \
|
||||||
|
@ -105,6 +106,7 @@ config_pri_assets {
|
||||||
|
|
||||||
config_pri_source_group1 {
|
config_pri_source_group1 {
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
$$quote($$BASEDIR/src/ActiveFrameQML.cpp) \
|
||||||
$$quote($$BASEDIR/src/Pnut.cpp) \
|
$$quote($$BASEDIR/src/Pnut.cpp) \
|
||||||
$$quote($$BASEDIR/src/Pnut_test.cpp) \
|
$$quote($$BASEDIR/src/Pnut_test.cpp) \
|
||||||
$$quote($$BASEDIR/src/WebImageView.cpp) \
|
$$quote($$BASEDIR/src/WebImageView.cpp) \
|
||||||
|
@ -112,6 +114,7 @@ config_pri_source_group1 {
|
||||||
$$quote($$BASEDIR/src/main.cpp)
|
$$quote($$BASEDIR/src/main.cpp)
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
|
$$quote($$BASEDIR/src/ActiveFrameQML.h) \
|
||||||
$$quote($$BASEDIR/src/Pnut.h) \
|
$$quote($$BASEDIR/src/Pnut.h) \
|
||||||
$$quote($$BASEDIR/src/WebImageView.h) \
|
$$quote($$BASEDIR/src/WebImageView.h) \
|
||||||
$$quote($$BASEDIR/src/applicationui.hpp) \
|
$$quote($$BASEDIR/src/applicationui.hpp) \
|
||||||
|
|
41
src/ActiveFrameQML.cpp
Normal file
41
src/ActiveFrameQML.cpp
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* ActiveFrameQML.cpp
|
||||||
|
*
|
||||||
|
* Created on: Oct 21, 2016
|
||||||
|
* Author: morga
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <src/ActiveFrameQML.h>
|
||||||
|
#include <bb/cascades/SceneCover>
|
||||||
|
#include <bb/cascades/Container>
|
||||||
|
#include <bb/cascades/Application>
|
||||||
|
#include <bb/cascades/QmlDocument>
|
||||||
|
|
||||||
|
using namespace bb::cascades;
|
||||||
|
|
||||||
|
ActiveFrameQML::ActiveFrameQML(QObject *parent) : SceneCover(parent)
|
||||||
|
{
|
||||||
|
QmlDocument *qml = QmlDocument::create("asset:///AppCover.qml").parent(parent);
|
||||||
|
Container *mainContainer = qml->createRootObject<Container>();
|
||||||
|
setContent(mainContainer);
|
||||||
|
|
||||||
|
global_unread_label = mainContainer->findChild<Label*>("global_label");
|
||||||
|
global_unread_label->setParent(mainContainer);
|
||||||
|
home_unread_label = mainContainer->findChild<Label*>("home_label");
|
||||||
|
home_unread_label->setParent(mainContainer);
|
||||||
|
}
|
||||||
|
|
||||||
|
ActiveFrameQML::~ActiveFrameQML()
|
||||||
|
{
|
||||||
|
// TODO Auto-generated destructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
void ActiveFrameQML::setGlobalUnread(QString count)
|
||||||
|
{
|
||||||
|
global_unread_label->setText(count);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ActiveFrameQML::setHomeUnread(QString count)
|
||||||
|
{
|
||||||
|
home_unread_label->setText(count);
|
||||||
|
}
|
32
src/ActiveFrameQML.h
Normal file
32
src/ActiveFrameQML.h
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* ActiveFrameQML.h
|
||||||
|
*
|
||||||
|
* Created on: Oct 21, 2016
|
||||||
|
* Author: morga
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ACTIVEFRAMEQML_H_
|
||||||
|
#define ACTIVEFRAMEQML_H_
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <bb/cascades/Label>
|
||||||
|
#include <bb/cascades/SceneCover>
|
||||||
|
|
||||||
|
using namespace ::bb::cascades;
|
||||||
|
|
||||||
|
class ActiveFrameQML: public SceneCover
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ActiveFrameQML(QObject *parent=0);
|
||||||
|
virtual ~ActiveFrameQML();
|
||||||
|
|
||||||
|
Q_INVOKABLE void setGlobalUnread(QString count);
|
||||||
|
Q_INVOKABLE void setHomeUnread(QString count);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bb::cascades::Label *global_unread_label;
|
||||||
|
bb::cascades::Label *home_unread_label;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* ACTIVEFRAMEQML_H_ */
|
|
@ -17,6 +17,7 @@
|
||||||
#include "applicationui.hpp"
|
#include "applicationui.hpp"
|
||||||
#include "Pnut.h"
|
#include "Pnut.h"
|
||||||
#include "WebImageView.h"
|
#include "WebImageView.h"
|
||||||
|
#include "ActiveFrameQML.h"
|
||||||
|
|
||||||
#include <bb/cascades/Application>
|
#include <bb/cascades/Application>
|
||||||
#include <bb/cascades/QmlDocument>
|
#include <bb/cascades/QmlDocument>
|
||||||
|
@ -54,6 +55,10 @@ ApplicationUI::ApplicationUI() :
|
||||||
|
|
||||||
qml->setContextProperty("_app", this);
|
qml->setContextProperty("_app", this);
|
||||||
|
|
||||||
|
ActiveFrameQML *activeFrame = new ActiveFrameQML();
|
||||||
|
Application::instance()->setCover(activeFrame);
|
||||||
|
qml->setContextProperty("_activeFrame", activeFrame);
|
||||||
|
|
||||||
// Create root object for the UI
|
// Create root object for the UI
|
||||||
AbstractPane *root = qml->createRootObject<AbstractPane>();
|
AbstractPane *root = qml->createRootObject<AbstractPane>();
|
||||||
|
|
||||||
|
|
|
@ -129,25 +129,25 @@
|
||||||
<context>
|
<context>
|
||||||
<name>StreamTab</name>
|
<name>StreamTab</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../assets/StreamTab.qml" line="90"/>
|
<location filename="../assets/StreamTab.qml" line="108"/>
|
||||||
<source>New Post</source>
|
<source>New Post</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../assets/StreamTab.qml" line="99"/>
|
<location filename="../assets/StreamTab.qml" line="117"/>
|
||||||
<source>Load Newer</source>
|
<source>To Top</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../assets/StreamTab.qml" line="108"/>
|
<location filename="../assets/StreamTab.qml" line="143"/>
|
||||||
|
<source>To Bottom</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../assets/StreamTab.qml" line="132"/>
|
||||||
<source>Reload</source>
|
<source>Reload</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<location filename="../assets/StreamTab.qml" line="119"/>
|
|
||||||
<source>Load Older</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>main</name>
|
<name>main</name>
|
||||||
|
@ -162,7 +162,7 @@
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../assets/main.qml" line="57"/>
|
<location filename="../assets/main.qml" line="60"/>
|
||||||
<source>Global</source>
|
<source>Global</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
Reference in a new issue