feat(AirdropRecipientsSelector): status label with current and max number of recipients added

This commit is contained in:
Michał Cieślak 2023-04-25 22:19:33 +02:00 committed by Michał
parent aa039a859e
commit da07230fa6
2 changed files with 58 additions and 2 deletions

View File

@ -23,6 +23,10 @@ SplitView {
return true
}
function getCompressedPk(publicKey) {
return "compressed_" + publicKey
}
function getColorId(publicKey) {
return Math.floor(Math.random() * 10)
}
@ -106,6 +110,12 @@ SplitView {
showAddressesInputWhenEmpty:
showAddressesInputWhenEmptyCheckBox.checked
infiniteExpectedNumberOfRecipients:
infiniteExpectedNumberOfRecipientsCheckBox.checked
expectedNumberOfRecipients:
expectedNumberOfRecipientsSpinBox.value
onAddAddressesRequested: timer.start()
onRemoveAddressRequested: addresses.remove(index)
onRemoveMemberRequested: members.remove(index)
@ -128,8 +138,6 @@ SplitView {
LogsAndControlsPanel {
SplitView.minimumHeight: 100
SplitView.preferredHeight: 180
logsView.logText: logs.logText
ColumnLayout {
@ -153,6 +161,26 @@ SplitView {
text: "Show addresses input when empty"
}
CheckBox {
id: infiniteExpectedNumberOfRecipientsCheckBox
text: "Infinite number of expected recipients"
}
}
RowLayout {
Label {
text: "Expected number of recipients:"
}
SpinBox {
id: expectedNumberOfRecipientsSpinBox
value: 2
from: 1
to: 100
}
}
Button {

View File

@ -1,6 +1,8 @@
import QtQuick 2.15
import StatusQ.Core 0.1
import StatusQ.Components 0.1
import StatusQ.Core.Theme 0.1
import utils 1.0
@ -15,6 +17,14 @@ StatusFlowSelector {
property alias addressesInputText: addressesSelectorPanel.text
property bool showAddressesInputWhenEmpty: false
property int expectedNumberOfRecipients: 0
property bool infiniteExpectedNumberOfRecipients: false
readonly property int count: addressesSelectorPanel.count +
membersSelectorPanel.count
readonly property bool valid:
addressesSelectorPanel.invalidAddressesCount === 0
signal addAddressesRequested(string addresses)
signal removeAddressRequested(int index)
@ -41,6 +51,24 @@ StatusFlowSelector {
membersSelectorPanel.positionListAtEnd()
}
StatusBaseText {
parent: label
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
readonly property bool valid: root.infiniteExpectedNumberOfRecipients ||
root.count <= root.expectedNumberOfRecipients
text: root.count + " / " + (root.infiniteExpectedNumberOfRecipients
? qsTr("∞ recipients", "infinite number of recipients")
: qsTr("%n recipient(s)", "", root.expectedNumberOfRecipients))
font.pixelSize: Theme.tertiaryTextFontSize + 1
color: valid ? Theme.palette.baseColor1 : Theme.palette.dangerColor1
elide: Text.ElideRight
}
AddressesSelectorPanel {
id: addressesSelectorPanel