Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor various popups #16430

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 162 additions & 0 deletions storybook/pages/BlockContactConfirmationDialogPage.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15

import StatusQ 0.1
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Popups 0.1

import shared.popups 1.0
import Models 1.0

import utils 1.0
import shared.status 1.0

SplitView {
id: root

Pane {
SplitView.fillWidth: true
SplitView.fillHeight: true

ColumnLayout {
anchors.fill: parent
spacing: 20

Item {
Layout.preferredHeight: 50
}

Button {
text: "Open Block Contact Confirmation Dialog"
Layout.alignment: Qt.AlignHCenter
onClicked: blockContactDialog.open()
}

Item {
Layout.preferredWidth: blockContactDialog.implicitWidth
Layout.preferredHeight: blockContactDialog.implicitHeight
Layout.alignment: Qt.AlignHCenter

BlockContactConfirmationDialog {
id: blockContactDialog
visible: false
isContact: isContactCheckBox.checked
outgoingVerificationStatus: outgoingVerificationStatusSelector.currentValue
incomingVerificationStatus: incomingVerificationStatusSelector.currentValue
trustStatus: trustStatusSelector.currentValue
onAccepted: {
blockContactDialog.close()
log("Contact blocked: " + nameInput.text)
log("Remove Contact: " + blockContactDialog.removeContact)
log("Remove ID Verification: " + blockContactDialog.removeIDVerification)
}
}
}
}
}

Pane {
SplitView.minimumWidth: 300
SplitView.preferredWidth: 400
SplitView.fillHeight: true

ColumnLayout {
anchors.fill: parent
spacing: 16

Label {
text: "Block Contact Dialog Settings"
font.bold: true
font.pixelSize: 16
}

Label { text: "Name" }
TextField {
id: nameInput
Layout.fillWidth: true
placeholderText: "Enter name"
}

CheckBox {
id: isContactCheckBox
text: "Is Contact"
}

Label { text: "Outgoing Verification Status" }
ComboBox {
id: outgoingVerificationStatusSelector
Layout.fillWidth: true
textRole: "text"
valueRole: "value"
model: [
{ text: "Untrustworthy", value: Constants.verificationStatus.untrustworthy },
{ text: "Trusted", value: Constants.verificationStatus.trusted }
]
}

Label { text: "Incoming Verification Status" }
ComboBox {
id: incomingVerificationStatusSelector
Layout.fillWidth: true
textRole: "text"
valueRole: "value"
model: [
{ text: "Untrustworthy", value: Constants.verificationStatus.untrustworthy },
{ text: "Trusted", value: Constants.verificationStatus.trusted }
]
}

Label { text: "Trust Status" }
ComboBox {
id: trustStatusSelector
Layout.fillWidth: true
textRole: "text"
valueRole: "value"
model: [
{ text: "Untrusted", value: Constants.trustStatus.untrusted },
{ text: "Trusted", value: Constants.trustStatus.trusted }
]
}

Item {
Layout.fillHeight: true
}

ColumnLayout {
Layout.fillWidth: true
spacing: 8

Label {
text: "Logs"
font.bold: true
font.pixelSize: 16
}

ScrollView {
Layout.fillWidth: true
Layout.preferredHeight: 150
clip: true

TextArea {
id: logsTextArea
readOnly: true
wrapMode: TextEdit.Wrap
selectByMouse: true
}
}

Button {
text: "Clear Logs"
onClicked: logsTextArea.clear()
}
}
}
}

function log(message) {
var timestamp = new Date().toLocaleTimeString(Qt.locale(), "HH:mm:ss")
logsTextArea.append(timestamp + ": " + message)
}
}
136 changes: 136 additions & 0 deletions storybook/pages/ContactVerificationRequestPopupPage.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15

import StatusQ 0.1
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Popups 0.1

import shared.popups 1.0
import Models 1.0

import utils 1.0
import shared.status 1.0

SplitView {
id: root

Pane {
SplitView.fillWidth: true
SplitView.fillHeight: true

ColumnLayout {
anchors.fill: parent
spacing: 20

Item {
Layout.preferredHeight: 50
}

Button {
text: "Open Contact Verification Request Popup"
Layout.alignment: Qt.AlignHCenter
onClicked: contactVerificationRequestPopup.open()
}

Item {
Layout.preferredWidth: contactVerificationRequestPopup.implicitWidth
Layout.preferredHeight: contactVerificationRequestPopup.implicitHeight
Layout.alignment: Qt.AlignHCenter

ContactVerificationRequestPopup {
id: contactVerificationRequestPopup
visible: false
senderPublicKey: senderPublicKeyInput.text
challengeText: challengeTextInput.text
messageTimestamp: messageTimestampInput.value
onVerificationRefused: {
log("Verification request declined")
}
onResponseSent: {
log("Response sent: " + response)
}
}
}
}
}

Pane {
SplitView.minimumWidth: 300
SplitView.preferredWidth: 400
SplitView.fillHeight: true

ColumnLayout {
anchors.fill: parent
spacing: 16

Label {
text: "Contact Verification Request Popup Settings"
font.bold: true
font.pixelSize: 16
}

Label { text: "Sender Public Key" }
TextField {
id: senderPublicKeyInput
Layout.fillWidth: true
placeholderText: "Enter sender's public key"
}

Label { text: "Challenge Text" }
TextArea {
id: challengeTextInput
Layout.fillWidth: true
placeholderText: "Enter challenge text"
}

Label { text: "Message Timestamp" }
SpinBox {
id: messageTimestampInput
Layout.fillWidth: true
from: 0
to: 2147483647 // Max 32-bit integer
value: Date.now()
}

Item {
Layout.fillHeight: true
}

ColumnLayout {
Layout.fillWidth: true
spacing: 8

Label {
text: "Logs"
font.bold: true
font.pixelSize: 16
}

ScrollView {
Layout.fillWidth: true
Layout.preferredHeight: 150
clip: true

TextArea {
id: logsTextArea
readOnly: true
wrapMode: TextEdit.Wrap
selectByMouse: true
}
}

Button {
text: "Clear Logs"
onClicked: logsTextArea.clear()
}
}
}
}

function log(message) {
var timestamp = new Date().toLocaleTimeString(Qt.locale(), "HH:mm:ss")
logsTextArea.append(timestamp + ": " + message)
}
}
Loading