2022-01-19 22:33:29 +00:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
|
|
|
Page {
|
|
|
|
id: root
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: 16
|
|
|
|
property ListModel contactsModel: null
|
|
|
|
background: null
|
|
|
|
|
|
|
|
header: RowLayout {
|
|
|
|
id: headerRow
|
|
|
|
width: parent.width
|
|
|
|
height: tagSelector.height
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 8
|
2022-07-15 16:35:59 +00:00
|
|
|
spacing: 16
|
2022-01-19 22:33:29 +00:00
|
|
|
|
|
|
|
StatusTagSelector {
|
|
|
|
id: tagSelector
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
|
|
|
|
Layout.leftMargin: 17
|
2022-03-24 22:03:36 +00:00
|
|
|
maxHeight: root.height
|
2022-01-19 22:33:29 +00:00
|
|
|
toLabelText: qsTr("To: ")
|
2022-03-24 22:03:36 +00:00
|
|
|
warningText: qsTr("USER LIMIT REACHED")
|
|
|
|
listLabel: qsTr("Contacts")
|
2022-05-19 09:02:36 +00:00
|
|
|
ringSpecModelGetter: function(pubKey) {
|
|
|
|
//for simulation purposes only, in real app
|
|
|
|
//this would be Utils.getColorHashAsJson(pubKey)
|
|
|
|
var index = -1;
|
|
|
|
if (!!contactsModel) {
|
|
|
|
for (var i = 0; i < contactsModel.count; i++) {
|
2022-06-12 14:25:17 +00:00
|
|
|
if (contactsModel.get(i).pubKey === pubKey) {
|
2022-05-19 09:02:36 +00:00
|
|
|
index = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return contactsModel.get(index).ringSpecModel;
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
compressedKeyGetter: function(pubKey) {
|
|
|
|
//for simulation purposes only, in real app
|
|
|
|
//this would be Utils.getCompressedPk(pubKey);
|
|
|
|
var possibleCharacters = pubKey.split('');
|
|
|
|
var randomStringLength = 12; // assuming you want random strings of 12 characters
|
|
|
|
var randomString = [];
|
|
|
|
for (var i=0; i<randomStringLength; ++i) {
|
|
|
|
var index = (Math.random() * possibleCharacters.length).toFixed(0);
|
|
|
|
var nextChar = possibleCharacters[index];
|
|
|
|
randomString.push(nextChar);
|
|
|
|
}
|
|
|
|
return randomString.join().toString().replace(/,/g, '');
|
|
|
|
}
|
2022-06-01 07:47:38 +00:00
|
|
|
colorIdForPubkeyGetter: function (pubKey) {
|
|
|
|
//for simulation purposes only, in real app
|
|
|
|
//this would be Utils.colorIdForPubkey(pubKey);
|
|
|
|
return Math.floor(Math.random() * 10);
|
|
|
|
}
|
2022-01-19 22:33:29 +00:00
|
|
|
onTextChanged: {
|
2022-03-24 22:03:36 +00:00
|
|
|
sortModel(root.contactsModel);
|
2022-01-19 22:33:29 +00:00
|
|
|
}
|
2022-05-09 12:04:17 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
textEdit.forceActiveFocus();
|
|
|
|
sortModel(root.contactsModel);
|
|
|
|
}
|
2022-01-19 22:33:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
2022-07-15 16:35:59 +00:00
|
|
|
implicitWidth: 106
|
2022-01-19 22:33:29 +00:00
|
|
|
implicitHeight: 44
|
2022-03-24 22:03:36 +00:00
|
|
|
Layout.alignment: Qt.AlignTop
|
2022-01-19 22:33:29 +00:00
|
|
|
enabled: (tagSelector.namesModel.count > 0)
|
|
|
|
text: "Confirm"
|
|
|
|
}
|
2022-07-15 16:35:59 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
implicitHeight: 32
|
|
|
|
implicitWidth: 32
|
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
|
|
|
|
StatusActivityCenterButton {
|
|
|
|
id: notificationButton
|
|
|
|
anchors.right: parent.right
|
|
|
|
unreadNotificationsCount: 3
|
|
|
|
}
|
|
|
|
}
|
2022-01-19 22:33:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: Item {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
StatusBaseText {
|
2022-07-15 16:35:59 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 252
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 252
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.verticalCenterOffset: -(headerRow.height/2)
|
2022-01-19 22:33:29 +00:00
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
2022-07-15 16:35:59 +00:00
|
|
|
visible: contactsModel.count === 0
|
|
|
|
wrapMode: Text.WordWrap
|
2022-01-19 22:33:29 +00:00
|
|
|
color: Theme.palette.baseColor1
|
2022-07-15 16:35:59 +00:00
|
|
|
text: qsTr("You can only send direct messages to your Contacts.\n
|
|
|
|
Send a contact request to the person you would like to chat with, you will be able to chat with them once they have accepted your contact request.")
|
2022-01-19 22:33:29 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
if (visible) {
|
|
|
|
tagSelector.enabled = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|