2020-12-11 20:38:10 +00:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.3
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import QtQml.Models 2.3
|
|
|
|
import "../../../../imports"
|
|
|
|
import "../../../../shared"
|
|
|
|
import "../../../../shared/status"
|
|
|
|
import "./"
|
|
|
|
import "../components"
|
|
|
|
|
|
|
|
ModalPopup {
|
|
|
|
id: popup
|
|
|
|
|
|
|
|
property var pubKeys: []
|
|
|
|
property var goBack
|
|
|
|
|
|
|
|
onOpened: {
|
|
|
|
pubKeys = [];
|
|
|
|
inviteBtn.enabled = false
|
|
|
|
contactList.membersData.clear();
|
|
|
|
// TODO remove friends that are already members
|
|
|
|
chatView.getContactListObject(contactList.membersData)
|
|
|
|
noContactsRect.visible = !profileModel.contacts.list.hasAddedContacts();
|
|
|
|
contactList.visible = !noContactsRect.visible;
|
|
|
|
}
|
|
|
|
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Invite friends"
|
|
|
|
title: qsTrId("invite-friends")
|
2020-12-11 20:38:10 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
2020-12-17 23:12:05 +00:00
|
|
|
|
|
|
|
TextWithLabel {
|
|
|
|
id: shareCommunity
|
|
|
|
anchors.top: parent.top
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Share community"
|
|
|
|
label: qsTrId("share-community")
|
2020-12-17 23:12:05 +00:00
|
|
|
text: "https://join.status.im/u/TODO"
|
|
|
|
textToCopy: text
|
|
|
|
}
|
|
|
|
|
|
|
|
Separator {
|
|
|
|
id: sep
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: shareCommunity.bottom
|
|
|
|
anchors.topMargin: Style.current.smallPadding
|
|
|
|
anchors.leftMargin: -Style.current.padding
|
|
|
|
anchors.rightMargin: -Style.current.padding
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Contacts"
|
|
|
|
text: qsTrId("contacts")
|
2020-12-17 23:12:05 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.top: sep.bottom
|
|
|
|
anchors.topMargin: Style.current.smallPadding
|
|
|
|
font.pixelSize: 15
|
|
|
|
font.weight: Font.Thin
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
}
|
|
|
|
|
2020-12-11 20:38:10 +00:00
|
|
|
NoFriendsRectangle {
|
|
|
|
id: noContactsRect
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
ContactList {
|
|
|
|
id: contactList
|
|
|
|
selectMode: true
|
2020-12-17 23:12:05 +00:00
|
|
|
anchors.top: sep.bottom
|
|
|
|
anchors.topMargin: 100
|
2020-12-11 20:38:10 +00:00
|
|
|
onItemChecked: function(pubKey, itemChecked) {
|
|
|
|
var idx = pubKeys.indexOf(pubKey)
|
|
|
|
if (itemChecked) {
|
|
|
|
if (idx === -1) {
|
|
|
|
pubKeys.push(pubKey)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (idx > -1) {
|
|
|
|
pubKeys.splice(idx, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
inviteBtn.enabled = pubKeys.length > 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
footer: Item {
|
2021-01-13 19:15:52 +00:00
|
|
|
width: parent.width
|
|
|
|
height: inviteBtn.height
|
2020-12-11 20:38:10 +00:00
|
|
|
|
|
|
|
StatusRoundButton {
|
|
|
|
id: btnBack
|
|
|
|
anchors.left: parent.left
|
|
|
|
visible: !!popup.goBack
|
|
|
|
icon.name: "arrow-right"
|
|
|
|
icon.width: 20
|
|
|
|
icon.height: 16
|
|
|
|
rotation: 180
|
|
|
|
onClicked: {
|
|
|
|
// Go back? Make it work when it's
|
|
|
|
popup.goBack()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
id: inviteBtn
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.right: parent.right
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Invite"
|
|
|
|
text: qsTrId("invite-button")
|
2020-12-11 20:38:10 +00:00
|
|
|
onClicked : {
|
|
|
|
console.log('invite')
|
|
|
|
popup.pubKeys.forEach(function (pubKey) {
|
|
|
|
const error = chatsModel.inviteUserToCommunity(pubKey)
|
|
|
|
if (error) {
|
|
|
|
console.log('do something?')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|