Skip to content

Commit

Permalink
feat(AirdropRecipientsSelector): status label with current and max nu…
Browse files Browse the repository at this point in the history
…mber of recipients added
  • Loading branch information
micieslak committed May 8, 2023
1 parent aa039a8 commit da07230
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
32 changes: 30 additions & 2 deletions storybook/pages/AirdropRecipientsSelectorPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ SplitView {
return true
}

function getCompressedPk(publicKey) {
return "compressed_" + publicKey
}

function getColorId(publicKey) {
return Math.floor(Math.random() * 10)
}
Expand Down Expand Up @@ -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)
Expand All @@ -128,8 +138,6 @@ SplitView {

LogsAndControlsPanel {
SplitView.minimumHeight: 100
SplitView.preferredHeight: 180

logsView.logText: logs.logText

ColumnLayout {
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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)
Expand All @@ -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

Expand Down

0 comments on commit da07230

Please sign in to comment.