better chat list view + anchor to bottom. sqlite db for chats + LIFO-ordered
This commit is contained in:
@@ -15,7 +15,7 @@ Item {
|
||||
property alias model: list.model
|
||||
|
||||
signal deleteChatRequest(content: ChatSession)
|
||||
signal loadChatRequest(content: ChatSession, index: int)
|
||||
signal loadChatRequest(content: ChatSession)
|
||||
signal newChatRequest
|
||||
|
||||
CustomText {
|
||||
@@ -44,140 +44,13 @@ Item {
|
||||
clip: true
|
||||
spacing: Tokens.spacing.medium
|
||||
|
||||
delegate: Component {
|
||||
Item {
|
||||
id: chatItem
|
||||
delegate: ChatDelegate {
|
||||
id: chat
|
||||
|
||||
property alias chat: chat
|
||||
property bool closing: false
|
||||
property bool editVisible: false
|
||||
required property int index
|
||||
required property var modelData
|
||||
property real startY: 0.0
|
||||
implicitWidth: ListView.view.width
|
||||
|
||||
anchors.fill: undefined
|
||||
implicitHeight: chat.layout.implicitHeight + chat.layout.anchors.topMargin + chat.layout.anchors.bottomMargin
|
||||
implicitWidth: ListView.view.width
|
||||
|
||||
onEditVisibleChanged: if (!editVisible)
|
||||
chat.x = 0
|
||||
|
||||
ParallelAnimation {
|
||||
id: removeAnim
|
||||
|
||||
onFinished: root.deleteChatRequest(chatItem.modelData)
|
||||
onStarted: chatItem.closing = true
|
||||
|
||||
Anim {
|
||||
property: "implicitHeight"
|
||||
target: chatItem
|
||||
to: 0
|
||||
}
|
||||
|
||||
Anim {
|
||||
property: "x"
|
||||
target: chat
|
||||
to: -chat.implicitWidth
|
||||
}
|
||||
|
||||
Anim {
|
||||
property: "opacity"
|
||||
target: chatItem
|
||||
to: 0
|
||||
}
|
||||
}
|
||||
|
||||
ChatDelegate {
|
||||
id: chat
|
||||
|
||||
chatItem: chatItem
|
||||
implicitWidth: chatItem.implicitWidth
|
||||
modelData: chatItem.modelData
|
||||
radius: Tokens.rounding.medium
|
||||
|
||||
Behavior on x {
|
||||
Anim {
|
||||
}
|
||||
}
|
||||
Behavior on y {
|
||||
Anim {
|
||||
}
|
||||
}
|
||||
|
||||
StateLayer {
|
||||
cursorShape: drag.active ? Qt.ClosedHandCursor : Qt.PointingHandCursor
|
||||
drag.axis: Drag.XAxis
|
||||
drag.target: chat
|
||||
hoverEnabled: true
|
||||
preventStealing: true
|
||||
|
||||
onClicked: {
|
||||
if (chatItem.editVisible)
|
||||
chatItem.editVisible = false;
|
||||
else
|
||||
root.loadChatRequest(chatItem.modelData, chatItem.index);
|
||||
}
|
||||
onPressed: event => {
|
||||
chatItem.startY = event.y;
|
||||
}
|
||||
onReleased: event => {
|
||||
if (chat.x > -(editTools.implicitWidth + Tokens.padding.extraSmall)) {
|
||||
chat.x = 0;
|
||||
} else {
|
||||
chatItem.editVisible = true;
|
||||
chat.x = -(editTools.implicitWidth + Tokens.spacing.medium + Tokens.padding.extraSmall);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CustomClippingRect {
|
||||
anchors.left: chat.right
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Tokens.padding.extraSmall
|
||||
anchors.verticalCenter: chat.verticalCenter
|
||||
implicitHeight: editTools.implicitHeight
|
||||
|
||||
RowLayout {
|
||||
id: editTools
|
||||
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
IconButton {
|
||||
id: deleteChatBtn
|
||||
|
||||
font.pointSize: Tokens.font.size.large
|
||||
icon: "close"
|
||||
radius: Tokens.rounding.full
|
||||
|
||||
transform: [
|
||||
Scale {
|
||||
property bool shouldBeActive: (chat.x < -deleteChatBtn.implicitWidth) && !chatItem.closing
|
||||
|
||||
origin.x: deleteChatBtn.implicitWidth / 2
|
||||
origin.y: deleteChatBtn.implicitWidth / 2
|
||||
xScale: shouldBeActive ? 1 : 0
|
||||
yScale: shouldBeActive ? 1 : 0
|
||||
|
||||
Behavior on xScale {
|
||||
Anim {
|
||||
}
|
||||
}
|
||||
Behavior on yScale {
|
||||
Anim {
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
onClicked: {
|
||||
removeAnim.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
onClicked: content => root.loadChatRequest(content)
|
||||
onRemove: content => root.deleteChatRequest(content)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user