feat(StatusChatToolBar): Add flexible component in right toolbar position
- Added loader in right component position and removed `StatusChatInfoButton` specific. - Updated sandbox and added new example in Layouts with another different component than the `StatusChatInfoButton`. BREAKING CHANGES: The toolbar now expects a component to be loaded. The previous `StatusChatInfoButton` component has been removed and needs to be passed as a component from outside whenever needed. Breaking changes in `desktop` will be addressed in: https://github.com/status-im/status-desktop/pull/5823
This commit is contained in:
parent
46cd904ced
commit
1cadfc051b
|
@ -10,31 +10,92 @@ import StatusQ.Layout 0.1
|
||||||
import StatusQ.Popups 0.1
|
import StatusQ.Popups 0.1
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
spacing: 5
|
spacing: 10
|
||||||
|
|
||||||
StatusChatToolBar {
|
StatusChatToolBar {
|
||||||
chatInfoButton.title: "Some contact"
|
toolbarComponent: chatInfoButton1
|
||||||
chatInfoButton.subTitle: "Contact"
|
width: 518
|
||||||
chatInfoButton.icon.color: Theme.palette.miscColor7
|
|
||||||
chatInfoButton.type: StatusChatInfoButton.Type.OneToOneChat
|
Component {
|
||||||
|
id: chatInfoButton1
|
||||||
|
|
||||||
|
StatusChatInfoButton {
|
||||||
|
width: Math.min(implicitWidth, parent.width)
|
||||||
|
title: "Some contact"
|
||||||
|
subTitle: "Contact"
|
||||||
|
icon.color: Theme.palette.miscColor7
|
||||||
|
type: StatusChatInfoButton.Type.OneToOneChat
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusChatToolBar {
|
StatusChatToolBar {
|
||||||
chatInfoButton.title: "Some contact"
|
toolbarComponent: chatInfoButton2
|
||||||
chatInfoButton.subTitle: "Contact"
|
width: 518
|
||||||
chatInfoButton.icon.color: Theme.palette.miscColor7
|
|
||||||
chatInfoButton.type: StatusChatInfoButton.Type.PublicChat
|
Component {
|
||||||
chatInfoButton.pinnedMessagesCount: 1
|
id: chatInfoButton2
|
||||||
chatInfoButton.muted: true
|
StatusChatInfoButton {
|
||||||
|
width: Math.min(implicitWidth, parent.width)
|
||||||
|
title: "Some contact"
|
||||||
|
subTitle: "Contact"
|
||||||
|
icon.color: Theme.palette.miscColor7
|
||||||
|
type: StatusChatInfoButton.Type.PublicChat
|
||||||
|
pinnedMessagesCount: 1
|
||||||
|
muted: true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
StatusChatToolBar {
|
StatusChatToolBar {
|
||||||
chatInfoButton.title: "Some contact"
|
|
||||||
chatInfoButton.subTitle: "Contact"
|
|
||||||
chatInfoButton.icon.color: Theme.palette.miscColor7
|
|
||||||
chatInfoButton.type: StatusChatInfoButton.Type.OneToOneChat
|
|
||||||
chatInfoButton.pinnedMessagesCount: 1
|
|
||||||
notificationCount: 1
|
notificationCount: 1
|
||||||
|
toolbarComponent: chatInfoButton3
|
||||||
|
width: 518
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: chatInfoButton3
|
||||||
|
|
||||||
|
StatusChatInfoButton {
|
||||||
|
width: Math.min(implicitWidth, parent.width)
|
||||||
|
title: "Some contact"
|
||||||
|
subTitle: "Contact"
|
||||||
|
icon.color: Theme.palette.miscColor7
|
||||||
|
type: StatusChatInfoButton.Type.OneToOneChat
|
||||||
|
pinnedMessagesCount: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StatusChatToolBar {
|
||||||
|
notificationCount: 1
|
||||||
|
toolbarComponent: tagSelector
|
||||||
|
width: 518
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: tagSelector
|
||||||
|
|
||||||
|
StatusTagSelector {
|
||||||
|
namesModel: ListModel {
|
||||||
|
ListElement {
|
||||||
|
publicId: "0x0"
|
||||||
|
name: "Maria"
|
||||||
|
icon: ""
|
||||||
|
isIdenticon: false
|
||||||
|
onlineStatus: 3
|
||||||
|
}
|
||||||
|
ListElement {
|
||||||
|
publicId: "0x1"
|
||||||
|
name: "James"
|
||||||
|
icon: ""
|
||||||
|
isIdenticon: false
|
||||||
|
onlineStatus: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
toLabelText: qsTr("To: ")
|
||||||
|
warningText: qsTr("USER LIMIT REACHED")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
|
|
|
@ -145,15 +145,8 @@ StatusAppThreePanelLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
StatusChatToolBar {
|
StatusChatToolBar {
|
||||||
anchors.top: parent.top
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
toolbarComponent: statusChatInfoButton
|
||||||
chatInfoButton.title: "Amazing Funny Squirrel"
|
|
||||||
chatInfoButton.subTitle: "Contact"
|
|
||||||
chatInfoButton.icon.color: Theme.palette.miscColor7
|
|
||||||
chatInfoButton.type: StatusChatInfoButton.Type.OneToOneChat
|
|
||||||
chatInfoButton.pinnedMessagesCount: 1
|
|
||||||
|
|
||||||
searchButton.visible: false
|
searchButton.visible: false
|
||||||
membersButton.visible: false
|
membersButton.visible: false
|
||||||
notificationCount: 1
|
notificationCount: 1
|
||||||
|
@ -186,6 +179,19 @@ StatusAppThreePanelLayout {
|
||||||
type: StatusMenuItem.Type.Danger
|
type: StatusMenuItem.Type.Danger
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: statusChatInfoButton
|
||||||
|
|
||||||
|
StatusChatInfoButton {
|
||||||
|
width: Math.min(implicitWidth, parent.width)
|
||||||
|
title: "Amazing Funny Squirrel"
|
||||||
|
subTitle: "Contact"
|
||||||
|
icon.color: Theme.palette.miscColor7
|
||||||
|
type: StatusChatInfoButton.Type.OneToOneChat
|
||||||
|
pinnedMessagesCount: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,13 +166,10 @@ StatusAppThreePanelLayout {
|
||||||
centerPanel: Item {
|
centerPanel: Item {
|
||||||
StatusChatToolBar {
|
StatusChatToolBar {
|
||||||
id: statusChatToolBar
|
id: statusChatToolBar
|
||||||
anchors.top: parent.top
|
|
||||||
width: parent.width
|
|
||||||
|
|
||||||
chatInfoButton.title: "general"
|
width: parent.width
|
||||||
chatInfoButton.subTitle: "Community Chat"
|
toolbarComponent: statusChatInfoButton
|
||||||
chatInfoButton.icon.color: Theme.palette.miscColor6
|
|
||||||
chatInfoButton.type: StatusChatInfoButton.Type.CommunityChat
|
|
||||||
onSearchButtonClicked: {
|
onSearchButtonClicked: {
|
||||||
searchButton.highlighted = !searchButton.highlighted;
|
searchButton.highlighted = !searchButton.highlighted;
|
||||||
searchPopup.setSearchSelection(communityDetailModalTitle,
|
searchPopup.setSearchSelection(communityDetailModalTitle,
|
||||||
|
@ -184,6 +181,18 @@ StatusAppThreePanelLayout {
|
||||||
onMembersButtonClicked: {
|
onMembersButtonClicked: {
|
||||||
root.showRightPanel = !root.showRightPanel;
|
root.showRightPanel = !root.showRightPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: statusChatInfoButton
|
||||||
|
|
||||||
|
StatusChatInfoButton {
|
||||||
|
width: Math.min(implicitWidth, parent.width)
|
||||||
|
title: "general"
|
||||||
|
subTitle: "Community Chat"
|
||||||
|
icon.color: Theme.palette.miscColor6
|
||||||
|
type: StatusChatInfoButton.Type.CommunityChat
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusSearchPopup {
|
StatusSearchPopup {
|
||||||
|
|
|
@ -1,24 +1,22 @@
|
||||||
import QtQuick 2.14
|
import QtQuick 2.14
|
||||||
import QtQuick.Controls 2.14
|
import QtQuick.Controls 2.14
|
||||||
|
import QtQuick.Layouts 1.13
|
||||||
|
|
||||||
import StatusQ.Core 0.1
|
import StatusQ.Core 0.1
|
||||||
import StatusQ.Core.Theme 0.1
|
import StatusQ.Core.Theme 0.1
|
||||||
import StatusQ.Controls 0.1
|
import StatusQ.Controls 0.1
|
||||||
|
Item {
|
||||||
Rectangle {
|
|
||||||
id: statusChatToolBar
|
id: statusChatToolBar
|
||||||
implicitWidth: 518
|
|
||||||
height: 56
|
|
||||||
color: Theme.palette.statusAppLayout.backgroundColor
|
|
||||||
|
|
||||||
property alias chatInfoButton: statusChatInfoButton
|
|
||||||
property alias menuButton: menuButton
|
property alias menuButton: menuButton
|
||||||
property alias notificationButton: notificationButton
|
property alias notificationButton: notificationButton
|
||||||
property alias membersButton: membersButton
|
property alias membersButton: membersButton
|
||||||
property alias searchButton: searchButton
|
property alias searchButton: searchButton
|
||||||
property int notificationCount: 0
|
|
||||||
|
|
||||||
|
property int padding: 8
|
||||||
|
property int notificationCount: 0
|
||||||
property Component popupMenu
|
property Component popupMenu
|
||||||
|
property var toolbarComponent
|
||||||
|
|
||||||
signal chatInfoButtonClicked()
|
signal chatInfoButtonClicked()
|
||||||
signal menuButtonClicked()
|
signal menuButtonClicked()
|
||||||
|
@ -26,150 +24,156 @@ Rectangle {
|
||||||
signal membersButtonClicked()
|
signal membersButtonClicked()
|
||||||
signal searchButtonClicked()
|
signal searchButtonClicked()
|
||||||
|
|
||||||
|
implicitWidth: 518
|
||||||
|
implicitHeight: 60
|
||||||
|
|
||||||
onPopupMenuChanged: {
|
onPopupMenuChanged: {
|
||||||
if (!!popupMenu) {
|
if (!!popupMenu) {
|
||||||
popupMenuSlot.sourceComponent = popupMenu
|
popupMenuSlot.sourceComponent = popupMenu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusChatInfoButton {
|
RowLayout {
|
||||||
id: statusChatInfoButton
|
width: parent.width
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
spacing: padding / 2
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.leftMargin: 12
|
|
||||||
width: Math.min(implicitWidth, parent.width - actionButtons.implicitWidth - anchors.leftMargin * 2)
|
|
||||||
onClicked: statusChatToolBar.chatInfoButtonClicked()
|
|
||||||
}
|
|
||||||
|
|
||||||
Row {
|
Loader {
|
||||||
id: actionButtons
|
id: loader
|
||||||
anchors.right: parent.right
|
sourceComponent: statusChatToolBar.toolbarComponent
|
||||||
anchors.rightMargin: 8
|
Layout.fillWidth: true
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
|
||||||
|
Layout.topMargin: padding
|
||||||
spacing: 8
|
Layout.leftMargin: padding
|
||||||
|
|
||||||
StatusFlatRoundButton {
|
|
||||||
id: searchButton
|
|
||||||
width: 32
|
|
||||||
height: 32
|
|
||||||
icon.name: "search"
|
|
||||||
type: StatusFlatRoundButton.Type.Secondary
|
|
||||||
onClicked: statusChatToolBar.searchButtonClicked()
|
|
||||||
|
|
||||||
// initializing the tooltip
|
|
||||||
tooltip.text: qsTr("Search")
|
|
||||||
tooltip.orientation: StatusToolTip.Orientation.Bottom
|
|
||||||
tooltip.y: parent.height + 12
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusFlatRoundButton {
|
RowLayout {
|
||||||
id: membersButton
|
id: actionButtons
|
||||||
width: 32
|
Layout.alignment: Qt.AlignTop | Qt.AlignRight
|
||||||
height: 32
|
Layout.topMargin: padding
|
||||||
icon.name: "group-chat"
|
Layout.rightMargin: padding
|
||||||
type: StatusFlatRoundButton.Type.Secondary
|
spacing: 8
|
||||||
onClicked: statusChatToolBar.membersButtonClicked()
|
|
||||||
|
|
||||||
// initializing the tooltip
|
StatusFlatRoundButton {
|
||||||
tooltip.text: qsTr("Members")
|
id: searchButton
|
||||||
tooltip.orientation: StatusToolTip.Orientation.Bottom
|
width: 32
|
||||||
tooltip.y: parent.height + 12
|
height: 32
|
||||||
}
|
icon.name: "search"
|
||||||
|
type: StatusFlatRoundButton.Type.Secondary
|
||||||
|
onClicked: statusChatToolBar.searchButtonClicked()
|
||||||
|
|
||||||
StatusFlatRoundButton {
|
// initializing the tooltip
|
||||||
id: menuButton
|
tooltip.text: qsTr("Search")
|
||||||
width: 32
|
tooltip.orientation: StatusToolTip.Orientation.Bottom
|
||||||
height: 32
|
tooltip.y: parent.height + 12
|
||||||
icon.name: "more"
|
|
||||||
type: StatusFlatRoundButton.Type.Secondary
|
|
||||||
visible: !!statusChatToolBar.popupMenu
|
|
||||||
|
|
||||||
// initializing the tooltip
|
|
||||||
tooltip.visible: !!tooltip.text && menuButton.hovered && !popupMenuSlot.item.opened
|
|
||||||
tooltip.text: qsTr("More")
|
|
||||||
tooltip.orientation: StatusToolTip.Orientation.Bottom
|
|
||||||
tooltip.y: parent.height + 12
|
|
||||||
|
|
||||||
property bool showMoreMenu: false
|
|
||||||
onClicked: {
|
|
||||||
menuButton.highlighted = true
|
|
||||||
|
|
||||||
let originalOpenHandler = popupMenuSlot.item.openHandler
|
|
||||||
let originalCloseHandler = popupMenuSlot.item.closeHandler
|
|
||||||
|
|
||||||
popupMenuSlot.item.openHandler = function () {
|
|
||||||
if (!!originalOpenHandler) {
|
|
||||||
originalOpenHandler()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
popupMenuSlot.item.closeHandler = function () {
|
|
||||||
menuButton.highlighted = false
|
|
||||||
if (!!originalCloseHandler) {
|
|
||||||
originalCloseHandler()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
popupMenuSlot.item.openHandler = originalOpenHandler
|
|
||||||
popupMenuSlot.item.popup(-popupMenuSlot.item.width + menuButton.width, menuButton.height + 4)
|
|
||||||
statusChatToolBar.menuButtonClicked()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader {
|
StatusFlatRoundButton {
|
||||||
id: popupMenuSlot
|
id: membersButton
|
||||||
active: !!statusChatToolBar.popupMenu
|
width: 32
|
||||||
|
height: 32
|
||||||
|
icon.name: "group-chat"
|
||||||
|
type: StatusFlatRoundButton.Type.Secondary
|
||||||
|
onClicked: statusChatToolBar.membersButtonClicked()
|
||||||
|
|
||||||
|
// initializing the tooltip
|
||||||
|
tooltip.text: qsTr("Members")
|
||||||
|
tooltip.orientation: StatusToolTip.Orientation.Bottom
|
||||||
|
tooltip.y: parent.height + 12
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
StatusFlatRoundButton {
|
||||||
height: 24
|
id: menuButton
|
||||||
width: 1
|
width: 32
|
||||||
color: Theme.palette.directColor7
|
height: 32
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
icon.name: "more"
|
||||||
visible: notificationButton.visible &&
|
type: StatusFlatRoundButton.Type.Secondary
|
||||||
(menuButton.visible || membersButton.visible || searchButton.visible)
|
visible: !!statusChatToolBar.popupMenu
|
||||||
}
|
|
||||||
|
|
||||||
StatusFlatRoundButton {
|
// initializing the tooltip
|
||||||
id: notificationButton
|
tooltip.visible: !!tooltip.text && menuButton.hovered && !popupMenuSlot.item.opened
|
||||||
width: 32
|
tooltip.text: qsTr("More")
|
||||||
height: 32
|
tooltip.orientation: StatusToolTip.Orientation.Bottom
|
||||||
|
tooltip.y: parent.height + 12
|
||||||
|
|
||||||
icon.name: "notification"
|
property bool showMoreMenu: false
|
||||||
icon.height: 21
|
onClicked: {
|
||||||
type: StatusFlatRoundButton.Type.Secondary
|
menuButton.highlighted = true
|
||||||
|
|
||||||
// initializing the tooltip
|
let originalOpenHandler = popupMenuSlot.item.openHandler
|
||||||
tooltip.text: qsTr("Activity")
|
let originalCloseHandler = popupMenuSlot.item.closeHandler
|
||||||
tooltip.orientation: StatusToolTip.Orientation.Bottom
|
|
||||||
tooltip.y: parent.height + 12
|
|
||||||
|
|
||||||
onClicked: statusChatToolBar.notificationButtonClicked()
|
popupMenuSlot.item.openHandler = function () {
|
||||||
|
if (!!originalOpenHandler) {
|
||||||
StatusBadge {
|
originalOpenHandler()
|
||||||
id: statusBadge
|
}
|
||||||
|
|
||||||
visible: value > 0
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.left: parent.right
|
|
||||||
anchors.topMargin: -3
|
|
||||||
anchors.leftMargin: {
|
|
||||||
if (statusBadge.value > 99) {
|
|
||||||
return -22
|
|
||||||
}
|
}
|
||||||
if (statusBadge.value > 9) {
|
|
||||||
return -21
|
popupMenuSlot.item.closeHandler = function () {
|
||||||
|
menuButton.highlighted = false
|
||||||
|
if (!!originalCloseHandler) {
|
||||||
|
originalCloseHandler()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return -18
|
|
||||||
|
popupMenuSlot.item.openHandler = originalOpenHandler
|
||||||
|
popupMenuSlot.item.popup(-popupMenuSlot.item.width + menuButton.width, menuButton.height + 4)
|
||||||
|
statusChatToolBar.menuButtonClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
value: statusChatToolBar.notificationCount
|
Loader {
|
||||||
border.width: 2
|
id: popupMenuSlot
|
||||||
border.color: parent.hovered ? Theme.palette.baseColor2 : Theme.palette.statusAppLayout.backgroundColor
|
active: !!statusChatToolBar.popupMenu
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
height: 24
|
||||||
|
width: 1
|
||||||
|
color: Theme.palette.directColor7
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
visible: notificationButton.visible &&
|
||||||
|
(menuButton.visible || membersButton.visible || searchButton.visible)
|
||||||
|
}
|
||||||
|
|
||||||
|
StatusFlatRoundButton {
|
||||||
|
id: notificationButton
|
||||||
|
width: 32
|
||||||
|
height: 32
|
||||||
|
|
||||||
|
icon.name: "notification"
|
||||||
|
icon.height: 21
|
||||||
|
type: StatusFlatRoundButton.Type.Secondary
|
||||||
|
|
||||||
|
// initializing the tooltip
|
||||||
|
tooltip.text: qsTr("Activity")
|
||||||
|
tooltip.orientation: StatusToolTip.Orientation.Bottom
|
||||||
|
tooltip.y: parent.height + 12
|
||||||
|
|
||||||
|
onClicked: statusChatToolBar.notificationButtonClicked()
|
||||||
|
|
||||||
|
StatusBadge {
|
||||||
|
id: statusBadge
|
||||||
|
|
||||||
|
visible: value > 0
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.left: parent.right
|
||||||
|
anchors.topMargin: -3
|
||||||
|
anchors.leftMargin: {
|
||||||
|
if (statusBadge.value > 99) {
|
||||||
|
return -22
|
||||||
|
}
|
||||||
|
if (statusBadge.value > 9) {
|
||||||
|
return -21
|
||||||
|
}
|
||||||
|
return -18
|
||||||
|
}
|
||||||
|
|
||||||
|
value: statusChatToolBar.notificationCount
|
||||||
|
border.width: 2
|
||||||
|
border.color: parent.hovered ? Theme.palette.baseColor2 : Theme.palette.statusAppLayout.backgroundColor
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue