updated visuals, added pull to load new, add/remove bookmarks and reposts,

and quote a post.
This commit is contained in:
Morgan McMillian 2016-10-01 06:40:48 -07:00
parent 8a906ec60b
commit b80fafa99c
19 changed files with 198 additions and 45 deletions

View file

@ -1,8 +1,10 @@
1 1
17 25
icons/comments.png
icons/globe.png icons/globe.png
icons/ic_add.png icons/ic_add.png
icons/ic_add_bookmarks.png icons/ic_add_bookmarks.png
icons/ic_del_bookmarks.png
icons/ic_favorite.png icons/ic_favorite.png
icons/ic_reload.png icons/ic_reload.png
icons/ic_reply.png icons/ic_reply.png
@ -11,9 +13,15 @@ icons/ic_to_bottom.png
icons/ic_to_top.png icons/ic_to_top.png
icons/laughing_man.png icons/laughing_man.png
icons/messages.png icons/messages.png
icons/quote-left.png
icons/refresh.png
icons/retweet.png
icons/star-o.png
icons/star.png
main.qml main.qml
moment.js moment.js
NewPostSheet.qml NewPostSheet.qml
PostItem.qml PostItem.qml
RefreshItem.qml
StreamTab.qml StreamTab.qml
ThreadPage.qml ThreadPage.qml

View file

@ -75,8 +75,9 @@ Container {
topMargin: ui.sdu(1.0) topMargin: ui.sdu(1.0)
Container { Container {
ImageView { ImageView {
visible: (ListItemData.counts.threads > 0 || ListItemData.counts.replies > 0 || ListItemData.id !== ListItemData.thread_id) // (ListItemData.counts.threads > 0 || ListItemData.counts.replies > 0 || ListItemData.id !== ListItemData.thread_id)
imageSource: "asset:///icons/messages.png" visible: (ListItemData.counts.threads > 0 || ListItemData.id !== ListItemData.thread_id)
imageSource: "asset:///icons/comments.png"
filterColor: (theme == VisualStyle.Bright) ? Color.Black : false filterColor: (theme == VisualStyle.Bright) ? Color.Black : false
maxWidth: ui.du(6) maxWidth: ui.du(6)
maxHeight: ui.du(6) maxHeight: ui.du(6)
@ -99,7 +100,23 @@ Container {
maxHeight: ui.du(6) maxHeight: ui.du(6)
accessibility.name: "favorite" accessibility.name: "favorite"
} }
}
Container {
verticalAlignment: VerticalAlignment.Bottom
Label {
text: (ListItemData.counts.reposts > 0) ? ListItemData.counts.reposts : ""
textStyle.fontSize: FontSize.XXSmall
}
}
Container {
ImageView {
visible: (ListItemData.counts.reposts > 0)
imageSource: "asset:///icons/retweet.png"
filterColor: (theme == VisualStyle.Bright) ? Color.Black : false
maxWidth: ui.du(6)
maxHeight: ui.du(6)
accessibility.name: "repost"
}
} }
} }
} }
@ -157,12 +174,35 @@ Container {
imageSource: "asset:///icons/ic_reply_all.png" imageSource: "asset:///icons/ic_reply_all.png"
} }
ActionItem { ActionItem {
title: qsTr("Add Bookmark") title: (ListItemData.you_bookmarked) ? qsTr("Delete Bookmark") : qsTr("Add Bookmark")
imageSource: "asset:///icons/ic_add_bookmarks.png" imageSource: "asset:///icons/ic_favorite.png" //(ListItemData.you_bookmarked) ? "asset:///icons/star.png" : "asset:///icons/star-o.png"
onTriggered: { onTriggered: {
if (ListItemData.you_bookmarked) {
postitem.ListItem.view.delBookmark(ListItemData.id);
} else {
postitem.ListItem.view.addBookmark(ListItemData.id); postitem.ListItem.view.addBookmark(ListItemData.id);
} }
enabled: false }
}
ActionItem {
title: (ListItemData.you_reposted) ? qsTr("Delete Repost") : qsTr("Repost")
imageSource: "asset:///icons/retweet.png"
onTriggered: {
if (ListItemData.you_reposted) {
postitem.ListItem.view.delRepost(ListItemData.id);
} else {
postitem.ListItem.view.repost(ListItemData.id);
}
}
}
ActionItem {
title: qsTr("Quote")
imageSource: "asset:///icons/quote-left.png"
onTriggered: {
replySheet.text = " >> @" + ListItemData.user.username + ": " + ListItemData.content.text;
replySheet.open();
// replySheet.input.requestFocus();
}
} }
} }
] ]

