Merge pull request #234 from monich/select

Animate display of selection panel
This commit is contained in:
Sebastian Wolf 2020-12-06 20:07:57 +01:00 committed by GitHub
commit 0064b80bb9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -57,15 +57,11 @@ Page {
|| (chatGroupInformation.status["@type"] === "chatMemberStatusCreator" && chatGroupInformation.status.is_member)
)
property var selectedMessages: []
readonly property bool isSelecting: selectedMessages.length > 0
states: [
State {
name: "selectMessages"
when: selectedMessages.length > 0
PropertyChanges {
target: newMessageColumn
visible: false
opacity: 0
}
when: isSelecting
PropertyChanges {
target: chatNameText
text: qsTr("Select Messages")
@ -74,12 +70,6 @@ Page {
target: chatStatusText
text: qsTr("%Ln messages selected", "number of messages selected", chatPage.selectedMessages.length)
}
PropertyChanges {
target: selectedMessagesActions
height: Theme.itemSizeMedium
active: true
opacity: 1.0//selectedMessages.length > 0 ? 1.0 : 0.5
}
PropertyChanges {
target: newMessageTextField
focus: false
@ -107,7 +97,7 @@ Page {
}
function updateChatPartnerStatusText() {
if (chatPage.state === "selectMessages") {
if (chatPage.isSelecting) {
return
}
var statusText = Functions.getChatPartnerStatusText(chatPartnerInformation.status['@type'], chatPartnerInformation.status.was_online);
@ -127,7 +117,7 @@ Page {
}
function updateGroupStatusText() {
if(chatPage.state === "selectMessages") {
if (chatPage.isSelecting) {
return
}
if (chatOnlineMemberCount > 0) {
@ -644,7 +634,7 @@ Page {
height: headerRow.height
width: parent.width
onClicked: {
if(chatPage.state === "selectMessages") {
if (chatPage.isSelecting) {
chatPage.selectedMessages = [];
} else {
pageStack.navigateForward();
@ -699,7 +689,6 @@ Page {
}
Image {
id: chatSecretImage
source: "image://theme/icon-s-secure"
width: chatPage.isPortrait ? Theme.fontSizeSmall : Theme.fontSizeExtraSmall
height: width
@ -825,7 +814,7 @@ Page {
readonly property int textColumnWidth: backgroundWidth - Theme.horizontalPageMargin
readonly property int messageInReplyToHeight: Theme.fontSizeExtraSmall * 2.571428571 + Theme.paddingSmall;
readonly property int webPagePreviewHeight: ( (textColumnWidth * 2 / 3) + (6 * Theme.fontSizeExtraSmall) + ( 7 * Theme.paddingSmall) )
readonly property bool pageIsSelecting: chatPage.state === "selectMessages"
readonly property bool pageIsSelecting: chatPage.isSelecting
}
@ -1048,12 +1037,14 @@ Page {
id: newMessageColumn
spacing: Theme.paddingSmall
topPadding: Theme.paddingSmall
width: parent.width - ( 2 * Theme.horizontalPageMargin )
anchors.horizontalCenter: parent.horizontalCenter
visible: chatPage.hasSendPrivilege("can_send_messages")
height: visible ? implicitHeight : 0
Behavior on opacity { FadeAnimation {} }
clip: true
visible: height > 0
width: parent.width - ( 2 * Theme.horizontalPageMargin )
height: isNeeded ? implicitHeight : 0
Behavior on height { SmoothedAnimation { duration: 200 } }
readonly property bool isNeeded: !chatPage.isSelecting && chatPage.hasSendPrivilege("can_send_messages")
property string replyToMessageId: "0";
property string editMessageId: "0";
@ -1456,21 +1447,23 @@ Page {
}
}
}
}
}
Loader {
id: selectedMessagesActions
asynchronous: true
active: false
height: 0
opacity: 0
width: parent.width - Theme.horizontalPageMargin
Behavior on opacity { FadeAnimation {} }
anchors.bottom: parent.bottom
readonly property bool isNeeded: chatPage.isSelecting
active: height > 0
width: parent.width
height: isNeeded ? Theme.itemSizeMedium : 0
Behavior on height { SmoothedAnimation { duration: 200 } }
sourceComponent: Component {
Item {
clip: true
IconButton {
id: cancelSelectionButton
anchors {
left: parent.left
leftMargin: Theme.horizontalPageMargin
@ -1482,18 +1475,17 @@ Page {
}
}
IconButton {
id: messagesCopyButton
Row {
spacing: Theme.paddingSmall
anchors {
right: messagesForwardButton.left
leftMargin: Theme.paddingSmall
right: parent.right
rightMargin: Theme.horizontalPageMargin
verticalCenter: parent.verticalCenter
}
IconButton {
icon.source: "../../images/icon-m-copy.svg"
icon.sourceSize {
width: Theme.iconSizeMedium
height: Theme.iconSizeMedium
}
icon.sourceSize: Qt.size(Theme.iconSizeMedium, Theme.iconSizeMedium)
onClicked: {
Clipboard.text = Functions.getMessagesArrayText(chatPage.selectedMessages);
appNotification.show(qsTr("%Ln messages have been copied", "", selectedMessages.length));
@ -1502,17 +1494,10 @@ Page {
}
IconButton {
id: messagesForwardButton
anchors {
right: messagesDeleteButton.left
leftMargin: visible ? Theme.paddingSmall : 0
verticalCenter: parent.verticalCenter
}
visible: selectedMessages.every(function(message){
return message.can_be_forwarded && !chatPage.isSecretChat
visible: !chatPage.isSecretChat && selectedMessages.every(function(message){
return message.can_be_forwarded
})
width: visible ? Theme.itemSizeMedium : 0
icon.sourceSize: Qt.size(Theme.iconSizeMedium, Theme.iconSizeMedium)
icon.source: "image://theme/icon-m-forward"
onClicked: {
var ids = Functions.getMessagesArrayIds(chatPage.selectedMessages)
@ -1528,18 +1513,11 @@ Page {
}
IconButton {
id: messagesDeleteButton
anchors {
right: parent.right
leftMargin: visible ? Theme.paddingSmall : 0
verticalCenter: parent.verticalCenter
}
icon.source: "image://theme/icon-m-delete"
visible: chatInformation.id === chatPage.myUserId || selectedMessages.every(function(message){
return message.can_be_deleted_for_all_users
})
width: visible ? Theme.itemSizeMedium : 0
icon.sourceSize: Qt.size(Theme.iconSizeMedium, Theme.iconSizeMedium)
onClicked: {
var ids = Functions.getMessagesArrayIds(selectedMessages);
var chatId = chatInformation.id
@ -1554,6 +1532,4 @@ Page {
}
}
}
}
}