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 1
13 16
icons/globe.png icons/globe.png
icons/ic_add.png icons/ic_add.png
icons/ic_add_bookmarks.png
icons/ic_favorite.png
icons/ic_reload.png icons/ic_reload.png
icons/ic_reply.png icons/ic_reply.png
icons/ic_reply_all.png icons/ic_reply_all.png
icons/ic_to_bottom.png 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
main.qml main.qml
moment.js moment.js
NewPostSheet.qml NewPostSheet.qml

View file

@ -24,45 +24,89 @@ import "moment.js" as Moment
Container { Container {
id: postitem id: postitem
leftPadding: 20.0 leftPadding: ui.sdu(3.0)
rightPadding: 20.0 rightPadding: ui.sdu(3.0)
topPadding: 10.0 topPadding: ui.sdu(2.0)
bottomPadding: 10.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 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 { Container {
layout: StackLayout { layout: DockLayout {}
orientation: LayoutOrientation.LeftToRight horizontalAlignment: HorizontalAlignment.Fill
}
Container { Container {
WebImageView { layout: StackLayout {
id: avatar orientation: LayoutOrientation.LeftToRight
url: ListItemData.user.content.avatar_image.link
maxWidth: 100.0
maxHeight: avatar.maxWidth
//imageSource: "asset:///laughing_man.png"
} }
}
Container {
leftMargin: 20.0
Container { Container {
Label { WebImageView {
id: name id: avatar
text: ListItemData.user.name url: ListItemData.user.content.avatar_image.link
textStyle.fontWeight: FontWeight.Bold maxWidth: 100.0
maxHeight: avatar.maxWidth
//imageSource: "asset:///icons/laughing_man.png"
} }
} }
Container { Container {
Label { leftMargin: ui.sdu(3.0)
id: username Container {
text: ListItemData.user.username Label {
id: name
text: ListItemData.user.name
textStyle.fontWeight: FontWeight.Bold
}
}
Container {
Label {
id: username
text: ListItemData.user.username
}
}
}
}
Container {
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 { Container {
topMargin: 20.0 topMargin: ui.sdu(2.0)
bottomMargin: 20.0 bottomMargin: ui.sdu(2.0)
Label { Label {
text: ListItemData.content.text text: ListItemData.content.text
multiline: true multiline: true
@ -73,20 +117,22 @@ Container {
horizontalAlignment: HorizontalAlignment.Fill horizontalAlignment: HorizontalAlignment.Fill
Container { Container {
horizontalAlignment: HorizontalAlignment.Left horizontalAlignment: HorizontalAlignment.Left
Label { Label { // "Sep 23, 2016 7:17 AM"
text: Moment.moment(ListItemData.created_at).format("lll") text: Moment.moment(ListItemData.created_at).format("lll")
textStyle.fontSize: FontSize.XSmall textStyle.fontSize: FontSize.XSmall
} }
} }
Container { Container {
horizontalAlignment: HorizontalAlignment.Right horizontalAlignment: HorizontalAlignment.Right
Label { Label { // "Broadsword Hack"
text: ListItemData.source.name text: ListItemData.source.name
textStyle.fontSize: FontSize.XSmall textStyle.fontSize: FontSize.XSmall
} }
} }
} }
Divider {} Divider {
accessibility.name: "divider"
}
contextActions: [ contextActions: [
ActionSet { ActionSet {
title: ListItemData.user.username title: ListItemData.user.username
@ -100,7 +146,7 @@ Container {
imageSource: "asset:///icons/ic_reply.png" imageSource: "asset:///icons/ic_reply.png"
} }
ActionItem { ActionItem {
title: "Reply All" title: qsTr("Reply All")
onTriggered: { onTriggered: {
replySheet.text = "@" + ListItemData.user.username + " " + parseMentions(ListItemData.content.entities.mentions); replySheet.text = "@" + ListItemData.user.username + " " + parseMentions(ListItemData.content.entities.mentions);
console.log(JSON.stringify(ListItemData.content.entities.mentions)) console.log(JSON.stringify(ListItemData.content.entities.mentions))
@ -120,11 +166,10 @@ Container {
} }
] ]
function parseMentions(mentions) { function parseMentions(mentions) {
console.log("blarp")
var mtext = "" var mtext = ""
for(var i = 0; i < mentions.length; i++) { for(var i = 0; i < mentions.length; i++) {
var mu = mentions[i].text var mu = mentions[i].text
if (mu !== "thrrgilag") { if (mu !== postitem.ListItem.view.getUserName()) {
mtext += "@" + mu + " " mtext += "@" + mu + " "
} }
} }

View file

@ -43,6 +43,9 @@ NavigationPane {
function sendReply(text, pid) { function sendReply(text, pid) {
pnut.sendReply(text, pid); pnut.sendReply(text, pid);
} }
function getUserName() {
return _app.setting("username")
}
} }
} }
actions: [ actions: [
@ -96,10 +99,6 @@ NavigationPane {
actionBarAutoHideBehavior: ActionBarAutoHideBehavior.HideOnScroll actionBarAutoHideBehavior: ActionBarAutoHideBehavior.HideOnScroll
} }
attachedObjects: [ attachedObjects: [
ComponentDefinition {
id: itemPageDefinition
source: "ItemPage.qml"
},
NewPostSheet { NewPostSheet {
id: newPostSheet id: newPostSheet
onSendPost: { onSendPost: {
@ -153,6 +152,7 @@ NavigationPane {
break; break;
} }
if (_app.setting("access_token") && _app.setting("access_token").length > 0) { if (_app.setting("access_token") && _app.setting("access_token").length > 0) {
pnut.getUserInfo();
pnut.getStream(endpoint, Pnut.STREAM_OLDER); pnut.getStream(endpoint, Pnut.STREAM_OLDER);
timer.start(); timer.start();
} else { } 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/StreamTab.qml) \
$$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_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) \
$$quote($$BASEDIR/assets/icons/ic_reply_all.png) \ $$quote($$BASEDIR/assets/icons/ic_reply_all.png) \
$$quote($$BASEDIR/assets/icons/ic_to_bottom.png) \ $$quote($$BASEDIR/assets/icons/ic_to_bottom.png) \
$$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/main.qml) \ $$quote($$BASEDIR/assets/main.qml) \
$$quote($$BASEDIR/assets/moment.js) $$quote($$BASEDIR/assets/moment.js)
} }

View file

@ -116,6 +116,7 @@ void Pnut::onAuthorizationReceived(QString token, QString verifier)
case KQOAuthManager::NoError: case KQOAuthManager::NoError:
qDebug() << "- authorization received -"; qDebug() << "- authorization received -";
m_appSettings->setValue("access_token", token); m_appSettings->setValue("access_token", token);
getUserInfo();
emit authorizationReceived(); emit authorizationReceived();
break; break;
default: default:
@ -142,13 +143,16 @@ void Pnut::onAuthorizedRequestReady(QByteArray data, int id)
{ {
case Pnut::OK: case Pnut::OK:
{ {
// qDebug() << ":: OK";
if (endpoint.startsWith("/posts/streams/")) if (endpoint.startsWith("/posts/streams/"))
{ {
Pnut::RequestType rtype = rtype_map[id]; Pnut::RequestType rtype = rtype_map[id];
emit streamReceived(variant.toMap()["data"].toList(), rtype); emit streamReceived(variant.toMap()["data"].toList(), rtype);
req_map.remove(id); req_map.remove(id);
rtype_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; break;
} }
@ -217,3 +221,19 @@ void Pnut::sendReply(QString text, int pid)
req_map[++req_id] = "/posts"; req_map[++req_id] = "/posts";
postRequest(url, parameters, req_id, post); 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 getStream(QString endpoint, Pnut::RequestType rtype);
Q_INVOKABLE void sendPost(QString text); Q_INVOKABLE void sendPost(QString text);
Q_INVOKABLE void sendReply(QString text, int pid); Q_INVOKABLE void sendReply(QString text, int pid);
Q_INVOKABLE void getUser(QString uid);
Q_INVOKABLE void getUserInfo();
public slots: public slots:
void onAuthorizedRequestReady(QByteArray data, int id); void onAuthorizedRequestReady(QByteArray data, int id);

View file

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