diff --git a/assets/.assets.index b/assets/.assets.index index 3495f3d..4a5571a 100644 --- a/assets/.assets.index +++ b/assets/.assets.index @@ -1,5 +1,5 @@ 1 -43 +45 AboutPage.qml AppCover.qml icons/at.png @@ -43,3 +43,5 @@ RefreshItem.qml SettingsPage.qml StreamTab.qml ThreadPage.qml +UserItem.qml +UserPage.qml diff --git a/assets/ProfilePage.qml b/assets/ProfilePage.qml index b44e8e6..6a631a3 100644 --- a/assets/ProfilePage.qml +++ b/assets/ProfilePage.qml @@ -187,15 +187,9 @@ Page { text: qsTr("Posts") onClicked: { var page = postPage.createObject() - pnut.userStreamReceived.connect(page.loadThread); + pnut.userStreamReceived.connect(page.loadThread) pnut.getUserStream(user.id) - //page.follow.connect(pnut.followUser) - //page.unfollow.connect(pnut.unfollowUser) - //page.block.connect(pnut.blockUser) - //page.unblock.connect(pnut.unblockUser) - //page.mute.connect(pnut.muteUser) - //page.unmute.connect(pnut.unmuteUser) - nav.push(page); + nav.push(page) } } } @@ -204,6 +198,14 @@ Page { rightPadding: ui.sdu(.5) Button { text: qsTr("Following") + onClicked: { + var page = userListPage.createObject() +// page.follow.connect(pnut.followUser) +// page.unfollow.connect(pnut.unfollowUser) + pnut.userListReceived.connect(page.loadThread) + pnut.getFollowing(user.id) + nav.push(page) + } } } Container { @@ -211,7 +213,15 @@ Page { rightPadding: ui.sdu(1) Button { text: qsTr("Followers") - } + onClicked: { + var page = userListPage.createObject() +// page.follow.connect(pnut.followUser) +// page.unfollow.connect(pnut.unfollowUser) + pnut.userListReceived.connect(page.loadThread) + pnut.getFollowers(user.id) + nav.push(page) + } + } } } // SegmentedControl { @@ -333,6 +343,10 @@ Page { ComponentDefinition { id: postPage source: "ThreadPage.qml" + }, + ComponentDefinition { + id: userListPage + source: "UserPage.qml" } ] } diff --git a/assets/UserItem.qml b/assets/UserItem.qml new file mode 100644 index 0000000..92386dd --- /dev/null +++ b/assets/UserItem.qml @@ -0,0 +1,66 @@ +import bb.cascades 1.4 +import org.labsquare 1.0 + +Container { + id: useritem + + property variant theme : Application.themeSupport.theme.colorTheme.style + 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. " + + leftPadding: ui.sdu(3.0) + rightPadding: ui.sdu(3.0) + topPadding: ui.sdu(2.0) + Container { + layout: DockLayout { + } + Container { + layout: StackLayout { + orientation: LayoutOrientation.LeftToRight + } + Container { + minWidth: ui.du(12) + background: (theme === VisualStyle.Bright) ? Color.create("#e9e9e9") : Color.create("#282828") + WebImageView { + id: avatar + url: ListItemData.content.avatar_image.link + maxWidth: ui.du(12) + maxHeight: ui.du(12) + //imageSource: "asset:///icons/laughing_man.png" + } + } + Container { + preferredWidth: 1440 + leftMargin: ui.sdu(3.0) + Container { + Label { + id: username + text: ListItemData.username + textStyle.fontWeight: FontWeight.Bold + } + } + Container { + Label { + id: description + text: ListItemData.content.html + multiline: true + textFormat: TextFormat.Html + } + } + } + Container { + minWidth: ui.du(24) + verticalAlignment: VerticalAlignment.Center + Button { + text: (ListItemData.you_follow) ? qsTr("Unfollow") : qsTr("Follow") + onClicked: { + if (ListItemData.you_follow) { + useritem.ListItem.view.unfollow(ListItemData.id) + } else { + useritem.ListItem.view.follow(ListItemData.id) + } + } + } + } + } + } +} diff --git a/assets/UserPage.qml b/assets/UserPage.qml new file mode 100644 index 0000000..709ee4f --- /dev/null +++ b/assets/UserPage.qml @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2016 Morgan McMillian + * + * This file is apart of the Goober application, a client for pnut.io + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import bb.cascades 1.4 + +Page { + + signal follow(string uid) + signal unfollow(string uid) + signal block(string uid) + signal unblock(string uid) + signal mute(string uid) + signal unmute(string uid) + + Container { + ListView { + id: userListView + dataModel: ArrayDataModel { + id: listModel + } + listItemComponents: [ + ListItemComponent { + id: root + UserItem {} + } + ] + function follow(uid) { + pnut.followUser(uid) + } + function unfollow(uid) { + pnut.unfollowUser(uid) + } +// function sendReply(text, pid) { +// pnut.sendReply(text, pid); +// } +// function getUserName() { +// return _app.setting("username") +// } +// function viewProfile(userobj) { +// var page = profilePage.createObject(); +// page.user = userobj +// page.follow.connect(follow) +// page.unfollow.connect(unfollow) +// page.block.connect(block) +// page.unblock.connect(unblock) +// page.mute.connect(mute) +// page.unmute.connect(unmute) +// nav.push(page); +// } +// function ccOnReply() { +// if (_app.setting("cc") === "true") { +// return true +// } else { +// return false +// } +// } + } + } + + function loadThread(data) { + listModel.append(data); + } +} diff --git a/config.pri b/config.pri index 5f84b1b..f94503d 100644 --- a/config.pri +++ b/config.pri @@ -76,6 +76,8 @@ config_pri_assets { $$quote($$BASEDIR/assets/SettingsPage.qml) \ $$quote($$BASEDIR/assets/StreamTab.qml) \ $$quote($$BASEDIR/assets/ThreadPage.qml) \ + $$quote($$BASEDIR/assets/UserItem.qml) \ + $$quote($$BASEDIR/assets/UserPage.qml) \ $$quote($$BASEDIR/assets/icons/at.png) \ $$quote($$BASEDIR/assets/icons/bell-slash.png) \ $$quote($$BASEDIR/assets/icons/bell.png) \ diff --git a/src/Pnut.cpp b/src/Pnut.cpp index 047d4f9..7ad1cfc 100644 --- a/src/Pnut.cpp +++ b/src/Pnut.cpp @@ -228,6 +228,11 @@ void Pnut::onAuthorizedRequestReady(QByteArray data, int id) emit userStreamReceived(variant.toMap()["data"].toList()); req_map.remove(id); } + else if (endpoint == ":followers" || endpoint == ":following") + { + emit userListReceived(variant.toMap()["data"].toList()); + req_map.remove(id); + } else if (endpoint == ":logout") { qDebug() << "Logout successful!"; @@ -498,3 +503,19 @@ void Pnut::getUserStream(QString uid) req_map[++req_id] = ":userstream"; getRequest(url, parameters, req_id); } + +void Pnut::getFollowers(QString uid) +{ + QUrl url(PNUT_API_ROOT + "/users/" + uid + "/followers"); + KQOAuthParameters parameters; + req_map[++req_id] = ":followers"; + getRequest(url, parameters, req_id); +} + +void Pnut::getFollowing(QString uid) +{ + QUrl url(PNUT_API_ROOT + "/users/" + uid + "/following"); + KQOAuthParameters parameters; + req_map[++req_id] = ":following"; + getRequest(url, parameters, req_id); +} diff --git a/src/Pnut.h b/src/Pnut.h index 12cbe1e..4c1db5f 100644 --- a/src/Pnut.h +++ b/src/Pnut.h @@ -86,6 +86,8 @@ public: Q_INVOKABLE void deletePost(QString pid); Q_INVOKABLE void getPost(QString pid); Q_INVOKABLE void getUserStream(QString uid); + Q_INVOKABLE void getFollowers(QString uid); + Q_INVOKABLE void getFollowing(QString uid); public slots: void onRequestReady(QByteArray data); @@ -105,6 +107,7 @@ Q_SIGNALS: void unmuteSuccess(QVariantMap user); void postReceived(QVariantMap post); void userStreamReceived(QVariantList stream); + void userListReceived(QVariantList users); private: static const QString PNUT_API_ROOT; diff --git a/translations/Goober.ts b/translations/Goober.ts index 0842944..dca5d81 100644 --- a/translations/Goober.ts +++ b/translations/Goober.ts @@ -84,13 +84,13 @@ ProfilePage - + Following - + Followers @@ -106,32 +106,32 @@ - + Unfollow - + Follow - + Unmute - + Mute - + Unblock - + Block @@ -195,6 +195,19 @@ + + UserItem + + + Unfollow + + + + + Follow + + + main