feat(ActivityCenter): Common date-time lable

Close #7952
This commit is contained in:
MishkaRogachev 2022-10-19 16:54:45 +04:00 committed by Mikhail Rogachev
parent 532700f6c7
commit 9b93a9d3f9
5 changed files with 20 additions and 205 deletions

View File

@ -252,6 +252,7 @@ Popup {
width: listView.availableWidth
store: root.store
notification: model
previousNotificationIndex: Math.min(listView.count - 1, index + 1)
}
}
DelegateChoice {
@ -261,6 +262,7 @@ Popup {
width: listView.availableWidth
store: root.store
notification: model
previousNotificationIndex: Math.min(listView.count - 1, index + 1)
}
}
}

View File

@ -1,188 +0,0 @@
import QtQuick 2.13
import QtGraphicalEffects 1.13
import StatusQ.Components 0.1
import StatusQ.Controls 0.1
import StatusQ.Core.Theme 0.1
import utils 1.0
import shared.controls 1.0
import shared 1.0
import shared.panels 1.0
import shared.popups 1.0
import shared.panels.chat 1.0
import shared.controls.chat 1.0
import "../controls"
import "../panels"
Item {
id: root
width: parent.width
height: childrenRect.height + dateGroupLbl.anchors.topMargin
property var store
property int previousNotificationIndex
property int previousNotificationTimestamp
property bool hideReadNotifications: false
property bool acCurrentActivityCategoryAll: false
StatusDateGroupLabel {
id: dateGroupLbl
anchors.top: parent.top
anchors.topMargin: Style.current.halfPadding
anchors.left: parent.left
anchors.leftMargin: Style.current.padding
height: visible ? implicitHeight : 0
visible: text !== ""
previousMessageIndex: root.previousNotificationIndex
previousMessageTimestamp: root.previousNotificationTimestamp
messageTimestamp: model.timestamp
}
Rectangle {
id: groupRequestContent
property int timestamp: model.timestamp
visible: {
if (hideReadNotifications && model.read) {
return false
}
return acCurrentActivityCategoryAll;
}
width: parent.width
height: visible ? 60 : 0
anchors.top: dateGroupLbl.bottom
anchors.topMargin: dateGroupLbl.visible ? 4 : 0
color: model.read ? Style.current.transparent : Utils.setColorAlpha(Style.current.blue, 0.1)
StatusSmartIdenticon {
id: channelIdenticon
anchors.left: parent.left
anchors.leftMargin: Style.current.padding
anchors.verticalCenter: parent.verticalCenter
name: model.name
asset.color: Theme.palette.miscColor5
}
Item {
id: nameItem
width: childrenRect.width
height: chatName.name
anchors.top: parent.top
anchors.topMargin: Style.current.halfPadding
// TODO fix anchoring to center when there is no author
// anchors.top: inviteText.visible ? parent.top: undefined
// anchors.topMargin: inviteText.visible ? Style.current.halfPadding : 0
// anchors.verticalCenter: inviteText.visible ? undefined : parent.verticalCenter
anchors.left: channelIdenticon.right
anchors.leftMargin: Style.current.halfPadding
SVGImage {
id: groupImage
width: 16
height: 16
anchors.verticalCenter: chatName.verticalCenter
anchors.left: parent.left
source: Style.svg("channel-icon-group")
ColorOverlay {
anchors.fill: parent
source: parent
color: chatName.color
}
}
StyledText {
id: chatName
text: model.name
anchors.left: groupImage.right
anchors.leftMargin: 4
font.pixelSize: 15
font.weight: Font.Medium
}
ChatTimePanel {
anchors.verticalCenter: chatName.verticalCenter
anchors.left: chatName.right
anchors.leftMargin: 4
font.pixelSize: 10
visible: true
color: Style.current.secondaryText
//timestamp: root.timestamp
}
}
function openProfile() {
Global.openProfilePopup(model.author)
}
StyledTextEdit {
id: inviteText
visible: !!model.author
// Not Refactored Yet
// text: {
// if (!visible) {
// return ""
// }
// let name = root.store.chatsModelInst.userNameOrAlias(model.author)
// if (name.length > 20) {
// name = name.substring(0, 9) + "..." + name.substring(name.length - 10)
// }
// return qsTr("%1 invited you to join the group")
// .arg(`<style type="text/css">`+
// `a {`+
// `color: ${Style.current.primary};`+
// `text-decoration: none;` +
// `}`+
// `</style>`+
// `<a href="#">${name}</a>`)
// }
anchors.bottom: parent.bottom
anchors.bottomMargin: Style.current.halfPadding
anchors.left: nameItem.left
anchors.right: buttons.left
anchors.rightMargin: Style.current.halfPadding
clip: true
font.pixelSize: 15
font.weight: Font.Medium
readOnly: true
selectByMouse: true
textFormat: Text.RichText
onLinkActivated: groupRequestContent.openProfile()
onLinkHovered: {
cursorShape: Qt.PointingHandCursor
}
}
AcceptRejectOptionsButtonsPanel {
id: buttons
anchors.right: parent.right
anchors.rightMargin: Style.current.halfPadding
anchors.verticalCenter: parent.verticalCenter
onAcceptClicked: root.store.activityCenterModuleInst.acceptActivityCenterNotification(model.id)
onDeclineClicked: root.store.activityCenterModuleInst.dismissActivityCenterNotification(model.id)
onProfileClicked: groupRequestContent.openProfile()
onBlockClicked: {
// Not Refactored Yet
// const pk = model.author
// blockContactConfirmationDialog.contactName = root.store.chatsModelInst.userNameOrAlias(pk)
// blockContactConfirmationDialog.contactAddress = pk
// blockContactConfirmationDialog.open()
}
BlockContactConfirmationDialog {
id: blockContactConfirmationDialog
onBlockButtonClicked: {
// Not Refactored Yet
// root.store.profileModuleInst.blockContact(blockContactConfirmationDialog.contactAddress)
root.store.activityCenterModuleInst.dismissActivityCenterNotification(model.id)
blockContactConfirmationDialog.close()
}
}
}
}
}

