This repository has been archived on 2023-11-19. You can view files and clone it, but cannot push or open issues or pull requests.
goober-bb10/assets/PostItem.qml
Morgan McMillian f8f3149d94 Initial commit
2016-09-22 16:21:20 -07:00

138 lines
5 KiB
QML

/*
* Copyright (C) 2016 Morgan McMillian <gilag@monkeystew.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
import bb.cascades 1.4
import org.labsquare 1.0
import "moment.js" as Moment
Container {
id: postitem
leftPadding: 20.0
rightPadding: 20.0
topPadding: 10.0
bottomPadding: 10.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. "
Container {
layout: StackLayout {
orientation: LayoutOrientation.LeftToRight
}
Container {
WebImageView {
id: avatar
url: ListItemData.user.content.avatar_image.link
maxWidth: 100.0
maxHeight: avatar.maxWidth
//imageSource: "asset:///laughing_man.png"
}
}
Container {
leftMargin: 20.0
Container {
Label {
id: name
text: ListItemData.user.name
textStyle.fontWeight: FontWeight.Bold
}
}
Container {
Label {
id: username
text: ListItemData.user.username
}
}
}
}
Container {
topMargin: 20.0
bottomMargin: 20.0
Label {
text: ListItemData.content.text
multiline: true
}
}
Container {
layout: DockLayout {}
horizontalAlignment: HorizontalAlignment.Fill
Container {
horizontalAlignment: HorizontalAlignment.Left
Label {
text: Moment.moment(ListItemData.created_at).format("lll")
textStyle.fontSize: FontSize.XSmall
}
}
Container {
horizontalAlignment: HorizontalAlignment.Right
Label {
text: ListItemData.source.name
textStyle.fontSize: FontSize.XSmall
}
}
}
Divider {}
contextActions: [
ActionSet {
title: ListItemData.user.username
ActionItem {
title: qsTr("Reply")
onTriggered: {
replySheet.text = "@" + ListItemData.user.username + " ";
replySheet.open();
replySheet.input.requestFocus();
}
imageSource: "asset:///icons/ic_reply.png"
}
ActionItem {
title: "Reply All"
onTriggered: {
replySheet.text = "@" + ListItemData.user.username + " " + parseMentions(ListItemData.content.entities.mentions);
console.log(JSON.stringify(ListItemData.content.entities.mentions))
replySheet.open();
replySheet.input.requestFocus();
}
imageSource: "asset:///icons/ic_reply_all.png"
}
}
]
attachedObjects: [
NewPostSheet {
id: replySheet
onSendPost: {
postitem.ListItem.view.sendReply(text, ListItemData.id);
}
}
]
function parseMentions(mentions) {
console.log("blarp")
var mtext = ""
for(var i = 0; i < mentions.length; i++) {
var mu = mentions[i].text
if (mu !== "thrrgilag") {
mtext += "@" + mu + " "
}
}
if (mtext.length > 0) {
return "\n/" + mtext
} else {
return ""
}
}
}