48 lines
1.8 KiB
QML
48 lines
1.8 KiB
QML
pragma ComponentBehavior: Bound
|
|
import QtQuick
|
|
import QtQuick.Controls
|
|
import QtQuick.Layouts
|
|
import "../services"
|
|
|
|
Rectangle {
|
|
id: card
|
|
property var notification: null
|
|
property var record: null
|
|
readonly property var entry: notification || record
|
|
implicitHeight: content.implicitHeight + 28
|
|
color: Theme.surfaceHigh
|
|
radius: Theme.radius
|
|
ColumnLayout {
|
|
id: content
|
|
anchors { top: parent.top; left: parent.left; right: parent.right; margins: 14 }
|
|
spacing: 8
|
|
Label {
|
|
Layout.fillWidth: true
|
|
visible: card.record !== null
|
|
text: card.record ? Qt.formatDateTime(new Date(card.record.time), "dd.MM HH:mm") + " · История" : ""
|
|
color: Theme.outline
|
|
}
|
|
Label { Layout.fillWidth: true; text: card.entry?.summary || ""; color: Theme.foreground; wrapMode: Text.Wrap; font.bold: true; textFormat: Text.PlainText }
|
|
Label { Layout.fillWidth: true; text: card.entry?.body || ""; color: Theme.foreground; wrapMode: Text.Wrap; textFormat: Text.PlainText }
|
|
Image {
|
|
source: card.notification?.image || ""
|
|
visible: source !== ""
|
|
Layout.preferredWidth: 160; Layout.preferredHeight: 100
|
|
sourceSize: Qt.size(512, 512)
|
|
fillMode: Image.PreserveAspectFit
|
|
}
|
|
Flow {
|
|
Layout.fillWidth: true
|
|
spacing: 8
|
|
Repeater {
|
|
model: card.notification?.actions || []
|
|
ActionButton { required property var modelData; text: modelData.text; onClicked: modelData.invoke() }
|
|
}
|
|
ActionButton {
|
|
text: "Удалить"
|
|
onClicked: card.notification ? Notifications.dismiss(card.notification.id) : Notifications.removeHistory(card.record.key)
|
|
}
|
|
}
|
|
}
|
|
}
|