View File

@ -17,12 +17,27 @@ Item {
property alias bodyComponent: bodyLoader.sourceComponent
property alias badgeComponent: badgeLoader.sourceComponent
property alias ctaComponent: ctaLoader.sourceComponent
property alias previousNotificationIndex: dateGroupLabel.previousMessageIndex
height: Math.max(50, bodyLoader.height + (badgeLoader.item ? badgeLoader.height : 0))
height: Math.max(50, bodyLoader.height +
(dateGroupLabel.visible ? dateGroupLabel.height : 0) +
(badgeLoader.item ? badgeLoader.height : 0))
StatusDateGroupLabel {
id: dateGroupLabel
anchors.top: parent.top
anchors.right: parent.right
anchors.left: parent.left
messageTimestamp: notification.timestamp
previousMessageTimestamp: root.previousNotificationIndex == 0 ? "" :
root.store.activityCenterList.getNotificationData(previousNotificationIndex,
"timestamp")
visible: text !== ""
}
Loader {
id: bodyLoader
anchors.top: parent.top
anchors.top: dateGroupLabel.visible ? dateGroupLabel.bottom : parent.top
anchors.right: ctaLoader.left
anchors.left: parent.left
}

View File

@ -17,11 +17,6 @@ ActivityNotificationBase {
id: root
property var messageContextMenu
property int previousNotificationIndex
readonly property string previousNotificationTimestamp: previousNotificationIndex == 0 ?
"" : root.store.activityCenterList.getNotificationData(
previousNotificationIndex, "timestamp")
signal activityCenterClose()
@ -36,12 +31,10 @@ ActivityNotificationBase {
senderId: notification.author
senderIcon: contactDetails.displayIcon
senderDisplayName: contactDetails.name
messageContextMenu: root.messageContextMenu
activityCenterMessage: true
activityCenterMessageRead: false
scrollToBottom: null
prevMessageIndex: root.previousNotificationIndex
prevMsgTimestamp: root.previousNotificationTimestamp
onImageClicked: Global.openImagePopup(image, root.messageContextMenu)
messageClickHandler: (sender,
point,

View File

@ -13,11 +13,6 @@ ActivityNotificationBase {
id: root
property var messageContextMenu
property int previousNotificationIndex
readonly property string previousNotificationTimestamp: previousNotificationIndex == 0 ?
"" : root.store.activityCenterList.getNotificationData(
previousNotificationIndex, "timestamp")
signal activityCenterClose()
@ -59,7 +54,5 @@ ActivityNotificationBase {
root.activityCenterClose()
root.store.activityCenterModuleInst.switchTo(notification.sectionId, notification.chatId, notification.id)
}
prevMessageIndex: root.previousNotificationIndex
prevMsgTimestamp: root.previousNotificationTimestamp
}
}