29
assets/RefreshItem.qml Normal file
View file

@ -0,0 +1,29 @@
import bb.cascades 1.4
Container {
signal refresh
Label {
id: label_refresh
text: qsTr("Load Newer")
horizontalAlignment: HorizontalAlignment.Center
}
ImageView {
id: icon_refresh
imageSource: "asset:///icons/refresh.png"
horizontalAlignment: HorizontalAlignment.Center
filterColor: (theme == VisualStyle.Bright) ? Color.Black : false
}
Divider {}
attachedObjects: [
LayoutUpdateHandler {
onLayoutFrameChanged: {
icon_refresh.rotationZ = layoutFrame.y
if (layoutFrame.y >= 0.0 * layoutFrame.height) {
if (layoutFrame.y == 0) {
refresh()
}
}
}
}
]
}

View file

@ -34,6 +34,11 @@ NavigationPane {
dataModel: ArrayDataModel { dataModel: ArrayDataModel {
id: postModel id: postModel
} }
leadingVisual: RefreshItem {
onRefresh: {
pnut.getStream(endpoint, Pnut.STREAM_NEWER);
}
}
listItemComponents: [ listItemComponents: [
ListItemComponent { ListItemComponent {
id: root id: root
@ -53,8 +58,16 @@ NavigationPane {
return _app.setting("username"); return _app.setting("username");
} }
function addBookmark(pid) { function addBookmark(pid) {
// pnut.setBookmark(pid); pnut.setBookmark(pid);
console.log("- needs fixing -"); }
function delBookmark(pid) {
pnut.deleteBookmark(pid);
}
function repost(pid) {
pnut.repost(pid);
}
function delRepost(pid) {
pnut.deleteRepost(pid);
} }
} }
} }
@ -94,19 +107,10 @@ NavigationPane {
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"
},
ActionItem {
title: qsTr("Logout")
ActionBar.placement: ActionBarPlacement.InOverflow
onTriggered: {
postModel.clear()
pnut.beforeId = 0
pnut.sinceId = 0
_app.setSetting("access_token", "");
}
} }
] ]
actionBarAutoHideBehavior: ActionBarAutoHideBehavior.HideOnScroll actionBarAutoHideBehavior: ActionBarAutoHideBehavior.HideOnScroll
actionBarVisibility: ChromeVisibility.Overlay
} }
attachedObjects: [ attachedObjects: [
ComponentDefinition { ComponentDefinition {
@ -133,10 +137,12 @@ NavigationPane {
onStreamReceived: { onStreamReceived: {
switch (rtype) { switch (rtype) {
case Pnut.STREAM_OLDER: case Pnut.STREAM_OLDER:
streamView.scrollToPosition(ScrollPosition.End, ScrollAnimation.None);
postModel.append(stream); postModel.append(stream);
break; break;
case Pnut.STREAM_NEWER: case Pnut.STREAM_NEWER:
postModel.insert(0, stream); postModel.insert(0, stream);
streamView.scrollToPosition(ScrollPosition.Beginning, ScrollAnimation.None);
break; break;
} }
pnut.beforeId = postModel.value(postModel.size() - 1).id; pnut.beforeId = postModel.value(postModel.size() - 1).id;

BIN
assets/icons/comments.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
assets/icons/quote-left.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

BIN
assets/icons/refresh.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
assets/icons/retweet.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 834 B

BIN
assets/icons/sign-out.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 B

BIN
assets/icons/star-o.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
assets/icons/star.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

View file

@ -21,7 +21,23 @@ import bb.cascades 1.4
TabbedPane { TabbedPane {
id: main id: main
showTabsOnActionBar: false
Menu.definition: MenuDefinition {
settingsAction: SettingsActionItem {
onTriggered: {
//
}
}
actions: [
ActionItem {
title: qsTr("Logout")
imageSource: "asset:///icons/sign-out.png"
onTriggered: {
//
}
}
]
}
Tab { Tab {
id: globalStream id: globalStream

View file

@ -30,7 +30,7 @@
<configuration name="Device-Debug"> <configuration name="Device-Debug">
<platformArchitecture>armle-v7</platformArchitecture> <platformArchitecture>armle-v7</platformArchitecture>
<asset path="arm/o.le-v7-g/Goober" entry="true" type="Qnx/Elf">Goober</asset> <asset path="arm/o.le-v7-g/Goober" entry="true" type="Qnx/Elf">Goober</asset>
<asset path="C:/Users/morga/workspace/momentics-workspace/bb-cascades-oauth/oauth/o.le-v7/libkqoauth.so" type="Qnx/Elf">lib/libkqoauth.so.1</asset> <asset path="C:/Users/morga/workspace/momentics-workspace/bb-cascades-oauth/oauth/o.le-v7-g/libkqoauth.so" type="Qnx/Elf">lib/libkqoauth.so.1</asset>
</configuration> </configuration>
<configuration name="Device-Release"> <configuration name="Device-Release">
<entryPointType>Qnx/Cascades</entryPointType> <entryPointType>Qnx/Cascades</entryPointType>

View file

@ -1 +1 @@
38 71

View file

@ -68,11 +68,14 @@ config_pri_assets {
OTHER_FILES += \ OTHER_FILES += \
$$quote($$BASEDIR/assets/NewPostSheet.qml) \ $$quote($$BASEDIR/assets/NewPostSheet.qml) \
$$quote($$BASEDIR/assets/PostItem.qml) \ $$quote($$BASEDIR/assets/PostItem.qml) \
$$quote($$BASEDIR/assets/RefreshItem.qml) \
$$quote($$BASEDIR/assets/StreamTab.qml) \ $$quote($$BASEDIR/assets/StreamTab.qml) \
$$quote($$BASEDIR/assets/ThreadPage.qml) \ $$quote($$BASEDIR/assets/ThreadPage.qml) \
$$quote($$BASEDIR/assets/icons/comments.png) \
$$quote($$BASEDIR/assets/icons/globe.png) \ $$quote($$BASEDIR/assets/icons/globe.png) \
$$quote($$BASEDIR/assets/icons/ic_add.png) \ $$quote($$BASEDIR/assets/icons/ic_add.png) \
$$quote($$BASEDIR/assets/icons/ic_add_bookmarks.png) \ $$quote($$BASEDIR/assets/icons/ic_add_bookmarks.png) \
$$quote($$BASEDIR/assets/icons/ic_del_bookmarks.png) \
$$quote($$BASEDIR/assets/icons/ic_favorite.png) \ $$quote($$BASEDIR/assets/icons/ic_favorite.png) \
$$quote($$BASEDIR/assets/icons/ic_reload.png) \ $$quote($$BASEDIR/assets/icons/ic_reload.png) \
$$quote($$BASEDIR/assets/icons/ic_reply.png) \ $$quote($$BASEDIR/assets/icons/ic_reply.png) \
@ -81,6 +84,11 @@ config_pri_assets {
$$quote($$BASEDIR/assets/icons/ic_to_top.png) \ $$quote($$BASEDIR/assets/icons/ic_to_top.png) \
$$quote($$BASEDIR/assets/icons/laughing_man.png) \ $$quote($$BASEDIR/assets/icons/laughing_man.png) \
$$quote($$BASEDIR/assets/icons/messages.png) \ $$quote($$BASEDIR/assets/icons/messages.png) \
$$quote($$BASEDIR/assets/icons/quote-left.png) \
$$quote($$BASEDIR/assets/icons/refresh.png) \
$$quote($$BASEDIR/assets/icons/retweet.png) \
$$quote($$BASEDIR/assets/icons/star-o.png) \
$$quote($$BASEDIR/assets/icons/star.png) \
$$quote($$BASEDIR/assets/main.qml) \ $$quote($$BASEDIR/assets/main.qml) \
$$quote($$BASEDIR/assets/moment.js) $$quote($$BASEDIR/assets/moment.js)
} }

View file

@ -166,10 +166,11 @@ void Pnut::onRequestReady(QByteArray data)
switch (oauthManager->lastError()) switch (oauthManager->lastError())
{ {
case KQOAuthManager::NetworkError: case KQOAuthManager::NetworkError:
qDebug() << "- NetworkError - assume re-authorization"; qDebug() << "- NetworkError -";
m_appSettings->remove("access_token"); qDebug() << data;
m_appSettings->remove("username"); // m_appSettings->remove("access_token");
authorize(); // m_appSettings->remove("username");
// authorize();
break; break;
} }
} }
@ -177,10 +178,10 @@ void Pnut::onRequestReady(QByteArray data)
void Pnut::onAuthorizedRequestReady(QByteArray data, int id) void Pnut::onAuthorizedRequestReady(QByteArray data, int id)
{ {
QString endpoint = req_map[id]; QString endpoint = req_map[id];
// qDebug() << "- onAuthorizedRequestReady"; qDebug() << "- onAuthorizedRequestReady";
// qDebug() << "- id: " << id; qDebug() << "- id: " << id;
// qDebug() << "- endpoint: " << endpoint; qDebug() << "- endpoint: " << endpoint;
// qDebug() << data; qDebug() << data;
QVariant variant; QVariant variant;
bb::data::JsonDataAccess jda; bb::data::JsonDataAccess jda;
@ -316,3 +317,18 @@ void Pnut::deleteBookmark(QString pid)
req_map[++req_id] = ":bookmark"; req_map[++req_id] = ":bookmark";
deleteRequest(url, parameters, req_id); deleteRequest(url, parameters, req_id);
} }
void Pnut::repost(QString pid) {
QUrl url(PNUT_API_ROOT + "/posts/" + pid + "/repost");
KQOAuthParameters parameters;
req_map[++req_id] = ":repost";
putRequest(url, parameters, req_id);
}
void Pnut::deleteRepost(QString pid)
{
QUrl url(PNUT_API_ROOT + "/posts/" + pid + "/repost");
KQOAuthParameters parameters;
req_map[++req_id] = ":repost";
deleteRequest(url, parameters, req_id);
}

View file

@ -74,6 +74,8 @@ public:
Q_INVOKABLE void getThread(QString pid); Q_INVOKABLE void getThread(QString pid);
Q_INVOKABLE void setBookmark(QString pid); Q_INVOKABLE void setBookmark(QString pid);
Q_INVOKABLE void deleteBookmark(QString pid); Q_INVOKABLE void deleteBookmark(QString pid);
Q_INVOKABLE void repost(QString pid);
Q_INVOKABLE void deleteRepost(QString pid);
public slots: public slots:
void onRequestReady(QByteArray data); void onRequestReady(QByteArray data);

View file

@ -22,53 +22,81 @@
<context> <context>
<name>PostItem</name> <name>PostItem</name>
<message> <message>
<location filename="../assets/PostItem.qml" line="141"/> <location filename="../assets/PostItem.qml" line="158"/>
<source>Reply</source> <source>Reply</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/PostItem.qml" line="150"/> <location filename="../assets/PostItem.qml" line="167"/>
<source>Reply All</source> <source>Reply All</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/PostItem.qml" line="160"/> <location filename="../assets/PostItem.qml" line="177"/>
<source>Add Bookmark</source> <source>Add Bookmark</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="../assets/PostItem.qml" line="177"/>
<source>Delete Bookmark</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/PostItem.qml" line="188"/>
<source>Repost</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/PostItem.qml" line="188"/>
<source>Delete Repost</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/PostItem.qml" line="199"/>
<source>Quote</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RefreshItem</name>
<message>
<location filename="../assets/RefreshItem.qml" line="7"/>
<source>Load Newer</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>StreamTab</name> <name>StreamTab</name>
<message> <message>
<location filename="../assets/StreamTab.qml" line="63"/> <location filename="../assets/StreamTab.qml" line="76"/>
<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="72"/> <location filename="../assets/StreamTab.qml" line="85"/>
<source>Load Newer</source> <source>Load Newer</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/StreamTab.qml" line="80"/> <location filename="../assets/StreamTab.qml" line="93"/>
<source>Reload</source> <source>Reload</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/StreamTab.qml" line="91"/> <location filename="../assets/StreamTab.qml" line="104"/>
<source>Load Older</source> <source>Load Older</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="../assets/StreamTab.qml" line="99"/>
<source>Logout</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>main</name> <name>main</name>
<message> <message>
<location filename="../assets/main.qml" line="28"/> <location filename="../assets/main.qml" line="33"/>
<source>Logout</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/main.qml" line="43"/>
<source>Global</source> <source>Global</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>