Put attachment row in a Flickable

This commit is contained in:
Sebastian Wolf 2021-01-02 18:08:33 +01:00
parent 5213084fb1
commit be404d0e55
No known key found for this signature in database
GPG key ID: CEA9522B5F38A90A
2 changed files with 116 additions and 97 deletions

View file

@ -203,7 +203,7 @@ Item {
} }
text: qsTr("Use recording") text: qsTr("Use recording")
onClicked: { onClicked: {
attachmentOptionsRow.isNeeded = false; attachmentOptionsFlickable.isNeeded = false;
attachmentPreviewRow.isVoiceNote = true; attachmentPreviewRow.isVoiceNote = true;
attachmentPreviewRow.attachmentDescription = qsTr("Voice Note (%1)").arg(recordingDurationLabel.text); attachmentPreviewRow.attachmentDescription = qsTr("Voice Note (%1)").arg(recordingDurationLabel.text);
attachmentPreviewRow.visible = true; attachmentPreviewRow.visible = true;

View file

@ -1120,7 +1120,7 @@ Page {
Debug.log("Sticker picked: " + stickerId); Debug.log("Sticker picked: " + stickerId);
tdLibWrapper.sendStickerMessage(chatInformation.id, stickerId); tdLibWrapper.sendStickerMessage(chatInformation.id, stickerId);
stickerPickerLoader.active = false; stickerPickerLoader.active = false;
attachmentOptionsRow.isNeeded = false; attachmentOptionsFlickable.isNeeded = false;
} }
} }
@ -1197,18 +1197,34 @@ Page {
visible: false visible: false
} }
Flickable {
id: attachmentOptionsFlickable
property bool isNeeded: false
onIsNeededChanged: {
console.log("HÖHE: " + attachmentOptionsRow.height);
}
width: parent.width
height: isNeeded ? attachmentOptionsRow.height : 0
Behavior on height { SmoothedAnimation { duration: 200 } }
visible: height > 0
contentHeight: attachmentOptionsRow.height
contentWidth: Math.max(parent.width, attachmentOptionsRow.width)
clip: true
Row { Row {
id: attachmentOptionsRow id: attachmentOptionsRow
property bool isNeeded: false
visible: height > 0 height: attachImageIconButton.height
height: isNeeded ? implicitHeight : 0
anchors.right: parent.right anchors.right: parent.right
width: parent.width
layoutDirection: Qt.RightToLeft layoutDirection: Qt.RightToLeft
spacing: Theme.paddingMedium spacing: Theme.paddingMedium
clip: true
Behavior on height { SmoothedAnimation { duration: 200 } }
IconButton { IconButton {
id: attachImageIconButton
visible: chatPage.hasSendPrivilege("can_send_media_messages") visible: chatPage.hasSendPrivilege("can_send_media_messages")
icon.source: "image://theme/icon-m-image" icon.source: "image://theme/icon-m-image"
onClicked: { onClicked: {
@ -1216,7 +1232,7 @@ Page {
allowedOrientations: chatPage.allowedOrientations allowedOrientations: chatPage.allowedOrientations
}) })
picker.selectedContentPropertiesChanged.connect(function(){ picker.selectedContentPropertiesChanged.connect(function(){
attachmentOptionsRow.isNeeded = false; attachmentOptionsFlickable.isNeeded = false;
Debug.log("Selected document: ", picker.selectedContentProperties.filePath ); Debug.log("Selected document: ", picker.selectedContentProperties.filePath );
attachmentPreviewRow.fileProperties = picker.selectedContentProperties; attachmentPreviewRow.fileProperties = picker.selectedContentProperties;
attachmentPreviewRow.isPicture = true; attachmentPreviewRow.isPicture = true;
@ -1233,7 +1249,7 @@ Page {
allowedOrientations: chatPage.allowedOrientations allowedOrientations: chatPage.allowedOrientations
}) })
picker.selectedContentPropertiesChanged.connect(function(){ picker.selectedContentPropertiesChanged.connect(function(){
attachmentOptionsRow.isNeeded = false; attachmentOptionsFlickable.isNeeded = false;
Debug.log("Selected video: ", picker.selectedContentProperties.filePath ); Debug.log("Selected video: ", picker.selectedContentProperties.filePath );
attachmentPreviewRow.fileProperties = picker.selectedContentProperties; attachmentPreviewRow.fileProperties = picker.selectedContentProperties;
attachmentPreviewRow.isVideo = true; attachmentPreviewRow.isVideo = true;
@ -1263,7 +1279,7 @@ Page {
allowedOrientations: chatPage.allowedOrientations allowedOrientations: chatPage.allowedOrientations
}) })
picker.selectedContentPropertiesChanged.connect(function(){ picker.selectedContentPropertiesChanged.connect(function(){
attachmentOptionsRow.isNeeded = false; attachmentOptionsFlickable.isNeeded = false;
Debug.log("Selected document: ", picker.selectedContentProperties.filePath ); Debug.log("Selected document: ", picker.selectedContentProperties.filePath );
attachmentPreviewRow.fileProperties = picker.selectedContentProperties; attachmentPreviewRow.fileProperties = picker.selectedContentProperties;
attachmentPreviewRow.isDocument = true; attachmentPreviewRow.isDocument = true;
@ -1290,11 +1306,14 @@ Page {
icon.source: "image://theme/icon-m-question" icon.source: "image://theme/icon-m-question"
onClicked: { onClicked: {
pageStack.push(Qt.resolvedUrl("../pages/PollCreationPage.qml"), { "chatId" : chatInformation.id, groupName: chatInformation.title}); pageStack.push(Qt.resolvedUrl("../pages/PollCreationPage.qml"), { "chatId" : chatInformation.id, groupName: chatInformation.title});
attachmentOptionsRow.isNeeded = false; attachmentOptionsFlickable.isNeeded = false;
} }
} }
} }
}
Row { Row {
id: attachmentPreviewRow id: attachmentPreviewRow
visible: false visible: false
@ -1564,17 +1583,17 @@ Page {
IconButton { IconButton {
id: attachmentIconButton id: attachmentIconButton
icon.source: "image://theme/icon-m-attach?" + (attachmentOptionsRow.isNeeded ? Theme.highlightColor : Theme.primaryColor) icon.source: "image://theme/icon-m-attach?" + (attachmentOptionsFlickable.isNeeded ? Theme.highlightColor : Theme.primaryColor)
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.bottomMargin: Theme.paddingSmall anchors.bottomMargin: Theme.paddingSmall
enabled: !attachmentPreviewRow.visible enabled: !attachmentPreviewRow.visible
onClicked: { onClicked: {
if (attachmentOptionsRow.isNeeded) { if (attachmentOptionsFlickable.isNeeded) {
attachmentOptionsRow.isNeeded = false; attachmentOptionsFlickable.isNeeded = false;
stickerPickerLoader.active = false; stickerPickerLoader.active = false;
voiceNoteOverlayLoader.active = false; voiceNoteOverlayLoader.active = false;
} else { } else {
attachmentOptionsRow.isNeeded = true; attachmentOptionsFlickable.isNeeded = true;
} }
} }
} }