2022-12-06 07:55:50 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
|
|
|
|
import Storybook 1.0
|
|
|
|
import Models 1.0
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
import shared.status 1.0
|
2024-09-04 14:27:24 +00:00
|
|
|
import shared.stores 1.0 as SharedStores
|
2022-12-06 07:55:50 +00:00
|
|
|
|
2024-09-06 13:11:47 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as SQUtils
|
2023-11-07 11:32:21 +00:00
|
|
|
|
2024-12-04 16:19:27 +00:00
|
|
|
import AppLayouts.Wallet.stores 1.0 as WalletStores
|
2024-05-22 08:13:39 +00:00
|
|
|
import AppLayouts.Chat.stores 1.0 as ChatStores
|
|
|
|
|
2022-12-06 07:55:50 +00:00
|
|
|
SplitView {
|
|
|
|
id: root
|
|
|
|
|
2022-12-15 10:29:10 +00:00
|
|
|
Logs { id: logs }
|
|
|
|
|
2022-12-06 07:55:50 +00:00
|
|
|
QtObject {
|
|
|
|
id: globalUtilsMock
|
|
|
|
|
|
|
|
property bool ready: false
|
|
|
|
property var globalUtils: QtObject {
|
|
|
|
function isCompressedPubKey(publicKey) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Component.onCompleted: {
|
|
|
|
Utils.globalUtilsInst = globalUtilsMock.globalUtils
|
|
|
|
globalUtilsMock.ready = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UsersModel {
|
|
|
|
id: fakeUsersModel
|
|
|
|
}
|
|
|
|
|
2023-10-25 15:20:02 +00:00
|
|
|
LinkPreviewModel {
|
2023-09-26 14:16:53 +00:00
|
|
|
id: fakeLinksModel
|
|
|
|
}
|
|
|
|
|
2022-12-06 07:55:50 +00:00
|
|
|
SplitView {
|
|
|
|
orientation: Qt.Vertical
|
|
|
|
SplitView.fillWidth: true
|
|
|
|
//dummy item to position chatInput at the bottom
|
|
|
|
Item {
|
|
|
|
SplitView.fillHeight: true
|
|
|
|
SplitView.fillWidth: true
|
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
2023-09-26 14:16:53 +00:00
|
|
|
id: chatInputLoader
|
2024-09-04 14:27:24 +00:00
|
|
|
active: globalUtilsMock.ready
|
2022-12-06 07:55:50 +00:00
|
|
|
sourceComponent: StatusChatInput {
|
|
|
|
id: chatInput
|
2023-10-09 08:45:16 +00:00
|
|
|
property string unformattedText: chatInput.textInput.getText(0, chatInput.textInput.length)
|
2023-09-26 14:20:59 +00:00
|
|
|
|
2024-09-06 13:11:47 +00:00
|
|
|
readonly property SQUtils.ModelChangeTracker urlsModelChangeTracker: SQUtils.ModelChangeTracker {
|
2023-11-07 11:32:21 +00:00
|
|
|
model: fakeLinksModel
|
|
|
|
}
|
|
|
|
|
2023-09-26 14:20:59 +00:00
|
|
|
onUnformattedTextChanged: {
|
|
|
|
textEditConnection.enabled = false
|
2023-10-09 08:45:16 +00:00
|
|
|
d.loadLinkPreviews(unformattedText)
|
2023-09-26 14:20:59 +00:00
|
|
|
textEditConnection.enabled = true
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
id: textEditConnection
|
|
|
|
target: chatInput.textInput
|
|
|
|
function onTextChanged() {
|
|
|
|
if(unformattedText !== chatInput.textInput.getText(0, chatInput.textInput.length))
|
|
|
|
unformattedText = chatInput.textInput.getText(0, chatInput.textInput.length)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-14 15:09:46 +00:00
|
|
|
enabled: enabledCheckBox.checked
|
2023-09-26 14:16:53 +00:00
|
|
|
linkPreviewModel: fakeLinksModel
|
2023-11-07 11:32:21 +00:00
|
|
|
urlsList: {
|
|
|
|
urlsModelChangeTracker.revision
|
2024-09-06 13:11:47 +00:00
|
|
|
return SQUtils.ModelUtils.modelToFlatArray(fakeLinksModel, "url")
|
2023-11-07 11:32:21 +00:00
|
|
|
}
|
2023-10-09 08:45:16 +00:00
|
|
|
askToEnableLinkPreview: askToEnableLinkPreviewSwitch.checked
|
|
|
|
onAskToEnableLinkPreviewChanged: {
|
|
|
|
if(askToEnableLinkPreview) {
|
|
|
|
fakeLinksModel.clear()
|
|
|
|
d.loadLinkPreviews(unformattedText)
|
|
|
|
}
|
|
|
|
}
|
2024-09-06 13:11:47 +00:00
|
|
|
usersModel: fakeUsersModel
|
2024-09-04 14:27:24 +00:00
|
|
|
|
|
|
|
sharedStore: SharedStores.RootStore {
|
2024-09-24 12:14:21 +00:00
|
|
|
property bool gifUnfurlingEnabled: true
|
2024-09-04 14:27:24 +00:00
|
|
|
|
|
|
|
property var gifStore: SharedStores.GifStore {
|
|
|
|
property var gifColumnA: ListModel {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-12-04 16:19:27 +00:00
|
|
|
paymentRequestFeatureEnabled: true
|
|
|
|
areTestNetworksEnabled: testnetEnabledCheckBox.checked
|
|
|
|
|
2022-12-15 10:29:10 +00:00
|
|
|
onSendMessage: {
|
|
|
|
logs.logEvent("StatusChatInput::sendMessage", ["MessageWithPk"], [chatInput.getTextWithPublicKeys()])
|
2024-10-08 11:20:50 +00:00
|
|
|
logs.logEvent("StatusChatInput::sendMessage", ["PlainText"], [SQUtils.StringUtils.plainText(chatInput.getTextWithPublicKeys())])
|
2022-12-15 10:29:10 +00:00
|
|
|
logs.logEvent("StatusChatInput::sendMessage", ["RawText"], [chatInput.textInput.text])
|
|
|
|
}
|
2023-10-09 08:45:16 +00:00
|
|
|
onEnableLinkPreviewForThisMessage: {
|
|
|
|
linkPreviewSwitch.checked = true
|
|
|
|
askToEnableLinkPreviewSwitch.checked = false
|
|
|
|
}
|
|
|
|
onEnableLinkPreview: {
|
|
|
|
linkPreviewSwitch.checked = true
|
|
|
|
askToEnableLinkPreviewSwitch.checked = false
|
|
|
|
}
|
|
|
|
onDisableLinkPreview: {
|
|
|
|
linkPreviewSwitch.checked = false
|
|
|
|
askToEnableLinkPreviewSwitch.checked = false
|
|
|
|
}
|
|
|
|
onDismissLinkPreviewSettings: {
|
|
|
|
askToEnableLinkPreviewSwitch.checked = false
|
|
|
|
linkPreviewSwitch.checked = false
|
|
|
|
}
|
|
|
|
onDismissLinkPreview: (index) => {
|
|
|
|
fakeLinksModel.setProperty(index, "unfurled", false)
|
|
|
|
fakeLinksModel.setProperty(index, "immutable", true)
|
|
|
|
}
|
2022-12-06 07:55:50 +00:00
|
|
|
}
|
|
|
|
}
|
2022-12-15 10:29:10 +00:00
|
|
|
|
|
|
|
LogsAndControlsPanel {
|
|
|
|
id: logsAndControlsPanel
|
|
|
|
|
|
|
|
SplitView.minimumHeight: 100
|
|
|
|
SplitView.preferredHeight: 200
|
|
|
|
|
|
|
|
logsView.logText: logs.logText
|
|
|
|
}
|
2023-10-09 08:45:16 +00:00
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
2024-12-04 16:19:27 +00:00
|
|
|
|
|
|
|
readonly property var walletAssetsStore: WalletStores.WalletAssetsStore {
|
|
|
|
id: thisWalletAssetStore
|
|
|
|
walletTokensStore: WalletStores.TokensStore {
|
|
|
|
plainTokensBySymbolModel: TokensBySymbolModel {}
|
|
|
|
}
|
|
|
|
assetsWithFilteredBalances: thisWalletAssetStore.groupedAccountsAssetsModel
|
|
|
|
}
|
|
|
|
|
2023-10-09 08:45:16 +00:00
|
|
|
property bool linkPreviewsEnabled: linkPreviewSwitch.checked && !askToEnableLinkPreviewSwitch.checked
|
|
|
|
onLinkPreviewsEnabledChanged: {
|
|
|
|
loadLinkPreviews(chatInputLoader.item ? chatInputLoader.item.unformattedText : "")
|
|
|
|
}
|
|
|
|
function loadLinkPreviews(text) {
|
2023-11-07 11:32:21 +00:00
|
|
|
var words = text.split(/\s+/)
|
2023-10-09 08:45:16 +00:00
|
|
|
|
|
|
|
fakeLinksModel.clear()
|
|
|
|
words.forEach(function(word){
|
|
|
|
if(Utils.isURL(word)) {
|
2023-10-25 15:20:02 +00:00
|
|
|
const linkPreview = fakeLinksModel.getStandardLinkPreview()
|
|
|
|
linkPreview.url = encodeURI(word)
|
|
|
|
linkPreview.unfurled = Math.random() > 0.2
|
|
|
|
linkPreview.immutable = !d.linkPreviewsEnabled
|
|
|
|
linkPreview.empty = Math.random() > 0.7
|
|
|
|
fakeLinksModel.append(linkPreview)
|
2023-10-09 08:45:16 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2022-12-06 07:55:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Pane {
|
2023-07-31 12:21:14 +00:00
|
|
|
SplitView.minimumWidth: 300
|
|
|
|
SplitView.preferredWidth: 300
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
CheckBox {
|
|
|
|
id: enabledCheckBox
|
|
|
|
text: "enabled"
|
|
|
|
checked: true
|
|
|
|
}
|
2023-09-26 14:16:53 +00:00
|
|
|
|
2024-12-04 16:19:27 +00:00
|
|
|
CheckBox {
|
|
|
|
id: testnetEnabledCheckBox
|
|
|
|
text: "testnet enabled"
|
|
|
|
checked: false
|
|
|
|
}
|
|
|
|
|
2023-09-26 14:16:53 +00:00
|
|
|
TabBar {
|
|
|
|
id: bar
|
|
|
|
TabButton {
|
|
|
|
text: "Attachments"
|
|
|
|
}
|
|
|
|
TabButton {
|
|
|
|
text: "Users"
|
|
|
|
}
|
2023-07-31 12:21:14 +00:00
|
|
|
}
|
|
|
|
|
2023-09-26 14:16:53 +00:00
|
|
|
StackLayout {
|
|
|
|
currentIndex: bar.currentIndex
|
|
|
|
ColumnLayout {
|
|
|
|
id: attachmentsTab
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Label {
|
|
|
|
text: "Images"
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
ComboBox {
|
|
|
|
id: imageNb
|
|
|
|
editable: true
|
|
|
|
model: 20
|
|
|
|
validator: IntValidator {bottom: 0; top: 20;}
|
|
|
|
focus: true
|
|
|
|
onCurrentIndexChanged: {
|
|
|
|
if(!chatInputLoader.item)
|
|
|
|
return
|
|
|
|
const urls = []
|
|
|
|
for (let i = 0; i < imageNb.currentIndex ; i++) {
|
|
|
|
urls.push("https://picsum.photos/200/300?random=" + i)
|
|
|
|
}
|
|
|
|
console.log(urls.length)
|
|
|
|
chatInputLoader.item.fileUrlsAndSources = urls
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Label {
|
|
|
|
text: "Links"
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2023-10-09 08:45:16 +00:00
|
|
|
|
|
|
|
Switch {
|
|
|
|
id: linkPreviewSwitch
|
|
|
|
text: "Link Preview enabled"
|
|
|
|
}
|
|
|
|
|
|
|
|
Switch {
|
|
|
|
id: askToEnableLinkPreviewSwitch
|
|
|
|
text: "Ask to enable Link Preview"
|
|
|
|
checked: true
|
|
|
|
}
|
|
|
|
|
2023-09-26 14:16:53 +00:00
|
|
|
ComboBox {
|
|
|
|
id: linksNb
|
|
|
|
editable: true
|
|
|
|
model: 20
|
|
|
|
validator: IntValidator {bottom: 0; top: 20;}
|
|
|
|
onCurrentIndexChanged: {
|
|
|
|
if(!chatInputLoader.item)
|
|
|
|
return
|
2023-09-26 14:20:59 +00:00
|
|
|
let urls = ""
|
2023-09-26 14:16:53 +00:00
|
|
|
for (let i = 0; i < linksNb.currentIndex ; i++) {
|
2023-09-26 14:20:59 +00:00
|
|
|
urls += "https://www.youtube.com/watch?v=9bZkp7q19f0" + Math.floor(Math.random() * 100) + " "
|
2023-09-26 14:16:53 +00:00
|
|
|
}
|
2023-09-26 14:20:59 +00:00
|
|
|
|
|
|
|
chatInputLoader.item.textInput.text = urls
|
2023-09-26 14:16:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
UsersModelEditor {
|
|
|
|
id: modelEditor
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
model: fakeUsersModel
|
|
|
|
|
|
|
|
onRemoveClicked: fakeUsersModel.remove(index, 1)
|
|
|
|
onRemoveAllClicked: fakeUsersModel.clear()
|
|
|
|
onAddClicked: fakeUsersModel.append(modelEditor.getNewUser(fakeUsersModel.count))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Label {
|
|
|
|
text: "Attachments"
|
|
|
|
Layout.fillWidth: true
|
2023-07-31 12:21:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-12-06 07:55:50 +00:00
|
|
|
}
|
2023-07-31 12:21:14 +00:00
|
|
|
|
|
|
|
// category: Components
|
2023-09-26 14:20:59 +00:00
|
|
|
|
2023-10-09 08:45:16 +00:00
|
|
|
// https://www.figma.com/file/Mr3rqxxgKJ2zMQ06UAKiWL/💬-Chat⎜Desktop?type=design&node-id=23155-66084&mode=design&t=VWBVK4DOUxr1BmTp-0
|