From 105c4cba4a530749daa5bf3076ff08a02970658c Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Mon, 1 Feb 2021 13:06:21 +0100 Subject: [PATCH] refactor(ContactsContainer): make use of NoFriendsRectangle --- .../Chat/components/NoFriendsRectangle.qml | 5 +-- .../Chat/components/PrivateChatPopup.qml | 34 ++++--------------- .../Profile/Sections/ContactsContainer.qml | 31 ++--------------- 3 files changed, 12 insertions(+), 58 deletions(-) diff --git a/ui/app/AppLayouts/Chat/components/NoFriendsRectangle.qml b/ui/app/AppLayouts/Chat/components/NoFriendsRectangle.qml index b520311dd1..94627be408 100644 --- a/ui/app/AppLayouts/Chat/components/NoFriendsRectangle.qml +++ b/ui/app/AppLayouts/Chat/components/NoFriendsRectangle.qml @@ -6,16 +6,17 @@ import "../../../../shared/status" Rectangle { id: noContactsRect width: 260 + property string text: qsTr("You don’t have any contacts yet. Invite your friends to start chatting.") StyledText { id: noContacts - //% "You don’t have any contacts yet. Invite your friends to start chatting." - text: qsTrId("you-don-t-have-any-contacts-yet--invite-your-friends-to-start-chatting-") + text: noContactsRect.text color: Style.current.darkGrey anchors.top: parent.top anchors.topMargin: Style.current.padding anchors.left: parent.left anchors.right: parent.right wrapMode: Text.WordWrap + font.pixelSize: 15 horizontalAlignment: Text.AlignHCenter } StatusButton { diff --git a/ui/app/AppLayouts/Chat/components/PrivateChatPopup.qml b/ui/app/AppLayouts/Chat/components/PrivateChatPopup.qml index c75feff518..4201e75f09 100644 --- a/ui/app/AppLayouts/Chat/components/PrivateChatPopup.qml +++ b/ui/app/AppLayouts/Chat/components/PrivateChatPopup.qml @@ -149,35 +149,13 @@ ModalPopup { } } - Rectangle { + + NoFriendsRectangle { id: noContactsRect - width: 260 - anchors.centerIn: parent - StyledText { - id: noContacts - //% "You don’t have any contacts yet. Invite your friends to start chatting." - text: qsTrId("you-don-t-have-any-contacts-yet--invite-your-friends-to-start-chatting-") - color: Style.current.darkGrey - anchors.top: parent.top - anchors.topMargin: Style.current.padding - anchors.left: parent.left - anchors.right: parent.right - wrapMode: Text.WordWrap - horizontalAlignment: Text.AlignHCenter - } - StatusButton { - //% "Invite friends" - text: qsTrId("invite-friends") - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: noContacts.bottom - anchors.topMargin: Style.current.xlPadding - onClicked: { - inviteFriendsPopup.open() - } - } - InviteFriendsPopup { - id: inviteFriendsPopup - } + visible: profileModel.contacts.addedContacts.rowCount() === 0 + text: qsTr("You don’t have any contacts yet. Invite your friends to start chatting.") + width: parent.width + anchors.verticalCenter: parent.verticalCenter } } } diff --git a/ui/app/AppLayouts/Profile/Sections/ContactsContainer.qml b/ui/app/AppLayouts/Profile/Sections/ContactsContainer.qml index fd178aa19b..46790191f7 100644 --- a/ui/app/AppLayouts/Profile/Sections/ContactsContainer.qml +++ b/ui/app/AppLayouts/Profile/Sections/ContactsContainer.qml @@ -232,37 +232,12 @@ Item { searchString: searchBox.text } - Item { + NoFriendsRectangle { id: element visible: profileModel.contacts.addedContacts.rowCount() === 0 - anchors.top: addNewContact.bottom + text: qsTr("You don’t have any contacts yet") width: parent.width - anchors.bottom: parent.bottom - - StyledText { - id: noFriendsText - //% "You don’t have any contacts yet" - text: qsTrId("you-don-t-have-any-contacts-yet") - anchors.verticalCenterOffset: -Style.current.bigPadding - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - font.pixelSize: 15 - color: Style.current.darkGrey - } - - StatusButton { - anchors.horizontalCenter: noFriendsText.horizontalCenter - anchors.top: noFriendsText.bottom - anchors.topMargin: Style.current.bigPadding - //% "Invite friends" - text: qsTrId("invite-friends") - onClicked: function () { - inviteFriendsPopup.open() - } - } - } - InviteFriendsPopup { - id: inviteFriendsPopup + anchors.verticalCenter: parent.verticalCenter } } }