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")
onClicked: {
attachmentOptionsRow.isNeeded = false;
attachmentOptionsFlickable.isNeeded = false;
attachmentPreviewRow.isVoiceNote = true;
attachmentPreviewRow.attachmentDescription = qsTr("Voice Note (%1)").arg(recordingDurationLabel.text);
attachmentPreviewRow.visible = true;

View file

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