RosterListItem.qml 1.92 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*
 *  Kaidan - A user-friendly XMPP client for every device!
 *
 *  Copyright (C) 2017 LNJ <git@lnj.li>
 *
 *  Kaidan is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Kaidan is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Kaidan. If not, see <http://www.gnu.org/licenses/>.
 */

20
import QtQuick 2.3
21 22 23 24 25 26 27 28
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.0 as Controls
import org.kde.kirigami 2.0 as Kirigami

Kirigami.SwipeListItem {
	property string name;
	property string lastMessage;
	property int unreadMessages;
29
	property string avatarImagePath;
30 31 32 33 34 35 36 37 38 39

	id: listItem
	topPadding: Kirigami.Units.smallSpacing * 1.5
	height: Kirigami.Units.gridUnit * 3.5

	RowLayout {
		spacing: Kirigami.Units.gridUnit * 0.5

		// left side: Avatar
		Image {
40
			source: avatarImagePath
41 42 43
			fillMode: Image.PreserveAspectFit
			Layout.preferredHeight: parent.height
			Layout.preferredWidth: parent.height
44
			mipmap: true
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
		}
		// right side
		ColumnLayout {
			// top
			RowLayout {
				// contact name
				Kirigami.Heading {
					text: name
					level: 3
					Layout.fillWidth: true
				}
			}
			// bottom
			Kirigami.Label {
				Layout.fillWidth: true
				text: kaidan.removeNewLinesFromString(lastMessage);
			}
		}

		// unread message counter
		MessageCounter {
			visible: unreadMessages > 0
			counter: unreadMessages

			Layout.preferredHeight: Kirigami.Units.gridUnit * 1.25
			Layout.preferredWidth: Kirigami.Units.gridUnit * 1.25
		}

		// placeholder
		Item {
			width: Kirigami.Units.gridUnit * 2.5
		}
	}
}