fix: fix channel text with break lines and add default props

This commit is contained in:
Jonathan Rainville 2020-06-18 14:06:02 -04:00 committed by Iuri Matias
parent 47b88cab95
commit 21afaf4ea4
3 changed files with 28 additions and 10 deletions

View File

@ -68,6 +68,7 @@ Item {
ChannelList { ChannelList {
id: channelList id: channelList
searchStr: contactsColumn.searchStr
} }
} }
} }

View File

@ -5,6 +5,13 @@ import "../../../../imports"
import "../components" import "../components"
Rectangle { Rectangle {
property string name: "channelName"
property string lastMessage: "My latest message\n with a return"
property string timestamp: "20/2/2020"
property string unviewedMessagesCount: "2"
property string chatType: Constants.chatTypePublic
property string searchStr: ""
id: wrapper id: wrapper
color: ListView.isCurrentItem ? Theme.lightBlue : Theme.transparent color: ListView.isCurrentItem ? Theme.lightBlue : Theme.transparent
anchors.right: parent.right anchors.right: parent.right
@ -34,8 +41,8 @@ Rectangle {
width: 40 width: 40
topMargin: 12 topMargin: 12
bottomMargin: 12 bottomMargin: 12
channelName: name channelName: wrapper.name
channelType: chatType channelType: wrapper.chatType
channelIdenticon: identicon channelIdenticon: identicon
} }
@ -44,17 +51,17 @@ Rectangle {
width: 16 width: 16
height: 16 height: 16
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
source: "../../../img/channel-icon-" + (chatType == Constants.chatTypePublic ? "public-chat.svg" : "group.svg") source: "../../../img/channel-icon-" + (wrapper.chatType === Constants.chatTypePublic ? "public-chat.svg" : "group.svg")
anchors.left: contactImage.right anchors.left: contactImage.right
anchors.leftMargin: Theme.padding anchors.leftMargin: Theme.padding
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: Theme.smallPadding anchors.topMargin: Theme.smallPadding
visible: chatType != Constants.chatTypeOneToOne visible: chatType !== Constants.chatTypeOneToOne
} }
Text { Text {
id: contactInfo id: contactInfo
text: chatType != Constants.chatTypePublic ? name : "#" + name text: wrapper.chatType !== Constants.chatTypePublic ? wrapper.name : "#" + wrapper.name
anchors.right: contactTime.left anchors.right: contactTime.left
anchors.rightMargin: Theme.smallPadding anchors.rightMargin: Theme.smallPadding
elide: Text.ElideRight elide: Text.ElideRight
@ -69,7 +76,7 @@ Rectangle {
Text { Text {
id: lastChatMessage id: lastChatMessage
text: lastMessage || qsTr("No messages") text: lastMessage ? lastMessage.replace(/\n|\r/g, ' ') : qsTr("No messages")
anchors.right: contactNumberChatsCircle.left anchors.right: contactNumberChatsCircle.left
anchors.rightMargin: Theme.smallPadding anchors.rightMargin: Theme.smallPadding
elide: Text.ElideRight elide: Text.ElideRight
@ -82,7 +89,7 @@ Rectangle {
} }
Text { Text {
id: contactTime id: contactTime
text: timestamp text: wrapper.timestamp
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: Theme.padding anchors.rightMargin: Theme.padding
anchors.top: parent.top anchors.top: parent.top
@ -103,7 +110,7 @@ Rectangle {
visible: unviewedMessagesCount > 0 visible: unviewedMessagesCount > 0
Text { Text {
id: contactNumberChats id: contactNumberChats
text: unviewedMessagesCount text: wrapper.unviewedMessagesCount
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
color: "white" color: "white"
@ -113,8 +120,10 @@ Rectangle {
/*##^## /*##^##
Designer { Designer {
D{i:0;autoSize:true;height:480;width:640} D{i:0;formeditorColor:"#ffffff";height:64;width:640}
} }
##^##*/ ##^##*/

View File

@ -7,6 +7,7 @@ import "../components"
Item { Item {
property alias channelListCount: chatGroupsListView.count property alias channelListCount: chatGroupsListView.count
property string searchStr: ""
id: chatGroupsContainer id: chatGroupsContainer
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
@ -15,7 +16,14 @@ Item {
id: chatGroupsListView id: chatGroupsListView
anchors.fill: parent anchors.fill: parent
model: chatsModel.chats model: chatsModel.chats
delegate: Channel {} delegate: Channel {
name: model.name
lastMessage: model.lastMessage
timestamp: model.timestamp
chatType: model.chatType
unviewedMessagesCount: model.unviewedMessagesCount
searchStr: chatGroupsContainer.searchStr
}
onCountChanged: { onCountChanged: {
if (count > 0 && chatsModel.activeChannelIndex > -1) { if (count > 0 && chatsModel.activeChannelIndex > -1) {
// If a chat is added or removed, we set the current index to the first value // If a chat is added or removed, we set the current index to the first value