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

118 lines
3.5 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 StatusQ.Controls 0.1
import "../../../../shared/controls"
import "../../../../shared/popups"
import "../../../../shared/panels"
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 === "") {
2021-02-18 16:36:05 +00:00
//% "You need to enter a channel name"
channelNameValidationError = qsTrId("you-need-to-enter-a-channel-name")
} else if (!Utils.isValidChannelName(channelName.text)) {
2021-02-18 16:36:05 +00:00
//% "The channel name can only contain lowercase letters, numbers and dashes"
channelNameValidationError = qsTrId("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
//% "Join public chat"
title: qsTrId("new-public-group-chat")
2020-05-29 18:38:11 +00:00
onOpened: {
channelName.text = "";
channelName.forceActiveFocus(Qt.MouseFocusReason)
}
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
//% "A public chat is where you get to hang out with others, make friends and talk about subjects of your interest."
text: qsTrId("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
//% "chat-name"
placeholderText: qsTrId("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()
//% "Start chat"
text: qsTrId("start-chat")
}
}