start user profile display
This commit is contained in:
parent
d8fc66aa1e
commit
f2edbba4cf
11 changed files with 264 additions and 16 deletions
|
@ -1,9 +1,12 @@
|
|||
1
|
||||
27
|
||||
31
|
||||
icons/comments.png
|
||||
icons/default_cover.png
|
||||
icons/globe.png
|
||||
icons/ic_add.png
|
||||
icons/ic_add_bookmarks.png
|
||||
icons/ic_cancel.png
|
||||
icons/ic_compose.png
|
||||
icons/ic_del_bookmarks.png
|
||||
icons/ic_favorite.png
|
||||
icons/ic_reload.png
|
||||
|
@ -24,6 +27,7 @@ main.qml
|
|||
moment.js
|
||||
NewPostSheet.qml
|
||||
PostItem.qml
|
||||
ProfilePage.qml
|
||||
RefreshItem.qml
|
||||
StreamTab.qml
|
||||
ThreadPage.qml
|
||||
|
|
159
assets/ProfilePage.qml
Normal file
159
assets/ProfilePage.qml
Normal file
|
@ -0,0 +1,159 @@
|
|||
import bb.cascades 1.4
|
||||
import org.labsquare 1.0
|
||||
|
||||
Page {
|
||||
|
||||
property variant user
|
||||
property variant theme : Application.themeSupport.theme.colorTheme.style
|
||||
|
||||
signal follow(string uid)
|
||||
signal unfollow(string uid)
|
||||
|
||||
Container {
|
||||
Container {
|
||||
layout: DockLayout {}
|
||||
horizontalAlignment: HorizontalAlignment.Fill
|
||||
preferredHeight: cover.height
|
||||
Container {
|
||||
Container {
|
||||
opacity: 0.5
|
||||
WebImageView {
|
||||
id: cover
|
||||
preferredWidth: 1440
|
||||
scalingMethod: ScalingMethod.AspectFit
|
||||
//imageSource: "asset:///icons/default_cover.png"
|
||||
url: user.content.cover_image.link
|
||||
}
|
||||
}
|
||||
}
|
||||
Container {
|
||||
layout: StackLayout {
|
||||
orientation: LayoutOrientation.LeftToRight
|
||||
}
|
||||
topPadding: ui.sdu(3)
|
||||
leftPadding: ui.sdu(3)
|
||||
Container {
|
||||
background: (theme === VisualStyle.Bright) ? Color.create("#e9e9e9") : Color.create("#282828")
|
||||
WebImageView {
|
||||
//imageSource: "asset:///icons/laughing_man.png"
|
||||
url: user.content.avatar_image.link
|
||||
maxHeight: ui.du(14)
|
||||
maxWidth: ui.du(14)
|
||||
}
|
||||
}
|
||||
Container {
|
||||
leftPadding: ui.sdu(3)
|
||||
rightPadding: ui.sdu(3)
|
||||
horizontalAlignment: HorizontalAlignment.Fill
|
||||
//background: (theme === VisualStyle.Bright) ? Color.create("#e9e9e9") : Color.create("#282828")
|
||||
Container {
|
||||
Label {
|
||||
//text: "Morgan McMillian"
|
||||
text: user.name
|
||||
textStyle.fontWeight: FontWeight.Bold
|
||||
textStyle.fontSize: FontSize.Large
|
||||
|
||||
}
|
||||
}
|
||||
Container {
|
||||
Label {
|
||||
//text: "thrrgilag"
|
||||
text: user.username
|
||||
textStyle.fontSize: FontSize.Medium
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Container {
|
||||
topPadding: ui.sdu(3)
|
||||
leftPadding: ui.sdu(3)
|
||||
layout: DockLayout {}
|
||||
horizontalAlignment: HorizontalAlignment.Fill
|
||||
Container {
|
||||
Label {
|
||||
//text: "Bio goes here."
|
||||
text: user.content.text
|
||||
multiline: true
|
||||
}
|
||||
}
|
||||
Container {
|
||||
horizontalAlignment: HorizontalAlignment.Right
|
||||
rightPadding: ui.sdu(3)
|
||||
Container {
|
||||
layout: StackLayout {
|
||||
orientation: LayoutOrientation.LeftToRight
|
||||
}
|
||||
horizontalAlignment: HorizontalAlignment.Right
|
||||
Label {
|
||||
text: qsTr("Following")
|
||||
|
||||
}
|
||||
Label {
|
||||
text: user.counts.following
|
||||
}
|
||||
}
|
||||
Container {
|
||||
layout: StackLayout {
|
||||
orientation: LayoutOrientation.LeftToRight
|
||||
}
|
||||
horizontalAlignment: HorizontalAlignment.Right
|
||||
Label {
|
||||
text: qsTr("Followers")
|
||||
|
||||
}
|
||||
Label {
|
||||
text: user.counts.followers
|
||||
}
|
||||
}
|
||||
Container {
|
||||
layout: StackLayout {
|
||||
orientation: LayoutOrientation.LeftToRight
|
||||
}
|
||||
horizontalAlignment: HorizontalAlignment.Right
|
||||
Label {
|
||||
text: qsTr("Posts")
|
||||
|
||||
}
|
||||
Label {
|
||||
text: user.counts.posts
|
||||
}
|
||||
}
|
||||
Container {
|
||||
layout: StackLayout {
|
||||
orientation: LayoutOrientation.LeftToRight
|
||||
}
|
||||
horizontalAlignment: HorizontalAlignment.Right
|
||||
Label {
|
||||
text: qsTr("Bookmarks")
|
||||
|
||||
}
|
||||
Label {
|
||||
text: user.counts.bookmarks
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
actions: [
|
||||
ActionItem {
|
||||
title: (user.you_follow) ? qsTr("Unfollow") : qsTr("Follow")
|
||||
ActionBar.placement: ActionBarPlacement.OnBar
|
||||
onTriggered: {
|
||||
if (user.you_follow) {
|
||||
unfollow(user.id)
|
||||
} else {
|
||||
follow(user.id)
|
||||
}
|
||||
}
|
||||
imageSource: (user.you_follow) ? "asset:///icons/ic_cancel.png" : "asset:///icons/ic_add.png"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -51,6 +51,14 @@ NavigationPane {
|
|||
pnut.getThread(postModel.data(indexPath).thread_id);
|
||||
nav.push(page);
|
||||
}
|
||||
function viewProfile(userobj) {
|
||||
console.log("narf: " + JSON.stringify(userobj))
|
||||
var page = profilePage.createObject();
|
||||
page.user = userobj
|
||||
page.follow.connect(pnut.followUser)
|
||||
page.unfollow.connect(pnut.unfollowUser)
|
||||
nav.push(page);
|
||||
}
|
||||
function sendReply(text, pid) {
|
||||
pnut.sendReply(text, pid);
|
||||
}
|
||||
|
@ -79,7 +87,7 @@ NavigationPane {
|
|||
newPostSheet.open();
|
||||
newPostSheet.input.requestFocus();
|
||||
}
|
||||
imageSource: "asset:///icons/ic_add.png"
|
||||
imageSource: "asset:///icons/ic_compose.png"
|
||||
},
|
||||
ActionItem {
|
||||
title: qsTr("Load Newer")
|
||||
|
@ -117,6 +125,10 @@ NavigationPane {
|
|||
id: threadPage
|
||||
source: "ThreadPage.qml"
|
||||
},
|
||||
ComponentDefinition {
|
||||
id: profilePage
|
||||
source: "ProfilePage.qml"
|
||||
},
|
||||
NewPostSheet {
|
||||
id: newPostSheet
|
||||
onSendPost: {
|
||||
|
@ -143,12 +155,12 @@ NavigationPane {
|
|||
onStreamReceived: {
|
||||
switch (rtype) {
|
||||
case Pnut.STREAM_OLDER:
|
||||
streamView.scrollToPosition(ScrollPosition.End, ScrollAnimation.None);
|
||||
//streamView.scrollToPosition(ScrollPosition.End, ScrollAnimation.None);
|
||||
postModel.append(stream);
|
||||
break;
|
||||
case Pnut.STREAM_NEWER:
|
||||
postModel.insert(0, stream);
|
||||
streamView.scrollToPosition(ScrollPosition.Beginning, ScrollAnimation.None);
|
||||
//streamView.scrollToPosition(ScrollPosition.Beginning, ScrollAnimation.None);
|
||||
break;
|
||||
}
|
||||
pnut.beforeId = postModel.value(postModel.size() - 1).id;
|
||||
|
|
BIN
assets/icons/default_cover.png
Normal file
BIN
assets/icons/default_cover.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
BIN
assets/icons/ic_cancel.png
Normal file
BIN
assets/icons/ic_cancel.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
BIN
assets/icons/ic_compose.png
Normal file
BIN
assets/icons/ic_compose.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
2
buildnum
2
buildnum
|
@ -1 +1 @@
|
|||
85
|
||||
117
|
|
@ -69,13 +69,17 @@ config_pri_assets {
|
|||
$$quote($$BASEDIR/assets/LoginSheet.qml) \
|
||||
$$quote($$BASEDIR/assets/NewPostSheet.qml) \
|
||||
$$quote($$BASEDIR/assets/PostItem.qml) \
|
||||
$$quote($$BASEDIR/assets/ProfilePage.qml) \
|
||||
$$quote($$BASEDIR/assets/RefreshItem.qml) \
|
||||
$$quote($$BASEDIR/assets/StreamTab.qml) \
|
||||
$$quote($$BASEDIR/assets/ThreadPage.qml) \
|
||||
$$quote($$BASEDIR/assets/icons/comments.png) \
|
||||
$$quote($$BASEDIR/assets/icons/default_cover.png) \
|
||||
$$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_cancel.png) \
|
||||
$$quote($$BASEDIR/assets/icons/ic_compose.png) \
|
||||
$$quote($$BASEDIR/assets/icons/ic_del_bookmarks.png) \
|
||||
$$quote($$BASEDIR/assets/icons/ic_favorite.png) \
|
||||
$$quote($$BASEDIR/assets/icons/ic_reload.png) \
|
||||
|
|
32
src/Pnut.cpp
32
src/Pnut.cpp
|
@ -221,6 +221,22 @@ void Pnut::onAuthorizedRequestReady(QByteArray data, int id)
|
|||
m_appSettings->remove("username");
|
||||
emit authorizationRequired();
|
||||
}
|
||||
else if (endpoint == ":follow")
|
||||
{
|
||||
qDebug() << "Follow successful!";
|
||||
req_map.remove(id);
|
||||
emit followSuccess(data);
|
||||
}
|
||||
else if (endpoint == ":unfollow")
|
||||
{
|
||||
qDebug() << "Unfollow successful!";
|
||||
req_map.remove(id);
|
||||
emit unfollowSuccess(data);
|
||||
}
|
||||
else {
|
||||
qDebug() << "GOT SOMETHING NEW!";
|
||||
qDebug() << endpoint;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Pnut::CREATED:
|
||||
|
@ -356,3 +372,19 @@ void Pnut::logout()
|
|||
req_map[++req_id] = ":logout";
|
||||
deleteRequest(url, parameters, req_id);
|
||||
}
|
||||
|
||||
void Pnut::followUser(QString uid)
|
||||
{
|
||||
QUrl url(PNUT_API_ROOT + "/users/" + uid + "/follow");
|
||||
KQOAuthParameters parameters;
|
||||
req_map[++req_id] = ":follow";
|
||||
putRequest(url, parameters, req_id);
|
||||
}
|
||||
|
||||
void Pnut::unfollowUser(QString uid)
|
||||
{
|
||||
QUrl url(PNUT_API_ROOT + "/users/" + uid + "/follow");
|
||||
KQOAuthParameters parameters;
|
||||
req_map[++req_id] = ":unfollow";
|
||||
deleteRequest(url, parameters, req_id);
|
||||
}
|
||||
|
|
|
@ -70,6 +70,8 @@ public:
|
|||
Q_INVOKABLE void sendPost(QString text);
|
||||
Q_INVOKABLE void sendReply(QString text, int pid);
|
||||
Q_INVOKABLE void getUser(QString uid);
|
||||
Q_INVOKABLE void followUser(QString uid);
|
||||
Q_INVOKABLE void unfollowUser(QString uid);
|
||||
Q_INVOKABLE void getUserInfo();
|
||||
Q_INVOKABLE void getThread(QString pid);
|
||||
Q_INVOKABLE void setBookmark(QString pid);
|
||||
|
@ -88,6 +90,8 @@ Q_SIGNALS:
|
|||
void authorizationReceived();
|
||||
void streamReceived(QVariantList stream, Pnut::RequestType rtype);
|
||||
void threadReceived(QVariantList thread);
|
||||
void followSuccess(QByteArray user);
|
||||
void unfollowSuccess(QByteArray user);
|
||||
|
||||
private:
|
||||
static const QString PNUT_API_ROOT;
|
||||
|
|
|
@ -30,41 +30,74 @@
|
|||
<context>
|
||||
<name>PostItem</name>
|
||||
<message>
|
||||
<location filename="../assets/PostItem.qml" line="158"/>
|
||||
<location filename="../assets/PostItem.qml" line="166"/>
|
||||
<source>Reply</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../assets/PostItem.qml" line="167"/>
|
||||
<location filename="../assets/PostItem.qml" line="175"/>
|
||||
<source>Reply All</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../assets/PostItem.qml" line="177"/>
|
||||
<location filename="../assets/PostItem.qml" line="185"/>
|
||||
<source>Add Bookmark</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../assets/PostItem.qml" line="177"/>
|
||||
<location filename="../assets/PostItem.qml" line="185"/>
|
||||
<source>Delete Bookmark</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../assets/PostItem.qml" line="188"/>
|
||||
<location filename="../assets/PostItem.qml" line="196"/>
|
||||
<source>Repost</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../assets/PostItem.qml" line="188"/>
|
||||
<location filename="../assets/PostItem.qml" line="196"/>
|
||||
<source>Delete Repost</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../assets/PostItem.qml" line="199"/>
|
||||
<location filename="../assets/PostItem.qml" line="207"/>
|
||||
<source>Quote</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProfilePage</name>
|
||||
<message>
|
||||
<location filename="../assets/ProfilePage.qml" line="93"/>
|
||||
<source>Following</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../assets/ProfilePage.qml" line="106"/>
|
||||
<source>Followers</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../assets/ProfilePage.qml" line="119"/>
|
||||
<source>Posts</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../assets/ProfilePage.qml" line="132"/>
|
||||
<source>Bookmarks</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../assets/ProfilePage.qml" line="147"/>
|
||||
<source>Unfollow</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../assets/ProfilePage.qml" line="147"/>
|
||||
<source>Follow</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RefreshItem</name>
|
||||
<message>
|
||||
|
@ -76,22 +109,22 @@
|
|||
<context>
|
||||
<name>StreamTab</name>
|
||||
<message>
|
||||
<location filename="../assets/StreamTab.qml" line="76"/>
|
||||
<location filename="../assets/StreamTab.qml" line="86"/>
|
||||
<source>New Post</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../assets/StreamTab.qml" line="85"/>
|
||||
<location filename="../assets/StreamTab.qml" line="95"/>
|
||||
<source>Load Newer</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../assets/StreamTab.qml" line="93"/>
|
||||
<location filename="../assets/StreamTab.qml" line="103"/>
|
||||
<source>Reload</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../assets/StreamTab.qml" line="104"/>
|
||||
<location filename="../assets/StreamTab.qml" line="114"/>
|
||||
<source>Load Older</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
Reference in a new issue