summaryrefslogtreecommitdiff
path: root/eventsview-plugins/eventsview-plugin-mastodon/MastodonFeedItem.qml
diff options
context:
space:
mode:
Diffstat (limited to 'eventsview-plugins/eventsview-plugin-mastodon/MastodonFeedItem.qml')
-rw-r--r--eventsview-plugins/eventsview-plugin-mastodon/MastodonFeedItem.qml143
1 files changed, 143 insertions, 0 deletions
diff --git a/eventsview-plugins/eventsview-plugin-mastodon/MastodonFeedItem.qml b/eventsview-plugins/eventsview-plugin-mastodon/MastodonFeedItem.qml
new file mode 100644
index 0000000..231b814
--- /dev/null
+++ b/eventsview-plugins/eventsview-plugin-mastodon/MastodonFeedItem.qml
@@ -0,0 +1,143 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2026 Open Mobile Platform LLC.
+ **
+ ****************************************************************************/
+
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+import Sailfish.TextLinking 1.0
+import "shared"
+
+SocialMediaFeedItem {
+ id: item
+
+ property variant imageList
+ property int likeCount
+ property int commentCount
+ property int boostCount
+
+ property string _booster: item.stringValue("boostedBy", "rebloggedBy", "retweeter")
+ property string _displayName: item.stringValue("name", "displayName", "display_name")
+ property string _accountName: item.stringValue("accountName", "acct", "screenName", "username")
+ property string _bodyText: item.stringValue("body", "content", "text")
+
+ timestamp: item.stringValue("timestamp", "createdAt", "created_at")
+
+ avatar.y: item._booster.length > 0
+ ? topMargin + boosterIcon.height + Theme.paddingSmall
+ : topMargin
+ contentHeight: Math.max(content.y + content.height, avatar.y + avatar.height) + bottomMargin
+ topMargin: item._booster.length > 0 ? Theme.paddingMedium : Theme.paddingLarge
+ userRemovable: false
+
+ Image {
+ id: boosterIcon
+
+ anchors {
+ right: avatar.right
+ top: parent.top
+ topMargin: item.topMargin
+ }
+ visible: item._booster.length > 0
+ source: "image://theme/icon-s-repost" + (item.highlighted ? "?" + Theme.highlightColor : "")
+ }
+
+ Text {
+ anchors {
+ left: content.left
+ right: content.right
+ verticalCenter: boosterIcon.verticalCenter
+ }
+ elide: Text.ElideRight
+ font.pixelSize: Theme.fontSizeExtraSmall
+ color: item.highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor
+ textFormat: Text.PlainText
+ visible: text.length > 0
+
+ text: item._booster.length > 0
+ ? //: Shown above a post that is boosted by another user. %1 = name of user who boosted
+ //% "%1 boosted"
+ qsTrId("lipstick-jolla-home-la-boosted_by").arg(item._booster)
+ : ""
+ }
+
+ Column {
+ id: content
+
+ anchors {
+ left: avatar.right
+ leftMargin: Theme.paddingMedium
+ top: avatar.top
+ }
+ width: parent.width - x
+
+ Label {
+ width: parent.width
+ truncationMode: TruncationMode.Fade
+ text: item._displayName
+ color: item.highlighted ? Theme.highlightColor : Theme.primaryColor
+ textFormat: Text.PlainText
+ }
+
+ Label {
+ width: parent.width
+ truncationMode: TruncationMode.Fade
+ text: item._accountName.length > 0 && item._accountName.charAt(0) !== "@"
+ ? "@" + item._accountName
+ : item._accountName
+ font.pixelSize: Theme.fontSizeSmall
+ color: item.highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor
+ textFormat: Text.PlainText
+ }
+
+ LinkedText {
+ width: parent.width
+ elide: Text.ElideRight
+ wrapMode: Text.Wrap
+ font.pixelSize: Theme.fontSizeSmall
+ shortenUrl: true
+ color: item.highlighted ? Theme.highlightColor : Theme.primaryColor
+ linkColor: Theme.highlightColor
+ plainText: item._bodyText
+ }
+
+ Text {
+ width: parent.width
+ height: previewRow.visible ? implicitHeight + Theme.paddingMedium : implicitHeight // add padding below
+ maximumLineCount: 1
+ elide: Text.ElideRight
+ wrapMode: Text.Wrap
+ color: item.highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor
+ font.pixelSize: Theme.fontSizeExtraSmall
+ text: item.formattedTime
+ textFormat: Text.PlainText
+ }
+
+ SocialMediaPreviewRow {
+ id: previewRow
+
+ width: parent.width + Theme.horizontalPageMargin // extend to right edge of notification area
+ imageList: item.imageList
+ downloader: item.downloader
+ accountId: item.accountId
+ connectedToNetwork: item.connectedToNetwork
+ highlighted: item.highlighted
+ eventsColumnMaxWidth: item.eventsColumnMaxWidth - item.avatar.width
+ }
+ }
+
+ function stringValue() {
+ for (var i = 0; i < arguments.length; ++i) {
+ var value = model[arguments[i]]
+ if (typeof value === "undefined" || value === null) {
+ continue
+ }
+ value = String(value)
+ if (value.length > 0) {
+ return value
+ }
+ }
+ return ""
+ }
+}