2016-10-22 22:56:38 +00:00
/ *
* Copyright ( C ) 2016 Morgan McMillian < gilag @ monkeystew . com >
2016-11-11 17:52:45 +00:00
*
2016-10-22 22:56:38 +00:00
* This file is apart of the Goober application , a client for pnut . io
2016-11-11 17:52:45 +00:00
*
2016-10-22 22:56:38 +00:00
* 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 .
2016-11-11 17:52:45 +00:00
*
2016-10-22 22:56:38 +00:00
* 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 .
2016-11-11 17:52:45 +00:00
*
2016-10-22 22:56:38 +00:00
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < http: //www.gnu.org/licenses/>.
* /
2016-10-21 13:09:34 +00:00
import bb . cascades 1.4
2017-11-16 21:06:59 +00:00
import com . netimage 1.0
2017-02-17 18:31:24 +00:00
import "parser.js" as Parser
2016-10-21 13:09:34 +00:00
Page {
2016-11-11 17:52:45 +00:00
2017-11-16 21:06:59 +00:00
property variant imgManager: imgManager
2016-10-21 13:09:34 +00:00
property variant user
2016-11-11 17:52:45 +00:00
property variant theme: Application . themeSupport . theme . colorTheme . style
2016-10-22 04:16:40 +00:00
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. "
2016-11-11 17:52:45 +00:00
2016-10-21 13:09:34 +00:00
signal follow ( string uid )
signal unfollow ( string uid )
2016-10-21 15:16:10 +00:00
signal block ( string uid )
signal unblock ( string uid )
signal mute ( string uid )
signal unmute ( string uid )
2016-11-12 00:10:08 +00:00
signal getPosts ( string uid )
2016-11-11 17:52:45 +00:00
2016-10-22 04:16:40 +00:00
ScrollView {
2016-10-21 13:09:34 +00:00
Container {
Container {
2016-11-11 17:52:45 +00:00
layout: DockLayout {
}
2016-10-22 04:16:40 +00:00
horizontalAlignment: HorizontalAlignment . Fill
preferredHeight: cover . height
2016-10-21 13:09:34 +00:00
Container {
2016-10-22 04:16:40 +00:00
Container {
opacity: 0.6
2017-11-16 21:06:59 +00:00
ImageView {
2016-10-22 04:16:40 +00:00
id: cover
preferredWidth: 1440
maxHeight: ui . du ( 24 )
scalingMethod: ScalingMethod . AspectFill
//imageSource: "asset:///icons/default_cover.png"
2017-11-16 21:06:59 +00:00
//url: user.content.cover_image.link
image: cimgtracker . image
attachedObjects: [
NetImageTracker {
id: cimgtracker
manager: imgManager
source: user . content . cover_image . link
}
]
2016-10-22 04:16:40 +00:00
}
2016-10-21 13:09:34 +00:00
}
}
Container {
2016-10-22 04:16:40 +00:00
layout: StackLayout {
orientation: LayoutOrientation . LeftToRight
2016-10-21 13:09:34 +00:00
}
2016-10-22 04:16:40 +00:00
topPadding: ui . sdu ( 3 )
2016-10-21 13:09:34 +00:00
leftPadding: ui . sdu ( 3 )
2016-10-22 04:16:40 +00:00
verticalAlignment: VerticalAlignment . Center
2016-10-21 13:09:34 +00:00
Container {
2016-10-22 04:16:40 +00:00
background: ( theme === VisualStyle . Bright ) ? Color . create ( "#e9e9e9" ) : Color . create ( "#282828" )
2017-11-16 21:06:59 +00:00
ImageView {
2016-10-22 04:16:40 +00:00
//imageSource: "asset:///icons/laughing_man.png"
2017-11-16 21:06:59 +00:00
//url: user.content.avatar_image.link
2016-10-22 04:16:40 +00:00
maxHeight: ui . du ( 14 )
maxWidth: ui . du ( 14 )
2017-11-16 21:06:59 +00:00
image: aimgtracker . image
attachedObjects: [
NetImageTracker {
id: aimgtracker
manager: imgManager
source: user . content . avatar_image . link
}
]
2016-10-21 13:09:34 +00:00
}
}
Container {
2016-10-22 04:16:40 +00:00
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
2016-11-11 17:52:45 +00:00
2016-10-22 04:16:40 +00:00
}
}
Container {
Label {
//text: "thrrgilag"
text: user . username
textStyle.fontSize: FontSize . Medium
2016-11-11 17:52:45 +00:00
2016-10-22 04:16:40 +00:00
}
2016-11-11 17:52:45 +00:00
2016-10-21 13:09:34 +00:00
}
}
2016-11-11 17:52:45 +00:00
2016-10-21 13:09:34 +00:00
}
2016-11-11 17:52:45 +00:00
2016-10-21 13:09:34 +00:00
}
Container {
2016-10-22 04:16:40 +00:00
topPadding: ui . sdu ( 3 )
leftPadding: ui . sdu ( 3 )
2016-10-21 13:09:34 +00:00
rightPadding: ui . sdu ( 3 )
2016-11-11 17:52:45 +00:00
layout: DockLayout {
}
2016-10-22 04:16:40 +00:00
horizontalAlignment: HorizontalAlignment . Fill
2016-10-21 13:09:34 +00:00
Container {
2016-10-22 04:16:40 +00:00
preferredWidth: ui . du ( 45 )
2016-10-21 13:09:34 +00:00
Label {
2016-10-22 04:16:40 +00:00
//text: lorem
2018-02-28 03:37:01 +00:00
text: Parser . parsePostText ( user . content )
2016-10-22 04:16:40 +00:00
multiline: true
textFormat: TextFormat . Html
2016-10-21 13:09:34 +00:00
}
}
Container {
horizontalAlignment: HorizontalAlignment . Right
2016-10-22 04:16:40 +00:00
rightPadding: ui . sdu ( 3 )
Container {
id: counts
layout: StackLayout {
orientation: LayoutOrientation . LeftToRight
}
horizontalAlignment: HorizontalAlignment . Right
Label {
text: qsTr ( "Following" )
2016-11-11 17:52:45 +00:00
2016-10-22 04:16:40 +00:00
}
Label {
text: user . counts . following
}
2016-10-21 13:09:34 +00:00
}
2016-10-22 04:16:40 +00:00
Container {
layout: StackLayout {
orientation: LayoutOrientation . LeftToRight
}
horizontalAlignment: HorizontalAlignment . Right
Label {
text: qsTr ( "Followers" )
2016-11-11 17:52:45 +00:00
2016-10-22 04:16:40 +00:00
}
Label {
text: user . counts . followers
}
2016-10-21 13:09:34 +00:00
}
2016-10-22 04:16:40 +00:00
Container {
layout: StackLayout {
orientation: LayoutOrientation . LeftToRight
}
horizontalAlignment: HorizontalAlignment . Right
Label {
text: qsTr ( "Posts" )
2016-11-11 17:52:45 +00:00
2016-10-22 04:16:40 +00:00
}
Label {
text: user . counts . posts
}
2016-10-21 13:09:34 +00:00
}
2016-10-22 04:16:40 +00:00
Container {
layout: StackLayout {
orientation: LayoutOrientation . LeftToRight
}
horizontalAlignment: HorizontalAlignment . Right
Label {
text: qsTr ( "Bookmarks" )
2016-11-11 17:52:45 +00:00
2016-10-22 04:16:40 +00:00
}
Label {
text: user . counts . bookmarks
}
2016-10-21 13:09:34 +00:00
}
}
2016-11-11 17:52:45 +00:00
2016-10-21 13:09:34 +00:00
}
2016-11-12 14:22:29 +00:00
Divider {
2016-11-11 17:51:17 +00:00
}
2016-11-12 14:22:29 +00:00
Container {
layout: StackLayout {
orientation: LayoutOrientation . LeftToRight
2016-11-11 17:51:17 +00:00
}
2016-11-12 14:22:29 +00:00
Container {
leftPadding: ui . sdu ( 1 )
rightPadding: ui . sdu ( . 5 )
Button {
text: qsTr ( "Posts" )
onClicked: {
var page = postPage . createObject ( )
2016-11-12 15:57:24 +00:00
pnut . userStreamReceived . connect ( page . loadThread )
2016-11-12 14:22:29 +00:00
pnut . getUserStream ( user . id )
2016-11-12 15:57:24 +00:00
nav . push ( page )
2016-11-11 17:52:45 +00:00
}
}
}
2016-11-12 14:22:29 +00:00
Container {
leftPadding: ui . sdu ( . 5 )
rightPadding: ui . sdu ( . 5 )
Button {
text: qsTr ( "Following" )
2016-11-12 15:57:24 +00:00
onClicked: {
var page = userListPage . createObject ( )
2016-11-12 16:55:16 +00:00
pnut . followSuccess . connect ( page . updateUser )
pnut . unfollowSuccess . connect ( page . updateUser )
2016-11-12 15:57:24 +00:00
pnut . userListReceived . connect ( page . loadThread )
pnut . getFollowing ( user . id )
nav . push ( page )
}
2016-11-11 17:52:45 +00:00
}
2016-11-11 17:51:17 +00:00
}
2016-11-12 14:22:29 +00:00
Container {
leftPadding: ui . sdu ( . 5 )
rightPadding: ui . sdu ( 1 )
Button {
text: qsTr ( "Followers" )
2016-11-12 15:57:24 +00:00
onClicked: {
var page = userListPage . createObject ( )
2016-11-12 16:55:16 +00:00
pnut . followSuccess . connect ( page . updateUser )
pnut . unfollowSuccess . connect ( page . updateUser )
2016-11-12 15:57:24 +00:00
pnut . userListReceived . connect ( page . loadThread )
pnut . getFollowers ( user . id )
nav . push ( page )
}
}
2016-11-12 14:22:29 +00:00
}
2016-11-11 17:51:17 +00:00
}
}
2016-10-21 13:09:34 +00:00
}
2016-11-11 17:52:45 +00:00
2016-10-21 13:09:34 +00:00
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 )
}
}
2016-10-21 15:16:10 +00:00
imageSource: ( user . you_follow ) ? "asset:///icons/minus-circle.png" : "asset:///icons/ic_add.png"
2016-10-21 15:50:17 +00:00
enabled: ( _app . setting ( "username" ) === user . username ) ? false : true
2016-10-21 15:16:10 +00:00
} ,
ActionItem {
title: ( user . you_muted ) ? qsTr ( "Unmute" ) : qsTr ( "Mute" )
ActionBar.placement: ActionBarPlacement . InOverflow
onTriggered: {
if ( user . you_muted ) {
unmute ( user . id )
} else {
mute ( user . id )
}
}
imageSource: ( user . you_muted ) ? "asset:///icons/bell.png" : "asset:///icons/bell-slash.png"
2016-10-21 15:50:17 +00:00
enabled: ( _app . setting ( "username" ) === user . username ) ? false : true
2016-10-21 15:16:10 +00:00
} ,
ActionItem {
title: ( user . you_blocked ) ? qsTr ( "Unblock" ) : qsTr ( "Block" )
ActionBar.placement: ActionBarPlacement . InOverflow
onTriggered: {
if ( user . you_blocked ) {
unblock ( user . id )
} else {
block ( user . id )
}
}
imageSource: "asset:///icons/ic_cancel.png"
2016-10-21 15:50:17 +00:00
enabled: ( _app . setting ( "username" ) === user . username ) ? false : true
2016-10-21 13:09:34 +00:00
}
]
2016-11-12 14:22:29 +00:00
attachedObjects: [
ComponentDefinition {
id: postPage
source: "ThreadPage.qml"
2016-11-12 15:57:24 +00:00
} ,
ComponentDefinition {
id: userListPage
source: "UserPage.qml"
2017-11-16 21:06:59 +00:00
} ,
NetImageManager {
id: imgManager
cacheId: "feedImageManager"
2017-11-17 22:14:24 +00:00
cacheSize: 250
2016-11-12 14:22:29 +00:00
}
]
2016-10-21 13:09:34 +00:00
}