cleanup qml

This commit is contained in:
Iuri Matias 2020-09-23 15:11:27 -04:00
parent 1d8d11a06e
commit 0da4633318
4 changed files with 63 additions and 214 deletions

View File

@ -55,38 +55,18 @@ Item {
anchors.topMargin: Style.current.padding
}
StackLayout {
id: contactsStackView
ChannelList {
id: channelList
searchStr: contactsColumn.searchStr
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.top: searchBox.bottom
anchors.topMargin: Style.current.padding
function getCurrentIndex() {
// return channelList.channelListCount > 0 ? 1 : 0
return 0
onChannelListCountChanged: {
}
currentIndex: getCurrentIndex()
// ScrollView {
// clip: true
// EmptyView {
// onCloseButtonPressed: function () {
// contactsStackView.currentIndex = 2
// }
// }
ChannelList {
id: channelList
searchStr: contactsColumn.searchStr
onChannelListCountChanged: {
contactsStackView.currentIndex = contactsStackView.getCurrentIndex()
}
}
ClosedEmptyView {}
}
}

View File

@ -18,67 +18,64 @@ ScrollView {
}
clip: true
Item {
id: itemId
Layout.fillHeight: true
Item {
id: itemId
Layout.fillHeight: true
anchors.top: parent.top
// anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.left: parent.left
anchors.rightMargin: Style.current.padding
anchors.leftMargin: Style.current.padding
height: childrenRect.height
ListView {
id: chatGroupsListView
anchors.top: parent.top
height: childrenRect.height
// anchors.bottom: parent.bottom
// anchors.bottom: chatGroupsListView2.top
anchors.right: parent.right
anchors.left: parent.left
anchors.rightMargin: Style.current.padding
anchors.leftMargin: Style.current.padding
interactive: false
// clip: true
model: chatsModel.chats
delegate: Channel {
name: model.name
muted: model.muted
lastMessage: model.lastMessage
timestamp: model.timestamp
chatType: model.chatType
identicon: model.identicon
unviewedMessagesCount: model.unviewedMessagesCount
hasMentions: model.hasMentions
contentType: model.contentType
searchStr: chatGroupsContainer.searchStr
chatId: model.id
}
onCountChanged: {
if (count > 0 && chatsModel.activeChannelIndex > -1) {
// If a chat is added or removed, we set the current index to the first value
chatsModel.activeChannelIndex = 0;
currentIndex = 0;
} else {
if(chatsModel.activeChannelIndex > -1){
chatGroupsListView.currentIndex = 0;
ListView {
id: chatGroupsListView
anchors.top: parent.top
height: childrenRect.height
anchors.right: parent.right
anchors.left: parent.left
anchors.rightMargin: Style.current.padding
anchors.leftMargin: Style.current.padding
interactive: false
// clip: true
model: chatsModel.chats
delegate: Channel {
name: model.name
muted: model.muted
lastMessage: model.lastMessage
timestamp: model.timestamp
chatType: model.chatType
identicon: model.identicon
unviewedMessagesCount: model.unviewedMessagesCount
hasMentions: model.hasMentions
contentType: model.contentType
searchStr: chatGroupsContainer.searchStr
chatId: model.id
}
onCountChanged: {
if (count > 0 && chatsModel.activeChannelIndex > -1) {
// If a chat is added or removed, we set the current index to the first value
chatsModel.activeChannelIndex = 0;
currentIndex = 0;
} else {
// Initial state. No chat has been selected yet
chatGroupsListView.currentIndex = -1;
if(chatsModel.activeChannelIndex > -1){
chatGroupsListView.currentIndex = 0;
} else {
// Initial state. No chat has been selected yet
chatGroupsListView.currentIndex = -1;
}
}
}
}
}
EmptyView {
width: parent.width
// height: 500
anchors.top: chatGroupsListView.bottom
anchors.topMargin: 10
}
EmptyView {
width: parent.width
// height: 500
anchors.top: chatGroupsListView.bottom
anchors.topMargin: 10
}
}
}
ProfilePopup {
id: profilePopup
@ -161,20 +158,20 @@ Item {
Separator {}
Action {
text: channelContextMenu.channelMuted ?
//% "Unmute chat"
qsTrId("unmute-chat") :
//% "Mute chat"
qsTrId("mute-chat")
text: channelContextMenu.channelMuted ?
//% "Unmute chat"
qsTrId("unmute-chat") :
//% "Mute chat"
qsTrId("mute-chat")
icon.source: "../../../img/bell.svg"
icon.width: 16
icon.height: 16
onTriggered: {
if (chatsModel.channelIsMuted(channelContextMenu.channelIndex)) {
chatsModel.unmuteChannel(channelContextMenu.channelIndex)
return
}
chatsModel.muteChannel(channelContextMenu.channelIndex)
if (chatsModel.channelIsMuted(channelContextMenu.channelIndex)) {
chatsModel.unmuteChannel(channelContextMenu.channelIndex)
return
}
chatsModel.muteChannel(channelContextMenu.channelIndex)
}
}

View File

@ -8,27 +8,13 @@ import "../../../../shared"
import "../../../../imports"
Item {
// ScrollView {
clip: true
// anchors.top: suggestionsText.bottom
// anchors.topMargin: Style.current.smallPadding
// anchors.left: parent.left
// anchors.right: parent.right
// anchors.bottom: parent.bottom
// ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
// ScrollBar.vertical.policy: ScrollBar.AlwaysOn
// Layout.fillHeight: true
// Layout.fillWidth: true
property var onCloseButtonPressed: function () {}
id: emptyView
clip: true
Layout.fillHeight: true
Layout.fillWidth: true
// contentHeight: {
height: {
if (!visible) return 0
var totalHeight = 0
@ -36,7 +22,6 @@ Item {
totalHeight += sectionRepeater.itemAt(i).height + Style.current.padding
}
return inviteFriendsContainer.height + totalHeight + Style.current.padding
// return totalHeight
}
Rectangle {
@ -136,8 +121,6 @@ Item {
anchors.top: inviteFriendsContainer.bottom
anchors.right: parent.right
anchors.left: parent.left
// height: suggestionsText.height + channelFlow.height + 2 * Style.current.xlPadding + Style.current.bigPadding
// height: suggestionsText.height + 2 * Style.current.xlPadding + Style.current.bigPadding
StyledText {
id: suggestionsText
@ -158,28 +141,6 @@ Item {
anchors.leftMargin: Style.current.xlPadding
}
// ScrollView {
// id: sview
// clip: true
// anchors.top: suggestionsText.bottom
// anchors.topMargin: Style.current.smallPadding
// anchors.left: parent.left
// anchors.right: parent.right
// anchors.bottom: parent.bottom
// ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
// ScrollBar.vertical.policy: ScrollBar.AlwaysOn
// Layout.fillHeight: true
// Layout.fillWidth: true
// contentHeight: {
// var totalHeight = 0
// for (let i = 0; i < sectionRepeater.count; i++) {
// totalHeight += sectionRepeater.itemAt(i).height + Style.current.padding
// }
// return totalHeight + Style.current.padding
// }
Item {
anchors.top: suggestionsText.bottom
anchors.topMargin: Style.current.smallPadding
@ -191,94 +152,7 @@ Item {
id: sectionRepeater
}
}
// Repeater {
// id: sectionRepeater
// // anchors.top: suggestionsText.bottom
// // anchors.topMargin: Style.current.smallPadding
// // id: sview
// model: ChannelJSON.categories
// Item {
// anchors.top: index === 0 ? parent.top : parent.children[index - 1].bottom
// anchors.topMargin: index === 0 ? 0 : Style.current.padding
// width: parent.width - Style.current.padding
// height: {
// return childrenRect.height
// }
// // height: {
// // var totalHeight = 0
// // for (let i = 0; i < channelRepeater.count; i++) {
// // totalHeight += channelRepeater.itemAt(i).height + Style.current.padding
// // }
// // return totalHeight
// // }
// Text {
// id: sectionTitle
// text: modelData.name
// font.bold: true
// font.pixelSize: 16
// }
// Flow {
// anchors.top: sectionTitle.bottom
// anchors.topMargin: Style.current.smallPadding
// Layout.fillHeight: true
// Layout.fillWidth: true
// width: parent.width
// spacing: 10
// Repeater {
// id: channelRepeater
// model: modelData.channels
// SuggestedChannel { channel: modelData }
// }
// }
// }
// }
// }
}
// Flow {
// id: channelFlow
// Layout.fillHeight: false
// Layout.fillWidth: true
// spacing: 6
// anchors.right: parent.right
// anchors.rightMargin: Style.current.xlPadding
// anchors.left: parent.left
// anchors.leftMargin: Style.current.xlPadding
// anchors.top: suggestionsText.bottom
// anchors.topMargin: Style.current.bigPadding
// SuggestedChannel {
// channel: "introductions"
// }
// SuggestedChannel {
// channel: "chitchat"
// }
// SuggestedChannel {
// channel: "status"
// }
// SuggestedChannel {
// channel: "crypto"
// }
// SuggestedChannel {
// channel: "tech"
// }
// SuggestedChannel {
// channel: "music"
// }
// SuggestedChannel {
// channel: "movies"
// }
// SuggestedChannel {
// channel: "test"
// }
// SuggestedChannel {
// channel: "test2"
// }
// }
}
}
}
}

View File

@ -13,9 +13,7 @@ Repeater {
anchors.top: index === 0 ? parent.top : parent.children[index - 1].bottom
anchors.topMargin: index === 0 ? 0 : Style.current.padding
width: parent.width - Style.current.padding
height: {
return childrenRect.height
}
height: childrenRect.height
Text {
id: sectionTitle