Improve tabbar in room list.

This commit is contained in:
Black Hat
2019-07-12 15:30:57 +08:00
parent 7b4e2cbb7f
commit 7f05c67534

View File

@@ -18,7 +18,7 @@ Item {
property var connection: null property var connection: null
readonly property var user: connection ? connection.localUser : null readonly property var user: connection ? connection.localUser : null
property int filter: tabBar.currentIndex property int filter: 0
property var enteredRoom: null property var enteredRoom: null
signal enterRoom(var room) signal enterRoom(var room)
@@ -178,8 +178,6 @@ Item {
background: Rectangle { background: Rectangle {
color: Material.background color: Material.background
opacity: listView.atYBeginning ? 0 : 1
layer.enabled: true layer.enabled: true
layer.effect: ElevationEffect { layer.effect: ElevationEffect {
elevation: 2 elevation: 2
@@ -193,8 +191,9 @@ Item {
id: listView id: listView
z: -1
spacing: 0 spacing: 0
clip: true
model: sortedRoomListModel model: sortedRoomListModel
@@ -352,54 +351,185 @@ Item {
} }
} }
TabBar { Control {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 48
Layout.margins: 16
id: tabBar padding: 8
TabButton { contentItem: RowLayout {
contentItem: Item { id: tabBar
MaterialIcon {
anchors.centerIn: parent
icon: "\ue7f5" spacing: 8
color: MPalette.lighter
Rectangle { Control {
anchors.right: parent.right readonly property bool highlighted: filter === 0
anchors.top: parent.top
visible: roomListModel.notificationCount > 0 Layout.fillWidth: highlighted
Layout.fillHeight: true
width: 12 id: newTabControl
height: 12
radius: 6
color: "white" horizontalPadding: 8
background: Rectangle {
visible: newTabControl.highlighted
color: Material.accent
border.color: Material.accent
border.width: 2
radius: height / 2
}
contentItem: RowLayout {
spacing: 0
MaterialIcon {
Layout.preferredWidth: 32
Layout.preferredHeight: 32
icon: "\ue7f5"
color: newTabControl.highlighted ? "white" : MPalette.lighter
Rectangle { Rectangle {
anchors.centerIn: parent anchors.right: parent.right
anchors.top: parent.top
width: 8 visible: roomListModel.notificationCount > 0
height: 8
radius: 4
color: "red" width: 12
height: 12
radius: 6
color: "white"
Rectangle {
anchors.centerIn: parent
width: 8
height: 8
radius: 4
color: "red"
}
} }
} }
Label {
Layout.alignment: Qt.AlignVCenter
visible: newTabControl.highlighted
text: "New"
color: "white"
}
}
MouseArea {
anchors.fill: parent
onClicked: filter = 0
}
}
Control {
readonly property bool highlighted: filter === 1
Layout.fillWidth: highlighted
Layout.fillHeight: true
id: peopleTabControl
horizontalPadding: 8
background: Rectangle {
visible: peopleTabControl.highlighted
color: Material.accent
border.color: Material.accent
border.width: 2
radius: height / 2
}
contentItem: RowLayout {
spacing: 0
MaterialIcon {
Layout.preferredWidth: 32
Layout.preferredHeight: 32
icon: "\ue7ff"
color: peopleTabControl.highlighted ? "white" : MPalette.lighter
}
Label {
Layout.alignment: Qt.AlignVCenter
visible: peopleTabControl.highlighted
text: "People"
color: "white"
}
}
MouseArea {
anchors.fill: parent
onClicked: filter = 1
}
}
Control {
readonly property bool highlighted: filter === 2
Layout.fillWidth: highlighted
Layout.fillHeight: true
id: groupTabControl
horizontalPadding: 8
background: Rectangle {
visible: groupTabControl.highlighted
color: Material.accent
border.color: Material.accent
border.width: 2
radius: height / 2
}
contentItem: RowLayout {
spacing: 0
MaterialIcon {
Layout.preferredWidth: 32
Layout.preferredHeight: 32
icon: "\ue7fc"
color: groupTabControl.highlighted ? "white" : MPalette.lighter
}
Label {
Layout.alignment: Qt.AlignVCenter
visible: groupTabControl.highlighted
text: "Group"
color: "white"
}
}
MouseArea {
anchors.fill: parent
onClicked: filter = 2
} }
} }
} }
TabButton {
contentItem: MaterialIcon { background: Rectangle {
icon: "\ue7ff" color: MSettings.darkTheme ? "#303030" : "#fafafa"
color: MPalette.lighter radius: 24
}
} layer.enabled: true
TabButton { layer.effect: ElevationEffect {
contentItem: MaterialIcon { elevation: 1
icon: "\ue7fc"
color: MPalette.lighter
} }
} }
} }