diff --git a/assets/.assets.index b/assets/.assets.index index a116554..32fa53d 100644 --- a/assets/.assets.index +++ b/assets/.assets.index @@ -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 diff --git a/assets/ProfilePage.qml b/assets/ProfilePage.qml new file mode 100644 index 0000000..873a14c --- /dev/null +++ b/assets/ProfilePage.qml @@ -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" + } + ] +} diff --git a/assets/StreamTab.qml b/assets/StreamTab.qml index 7b943da..44ba7fa 100644 --- a/assets/StreamTab.qml +++ b/assets/StreamTab.qml @@ -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; diff --git a/assets/icons/default_cover.png b/assets/icons/default_cover.png new file mode 100644 index 0000000..220c859 Binary files /dev/null and b/assets/icons/default_cover.png differ diff --git a/assets/icons/ic_cancel.png b/assets/icons/ic_cancel.png new file mode 100644 index 0000000..0780b21 Binary files /dev/null and b/assets/icons/ic_cancel.png differ diff --git a/assets/icons/ic_compose.png b/assets/icons/ic_compose.png new file mode 100644 index 0000000..8c71ad1 Binary files /dev/null and b/assets/icons/ic_compose.png differ diff --git a/buildnum b/buildnum index 615be70..1bda760 100644 --- a/buildnum +++ b/buildnum @@ -1 +1 @@ -85 \ No newline at end of file +117 \ No newline at end of file diff --git a/config.pri b/config.pri index 5d032b9..4d4df08 100644 --- a/config.pri +++ b/config.pri @@ -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) \ diff --git a/src/Pnut.cpp b/src/Pnut.cpp index 0514fcf..1157cc2 100644 --- a/src/Pnut.cpp +++ b/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); +} diff --git a/src/Pnut.h b/src/Pnut.h index e856cc5..d53e436 100644 --- a/src/Pnut.h +++ b/src/Pnut.h @@ -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; diff --git a/translations/Goober.ts b/translations/Goober.ts index ddbb1f1..9b72508 100644 --- a/translations/Goober.ts +++ b/translations/Goober.ts @@ -30,41 +30,74 @@ PostItem - + Reply - + Reply All - + Add Bookmark - + Delete Bookmark - + Repost - + Delete Repost - + Quote + + ProfilePage + + + Following + + + + + Followers + + + + + Posts + + + + + Bookmarks + + + + + Unfollow + + + + + Follow + + + RefreshItem @@ -76,22 +109,22 @@ StreamTab - + New Post - + Load Newer - + Reload - + Load Older