status-desktop/ui/app/AppLayouts/Chat/popups/PublicChatPopup.qml

112 lines
3.1 KiB
QML
Raw Normal View History

2020-06-17 19:18:31 +00:00
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import utils 1.0
import shared.controls 1.0
import StatusQ.Controls 0.1
import shared.panels 1.0
import shared.popups 1.0
import "../helpers/channelList.js" as ChannelJSON
import "../panels"
// TODO: replace with StatusModal
2020-05-29 16:27:50 +00:00
ModalPopup {
property string channelNameValidationError: ""
signal joinPublicChat(string name)
signal suggestedMessageClicked(string channel)
function validate() {
if (channelName.text === "") {
channelNameValidationError = qsTr("You need to enter a channel name")
} else if (!Utils.isValidChannelName(channelName.text)) {
channelNameValidationError = qsTr("The channel name can only contain lowercase letters, numbers and dashes")
} else {
channelNameValidationError = ""
}
return channelNameValidationError === ""
}
function doJoin() {
if (!validate()) {
return
}
popup.joinPublicChat(channelName.text);
popup.close();
}
id: popup
title: qsTr("Join public chat")
2020-05-29 18:38:11 +00:00
onOpened: {
channelName.text = "";
channelName.forceActiveFocus(Qt.MouseFocusReason)
}
2022-02-09 09:43:23 +00:00
2020-05-29 16:27:50 +00:00
Row {
id: description
Layout.fillHeight: false
Layout.fillWidth: true
width: parent.width
StyledText {
2020-06-04 14:53:10 +00:00
width: parent.width
2020-05-29 16:27:50 +00:00
font.pixelSize: 15
text: qsTr("A public chat is where you get to hang out with others, make friends and talk about subjects of your interest.")
2020-05-29 16:27:50 +00:00
wrapMode: Text.WordWrap
verticalAlignment: Text.AlignTop
}
2020-05-29 16:27:50 +00:00
}
Input {
id: channelName
2020-05-29 16:27:50 +00:00
anchors.top: description.bottom
anchors.topMargin: Style.current.padding
placeholderText: qsTr("chat-name")
Keys.onEnterPressed: doJoin()
Keys.onReturnPressed: doJoin()
icon: Style.svg("hash")
validationError: channelNameValidationError
2020-05-29 16:27:50 +00:00
}
ScrollView {
id: sview
2020-09-23 16:49:08 +00:00
clip: true
anchors.top: channelName.bottom
anchors.topMargin: Style.current.smallPadding
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
ScrollBar.vertical.policy: ScrollBar.AlwaysOn
Layout.fillHeight: true
Layout.fillWidth: true
2020-09-23 16:49:08 +00:00
contentHeight: {
var totalHeight = 0
for (let i = 0; i < sectionRepeater.count; i++) {
totalHeight += sectionRepeater.itemAt(i).height + Style.current.padding
}
return totalHeight + Style.current.padding
}
SuggestedChannelsPanel {
2020-09-23 19:36:36 +00:00
id: sectionRepeater
width: parent.width
onSuggestedMessageClicked: {
popup.suggestedMessageClicked(channel);
}
}
2020-05-29 16:27:50 +00:00
}
footer: StatusButton {
2020-05-29 16:27:50 +00:00
anchors.bottom: parent.bottom
anchors.right: parent.right
onClicked : doJoin()
text: qsTr("Start chat")
}
}