added status icons to post item and adjusted spaciing and removed

hardcoded username in mention parsing
This commit is contained in:
Morgan McMillian 2016-09-23 12:33:16 -07:00
parent 70f6309314
commit fcf50dc6d0
11 changed files with 122 additions and 44 deletions

View file

@ -1,13 +1,16 @@
1
13
16
icons/globe.png
icons/ic_add.png
icons/ic_add_bookmarks.png
icons/ic_favorite.png
icons/ic_reload.png
icons/ic_reply.png
icons/ic_reply_all.png
icons/ic_to_bottom.png
icons/ic_to_top.png
icons/laughing_man.png
icons/messages.png
main.qml
moment.js
NewPostSheet.qml

View file

@ -24,12 +24,17 @@ import "moment.js" as Moment
Container {
id: postitem
leftPadding: 20.0
rightPadding: 20.0
topPadding: 10.0
bottomPadding: 10.0
leftPadding: ui.sdu(3.0)
rightPadding: ui.sdu(3.0)
topPadding: ui.sdu(2.0)
bottomPadding: ui.sdu(2.0)
property string lorem: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse non enim tellus. Donec vestibulum enim urna, eget faucibus diam commodo a. Donec eget hendrerit metus. Pellentesque vehicula nisi nec vehicula ullamcorper. Aliquam a elit eget mi fringilla porta fermentum eget eros. Phasellus vestibulum nulla sed elit congue adipiscing. Cras imperdiet urna ac ipsum volutpat lobortis. Maecenas vehicula tortor at viverra convallis. Curabitur nibh massa, tristique id felis ut, venenatis faucibus dui. Donec fringilla, mi nec tincidunt dignissim, neque nunc semper mi, quis rutrum diam turpis sit amet erat. Cras a sodales nisi. Nunc sit amet diam sed lectus molestie cursus convallis et erat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Duis vitae varius leo. Mauris eu leo a nunc bibendum rutrum euismod et ipsum. "
property variant theme : Application.themeSupport.theme.colorTheme.style
Container {
layout: DockLayout {}
horizontalAlignment: HorizontalAlignment.Fill
Container {
layout: StackLayout {
orientation: LayoutOrientation.LeftToRight
@ -40,11 +45,11 @@ Container {
url: ListItemData.user.content.avatar_image.link
maxWidth: 100.0
maxHeight: avatar.maxWidth
//imageSource: "asset:///laughing_man.png"
//imageSource: "asset:///icons/laughing_man.png"
}
}
Container {
leftMargin: 20.0
leftMargin: ui.sdu(3.0)
Container {
Label {
id: name
@ -61,8 +66,47 @@ Container {
}
}
Container {
topMargin: 20.0
bottomMargin: 20.0
horizontalAlignment: HorizontalAlignment.Right
Container {
layout: StackLayout {
orientation: LayoutOrientation.RightToLeft
}
horizontalAlignment: HorizontalAlignment.Fill
topMargin: ui.sdu(1.0)
Container {
ImageView {
visible: (ListItemData.counts.threads > 0 || ListItemData.counts.replies > 0 || ListItemData.id !== ListItemData.thread_id)
imageSource: "asset:///icons/messages.png"
filterColor: (theme == VisualStyle.Bright) ? Color.Black : false
maxWidth: ui.du(6)
maxHeight: ui.du(6)
accessibility.name: "thread"
}
}
Container {
verticalAlignment: VerticalAlignment.Bottom
Label {
text: (ListItemData.counts.bookmarks > 0) ? ListItemData.counts.bookmarks : ""
textStyle.fontSize: FontSize.XXSmall
}
}
Container {
ImageView {
visible: (ListItemData.counts.bookmarks > 0)
imageSource: "asset:///icons/ic_favorite.png"
filterColor: (theme == VisualStyle.Bright) ? Color.Black : false
maxWidth: ui.du(6)
maxHeight: ui.du(6)
accessibility.name: "favorite"
}
}
}
}
}
Container {
topMargin: ui.sdu(2.0)
bottomMargin: ui.sdu(2.0)
Label {
text: ListItemData.content.text
multiline: true
@ -73,20 +117,22 @@ Container {
horizontalAlignment: HorizontalAlignment.Fill
Container {
horizontalAlignment: HorizontalAlignment.Left
Label {
Label { // "Sep 23, 2016 7:17 AM"
text: Moment.moment(ListItemData.created_at).format("lll")
textStyle.fontSize: FontSize.XSmall
}
}
Container {
horizontalAlignment: HorizontalAlignment.Right
Label {
Label { // "Broadsword Hack"
text: ListItemData.source.name
textStyle.fontSize: FontSize.XSmall
}
}
}
Divider {}
Divider {
accessibility.name: "divider"
}
contextActions: [
ActionSet {
title: ListItemData.user.username
@ -100,7 +146,7 @@ Container {
imageSource: "asset:///icons/ic_reply.png"
}
ActionItem {
title: "Reply All"
title: qsTr("Reply All")
onTriggered: {
replySheet.text = "@" + ListItemData.user.username + " " + parseMentions(ListItemData.content.entities.mentions);
console.log(JSON.stringify(ListItemData.content.entities.mentions))
@ -120,11 +166,10 @@ Container {
}
]
function parseMentions(mentions) {
console.log("blarp")
var mtext = ""
for(var i = 0; i < mentions.length; i++) {
var mu = mentions[i].text
if (mu !== "thrrgilag") {
if (mu !== postitem.ListItem.view.getUserName()) {
mtext += "@" + mu + " "
}
}

View file

@ -43,6 +43,9 @@ NavigationPane {
function sendReply(text, pid) {
pnut.sendReply(text, pid);
}
function getUserName() {
return _app.setting("username")
}
}
}
actions: [
@ -96,10 +99,6 @@ NavigationPane {
actionBarAutoHideBehavior: ActionBarAutoHideBehavior.HideOnScroll
}
attachedObjects: [
ComponentDefinition {
id: itemPageDefinition
source: "ItemPage.qml"
},
NewPostSheet {
id: newPostSheet
onSendPost: {
@ -153,6 +152,7 @@ NavigationPane {
break;
}
if (_app.setting("access_token") && _app.setting("access_token").length > 0) {
pnut.getUserInfo();
pnut.getStream(endpoint, Pnut.STREAM_OLDER);
timer.start();
} else {

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
assets/icons/messages.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -1 +1 @@
4
16

View file

@ -71,12 +71,15 @@ config_pri_assets {
$$quote($$BASEDIR/assets/StreamTab.qml) \
$$quote($$BASEDIR/assets/icons/globe.png) \
$$quote($$BASEDIR/assets/icons/ic_add.png) \
$$quote($$BASEDIR/assets/icons/ic_add_bookmarks.png) \
$$quote($$BASEDIR/assets/icons/ic_favorite.png) \
$$quote($$BASEDIR/assets/icons/ic_reload.png) \
$$quote($$BASEDIR/assets/icons/ic_reply.png) \
$$quote($$BASEDIR/assets/icons/ic_reply_all.png) \
$$quote($$BASEDIR/assets/icons/ic_to_bottom.png) \
$$quote($$BASEDIR/assets/icons/ic_to_top.png) \
$$quote($$BASEDIR/assets/icons/laughing_man.png) \
$$quote($$BASEDIR/assets/icons/messages.png) \
$$quote($$BASEDIR/assets/main.qml) \
$$quote($$BASEDIR/assets/moment.js)
}

View file

@ -116,6 +116,7 @@ void Pnut::onAuthorizationReceived(QString token, QString verifier)
case KQOAuthManager::NoError:
qDebug() << "- authorization received -";
m_appSettings->setValue("access_token", token);
getUserInfo();
emit authorizationReceived();
break;
default:
@ -142,13 +143,16 @@ void Pnut::onAuthorizedRequestReady(QByteArray data, int id)
{
case Pnut::OK:
{
// qDebug() << ":: OK";
if (endpoint.startsWith("/posts/streams/"))
{
Pnut::RequestType rtype = rtype_map[id];
emit streamReceived(variant.toMap()["data"].toList(), rtype);
req_map.remove(id);
rtype_map.remove(id);
} else if (endpoint == ":me")
{
QVariantMap userinfo(variant.toMap()["data"].toMap());
m_appSettings->setValue("username", userinfo.value("username").toString());
}
break;
}
@ -217,3 +221,19 @@ void Pnut::sendReply(QString text, int pid)
req_map[++req_id] = "/posts";
postRequest(url, parameters, req_id, post);
}
void Pnut::getUser(QString uid)
{
QUrl url(PNUT_API_ROOT + "/users/" + uid);
KQOAuthParameters parameters;
req_map[++req_id] = "/users/" + uid;
getRequest(url, parameters, req_id);
}
void Pnut::getUserInfo()
{
QUrl url(PNUT_API_ROOT + "/users/me");
KQOAuthParameters parameters;
req_map[++req_id] = ":me";
getRequest(url, parameters, req_id);
}

View file

@ -69,6 +69,8 @@ public:
Q_INVOKABLE void getStream(QString endpoint, Pnut::RequestType rtype);
Q_INVOKABLE void sendPost(QString text);
Q_INVOKABLE void sendReply(QString text, int pid);
Q_INVOKABLE void getUser(QString uid);
Q_INVOKABLE void getUserInfo();
public slots:
void onAuthorizedRequestReady(QByteArray data, int id);

View file

@ -22,35 +22,40 @@
<context>
<name>PostItem</name>
<message>
<location filename="../assets/PostItem.qml" line="94"/>
<location filename="../assets/PostItem.qml" line="140"/>
<source>Reply</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/PostItem.qml" line="149"/>
<source>Reply All</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>StreamTab</name>
<message>
<location filename="../assets/StreamTab.qml" line="50"/>
<location filename="../assets/StreamTab.qml" line="53"/>
<source>New Post</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/StreamTab.qml" line="59"/>
<location filename="../assets/StreamTab.qml" line="62"/>
<source>Load Newer</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/StreamTab.qml" line="67"/>
<location filename="../assets/StreamTab.qml" line="70"/>
<source>Reload</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/StreamTab.qml" line="78"/>
<location filename="../assets/StreamTab.qml" line="81"/>
<source>Load Older</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/StreamTab.qml" line="86"/>
<location filename="../assets/StreamTab.qml" line="89"/>
<source>Logout</source>
<translation type="unfinished"></translation>
</message>