From 477f5aa460db92ea2be1612f97792c0c3739d8db Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Sun, 9 Aug 2020 22:14:21 -0400 Subject: [PATCH] feat: display empty state when user has no contacts --- src/app/profile/views/contact_list.nim | 5 +++ .../Chat/components/GroupChatPopup.qml | 38 ++++++++++++++++++ .../Chat/components/GroupInfoPopup.qml | 40 ++++++++++++++++--- .../Chat/components/PrivateChatPopup.qml | 31 ++++++++++++++ 4 files changed, 108 insertions(+), 6 deletions(-) diff --git a/src/app/profile/views/contact_list.nim b/src/app/profile/views/contact_list.nim index d6bc04ffad..07cc7f76d7 100644 --- a/src/app/profile/views/contact_list.nim +++ b/src/app/profile/views/contact_list.nim @@ -78,6 +78,11 @@ QtObject: self.contacts.add(contact) self.endInsertRows() + proc hasAddedContacts(self: ContactList): bool {.slot.} = + for c in self.contacts: + if(c.isContact()): return true + return false + proc updateContact*(self: ContactList, contact: Profile) = var found = false let topLeft = self.createIndex(0, 0, nil) diff --git a/ui/app/AppLayouts/Chat/components/GroupChatPopup.qml b/ui/app/AppLayouts/Chat/components/GroupChatPopup.qml index 24aa28ff9e..110cfefd5b 100644 --- a/ui/app/AppLayouts/Chat/components/GroupChatPopup.qml +++ b/ui/app/AppLayouts/Chat/components/GroupChatPopup.qml @@ -46,6 +46,11 @@ ModalPopup { identicon: profileModel.profile.identicon, isUser: true }); + noContactsRect.visible = !profileModel.contactList.hasAddedContacts(); + svMembers.visible = !noContactsRect.visible; + if(!svMembers.visible){ + memberCount = 0; + } } function doJoin(){ @@ -94,6 +99,38 @@ ModalPopup { visible: !selectChatMembers } + Rectangle { + id: noContactsRect + width: 260 + anchors.top: groupName.bottom + anchors.topMargin: Style.current.xlPadding + anchors.horizontalCenter: parent.horizontalCenter + StyledText { + id: noContacts + text: qsTr("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 + } + StyledButton { + //% "Invite friends" + label: qsTrId("invite-friends") + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: noContacts.bottom + anchors.topMargin: Style.current.xlPadding + onClicked: { + inviteFriendsPopup.open() + } + } + InviteFriendsPopup { + id: inviteFriendsPopup + } + } + ScrollView { anchors.fill: parent anchors.topMargin: 50 @@ -101,6 +138,7 @@ ModalPopup { Layout.fillWidth: true Layout.fillHeight: true + id: svMembers ScrollBar.horizontal.policy: ScrollBar.AlwaysOff ScrollBar.vertical.policy: groupMembers.contentHeight > groupMembers.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff diff --git a/ui/app/AppLayouts/Chat/components/GroupInfoPopup.qml b/ui/app/AppLayouts/Chat/components/GroupInfoPopup.qml index 733bbeba37..d36802c2b3 100644 --- a/ui/app/AppLayouts/Chat/components/GroupInfoPopup.qml +++ b/ui/app/AppLayouts/Chat/components/GroupInfoPopup.qml @@ -18,11 +18,6 @@ ModalPopup { pubKeys = []; memberCount = chatsModel.activeChannel.members.rowCount(); currMemberCount = memberCount; - for(var i in groupMembers.contentItem.children){ - if (groupMembers.contentItem.children[i].isChecked !== null) { - groupMembers.contentItem.children[i].isChecked = false - } - } data.clear(); for(let i = 0; i < profileModel.contactList.rowCount(); i++){ if(chatsModel.activeChannel.contains(profileModel.contactList.rowData(i, "pubKey"))) continue; @@ -162,8 +157,41 @@ ModalPopup { fontPixelSize: 15 } + Rectangle { + id: noContactsRect + width: 320 + visible: data.count == 0 + anchors.top: searchBox.bottom + anchors.topMargin: Style.current.xlPadding + anchors.horizontalCenter: parent.horizontalCenter + StyledText { + id: noContacts + text: qsTr("All your contacts are already in the group") + color: Style.current.textColor + anchors.top: parent.top + anchors.topMargin: Style.current.padding + anchors.left: parent.left + anchors.right: parent.right + wrapMode: Text.WordWrap + horizontalAlignment: Text.AlignHCenter + } + StyledButton { + //% "Invite friends" + label: qsTrId("invite-friends") + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: noContacts.bottom + anchors.topMargin: Style.current.padding + onClicked: { + inviteFriendsPopup.open() + } + } + InviteFriendsPopup { + id: inviteFriendsPopup + } + } + ScrollView { - visible: addMembers + visible: addMembers && data.count > 0 anchors.fill: parent anchors.topMargin: 50 anchors.top: searchBox.bottom diff --git a/ui/app/AppLayouts/Chat/components/PrivateChatPopup.qml b/ui/app/AppLayouts/Chat/components/PrivateChatPopup.qml index 8e08df8da4..3b894d130b 100644 --- a/ui/app/AppLayouts/Chat/components/PrivateChatPopup.qml +++ b/ui/app/AppLayouts/Chat/components/PrivateChatPopup.qml @@ -56,6 +56,7 @@ ModalPopup { pubKey = ""; ensUsername.text = ""; chatKey.forceActiveFocus(Qt.MouseFocusReason) + noContactsRect.visible = !profileModel.contactList.hasAddedContacts() } Input { @@ -128,6 +129,36 @@ ModalPopup { } } } + + Rectangle { + id: noContactsRect + width: 260 + anchors.centerIn: parent + StyledText { + id: noContacts + text: qsTr("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 + } + StyledButton { + //% "Invite friends" + label: qsTrId("invite-friends") + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: noContacts.bottom + anchors.topMargin: Style.current.xlPadding + onClicked: { + inviteFriendsPopup.open() + } + } + InviteFriendsPopup { + id: inviteFriendsPopup + } + } } }