feat(CommunityNewPermissionView): red highlight for tokens with inssuficient balance and warning msg panel

This commit is contained in:
Michał Cieślak 2023-04-28 00:13:59 +02:00 committed by Michał
parent 45aaa5a3de
commit 1f3ae975fc
7 changed files with 36 additions and 10 deletions

View File

@ -12,19 +12,22 @@ ColumnLayout {
tokenText: "2 MCT", tokenText: "2 MCT",
networkText: "Ethereum", networkText: "Ethereum",
tokenImage: Style.png("tokens/SNT"), tokenImage: Style.png("tokens/SNT"),
networkImage: Style.svg("network/Network=Ethereum") networkImage: Style.svg("network/Network=Ethereum"),
valid: true
}, },
{ {
tokenText: "64 DAI", tokenText: "64 DAI",
networkText: "Optimism", networkText: "Optimism",
tokenImage: Style.png("tokens/DAI"), tokenImage: Style.png("tokens/DAI"),
networkImage: Style.svg("network/Network=Optimism") networkImage: Style.svg("network/Network=Optimism"),
valid: false
}, },
{ {
tokenText: "0.125 ETH", tokenText: "0.125 ETH",
networkText: "Arbitrum", networkText: "Arbitrum",
tokenImage: Style.png("tokens/ETH"), tokenImage: Style.png("tokens/ETH"),
networkImage: Style.svg("network/Network=Arbitrum") networkImage: Style.svg("network/Network=Arbitrum"),
valid: true
} }
] ]

View File

@ -20,17 +20,20 @@ SplitView {
{ {
name: "Optimism", name: "Optimism",
icon: Style.svg(ModelsData.networks.optimism), icon: Style.svg(ModelsData.networks.optimism),
amount: "300" amount: 300,
infiniteAmount: false
}, },
{ {
name: "Arbitrum", name: "Arbitrum",
icon: Style.svg(ModelsData.networks.arbitrum), icon: Style.svg(ModelsData.networks.arbitrum),
amount: "400" amount: 400,
infiniteAmount: false
}, },
{ {
name: "Hermez", name: "Hermez",
icon: Style.svg(ModelsData.networks.hermez), icon: Style.svg(ModelsData.networks.hermez),
amount: "500" amount: 500,
infiniteAmount: true
} }
] ]

View File

@ -45,7 +45,9 @@ StatusFlowSelector {
component Text: StatusBaseText { component Text: StatusBaseText {
Layout.fillWidth: true Layout.fillWidth: true
color: Theme.palette.primaryColor1 font.weight: Font.Medium
color: model.valid ? Theme.palette.primaryColor1
: Theme.palette.dangerColor1
elide: Text.ElideRight elide: Text.ElideRight
} }
@ -54,7 +56,8 @@ StatusFlowSelector {
rightPadding: d.commonMargin * 2 rightPadding: d.commonMargin * 2
background: Rectangle { background: Rectangle {
color: Theme.palette.primaryColor3 color: model.valid ? Theme.palette.primaryColor3
: Theme.palette.dangerColor3
radius: root.placeholderItemHeight / 2 radius: root.placeholderItemHeight / 2
MouseArea { MouseArea {

View File

@ -8,6 +8,6 @@ HidePermissionPanel 1.0 HidePermissionPanel.qml
JoinPermissionsOverlayPanel 1.0 JoinPermissionsOverlayPanel.qml JoinPermissionsOverlayPanel 1.0 JoinPermissionsOverlayPanel.qml
MintTokensFooterPanel 1.0 MintTokensFooterPanel.qml MintTokensFooterPanel 1.0 MintTokensFooterPanel.qml
PermissionConflictWarningPanel 1.0 PermissionConflictWarningPanel.qml PermissionConflictWarningPanel 1.0 PermissionConflictWarningPanel.qml
PermissionWarningPanel 1.0 PermissionWarningPanel.qml
PermissionQualificationPanel 1.0 PermissionQualificationPanel.qml PermissionQualificationPanel 1.0 PermissionQualificationPanel.qml
TokenHoldersPanel 1.0 TokenHoldersPanel.qml TokenHoldersPanel 1.0 TokenHoldersPanel.qml
WarningPanel 1.0 WarningPanel.qml

View File

@ -98,9 +98,15 @@ StatusScrollView {
readonly property real amount: model.amount readonly property real amount: model.amount
readonly property bool infiniteSupply: model.infiniteSupply readonly property bool infiniteSupply: model.infiniteSupply
readonly property bool valid:
infiniteSupply || amount * airdropRecipientsSelector.count <= supply
onSupplyChanged: recipientsCountInstantiator.findRecipientsCount() onSupplyChanged: recipientsCountInstantiator.findRecipientsCount()
onAmountChanged: recipientsCountInstantiator.findRecipientsCount() onAmountChanged: recipientsCountInstantiator.findRecipientsCount()
onInfiniteSupplyChanged: recipientsCountInstantiator.findRecipientsCount() onInfiniteSupplyChanged: recipientsCountInstantiator.findRecipientsCount()
onValidChanged: model.valid = valid
Component.onCompleted: model.valid = valid
} }
onCountChanged: findRecipientsCount() onCountChanged: findRecipientsCount()
@ -164,6 +170,7 @@ StatusScrollView {
onAddCollectible: { onAddCollectible: {
const entry = d.prepareEntry(key, amount) const entry = d.prepareEntry(key, amount)
entry.valid = true
selectedHoldingsModel.append(entry) selectedHoldingsModel.append(entry)
dropdown.close() dropdown.close()
@ -350,6 +357,16 @@ StatusScrollView {
} }
} }
WarningPanel {
Layout.fillWidth: true
Layout.topMargin: Style.current.padding
text: qsTr("Not enough tokens to send to all recipients. Reduce the number of recipients or change the number of tokens sent to each recipient.")
visible: !recipientsCountInstantiator.infinity &&
recipientsCountInstantiator.maximumRecipientsCount < airdropRecipientsSelector.count
}
StatusButton { StatusButton {
Layout.preferredHeight: 44 Layout.preferredHeight: 44
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter

View File

@ -581,7 +581,7 @@ StatusScrollView {
onToggled: d.dirtyValues.isPrivate = checked onToggled: d.dirtyValues.isPrivate = checked
} }
PermissionWarningPanel { WarningPanel {
id: duplicationPanel id: duplicationPanel
Layout.fillWidth: true Layout.fillWidth: true