2023-07-17 10:49:06 +02:00
import QtQuick
import QtQuick . Layouts
import QtQuick . Controls
import QtQuick . Controls . Material
2022-09-28 18:05:45 +02:00
import org . electrum 1.0
import "controls"
ElDialog {
id: dialog
title: qsTr ( 'LNURL Payment request' )
2022-09-30 14:40:35 +02:00
iconSource: '../../../icons/link.png'
2022-09-28 18:05:45 +02:00
property InvoiceParser invoiceParser
2022-11-11 15:13:39 +01:00
padding: 0
2022-09-30 14:40:35 +02:00
2023-05-12 15:49:42 +02:00
property bool commentValid: comment . text . length <= invoiceParser . lnurlData [ 'comment_allowed' ]
property bool amountValid: amountBtc . textAsSats . satsInt >= parseInt ( invoiceParser . lnurlData [ 'min_sendable_sat' ] )
&& amountBtc . textAsSats . satsInt <= parseInt ( invoiceParser . lnurlData [ 'max_sendable_sat' ] )
property bool valid: commentValid && amountValid
2022-11-11 15:13:39 +01:00
ColumnLayout {
2022-09-30 14:40:35 +02:00
width: parent . width
2023-05-12 15:31:06 +02:00
2022-11-11 15:13:39 +01:00
spacing: 0
GridLayout {
2023-05-12 15:31:06 +02:00
id: rootLayout
2022-11-11 15:13:39 +01:00
columns: 2
2022-09-28 18:05:45 +02:00
2022-09-30 14:40:35 +02:00
Layout.fillWidth: true
2022-11-11 15:13:39 +01:00
Layout.leftMargin: constants . paddingLarge
Layout.rightMargin: constants . paddingLarge
2023-05-12 15:31:06 +02:00
Layout.bottomMargin: constants . paddingLarge
2022-09-28 18:05:45 +02:00
2023-11-15 18:28:44 +01:00
InfoTextArea {
Layout.columnSpan: 2
Layout.fillWidth: true
compact: true
visible: invoiceParser . lnurlData [ 'min_sendable_sat' ] != invoiceParser . lnurlData [ 'max_sendable_sat' ]
text: qsTr ( 'Amount must be between %1 and %2 %3' ) . arg ( Config . formatSats ( invoiceParser . lnurlData [ 'min_sendable_sat' ] ) ) . arg ( Config . formatSats ( invoiceParser . lnurlData [ 'max_sendable_sat' ] ) ) . arg ( Config . baseUnit )
}
2022-11-11 15:13:39 +01:00
Label {
text: qsTr ( 'Provider' )
color: Material . accentColor
}
Label {
2023-05-12 15:31:06 +02:00
Layout.fillWidth: true
2022-11-11 15:13:39 +01:00
text: invoiceParser . lnurlData [ 'domain' ]
}
Label {
text: qsTr ( 'Description' )
color: Material . accentColor
}
Label {
Layout.fillWidth: true
2023-05-12 15:31:06 +02:00
text: invoiceParser . lnurlData [ 'metadata_plaintext' ]
2022-11-11 15:13:39 +01:00
wrapMode: Text . Wrap
}
2023-03-23 12:43:43 +01:00
2022-11-11 15:13:39 +01:00
Label {
2023-03-23 12:43:43 +01:00
text: qsTr ( 'Amount' )
2022-11-11 15:13:39 +01:00
color: Material . accentColor
}
2023-03-23 12:43:43 +01:00
2023-05-12 15:31:06 +02:00
RowLayout {
Layout.fillWidth: true
BtcField {
id: amountBtc
Layout.preferredWidth: rootLayout . width / 3
2023-06-23 16:23:12 +00:00
text: Config . formatSatsForEditing ( invoiceParser . lnurlData [ 'min_sendable_sat' ] )
2023-05-12 15:31:06 +02:00
enabled: invoiceParser . lnurlData [ 'min_sendable_sat' ] != invoiceParser . lnurlData [ 'max_sendable_sat' ]
color: Material . foreground // override gray-out on disabled
fiatfield: amountFiat
onTextAsSatsChanged: {
invoiceParser . amountOverride = textAsSats
}
}
Label {
text: Config . baseUnit
color: Material . accentColor
}
}
Item { visible: Daemon . fx . enabled ; Layout.preferredWidth: 1 ; Layout.preferredHeight: 1 }
RowLayout {
visible: Daemon . fx . enabled
FiatField {
id: amountFiat
Layout.preferredWidth: rootLayout . width / 3
btcfield: amountBtc
}
Label {
text: Daemon . fx . fiatCurrency
color: Material . accentColor
2023-03-23 12:43:43 +01:00
}
}
2023-05-12 15:31:06 +02:00
Label {
Layout.columnSpan: 2
visible: invoiceParser . lnurlData [ 'comment_allowed' ] > 0
text: qsTr ( 'Message' )
color: Material . accentColor
}
2023-11-15 18:28:44 +01:00
ElTextArea {
2022-11-11 15:13:39 +01:00
id: comment
Layout.columnSpan: 2
2023-05-12 15:31:06 +02:00
Layout.fillWidth: true
2023-11-15 18:28:44 +01:00
Layout.minimumHeight: 160
2023-05-12 15:31:06 +02:00
visible: invoiceParser . lnurlData [ 'comment_allowed' ] > 0
2022-11-11 15:13:39 +01:00
wrapMode: TextEdit . Wrap
placeholderText: qsTr ( 'Enter an (optional) message for the receiver' )
color: text . length > invoiceParser . lnurlData [ 'comment_allowed' ] ? constants.colorError : Material . foreground
}
Label {
2023-05-12 15:31:06 +02:00
Layout.columnSpan: 2
Layout.leftMargin: constants . paddingLarge
2022-11-11 15:13:39 +01:00
visible: invoiceParser . lnurlData [ 'comment_allowed' ] > 0
text: qsTr ( '%1 characters remaining' ) . arg ( Math . max ( 0 , ( invoiceParser . lnurlData [ 'comment_allowed' ] - comment . text . length ) ) )
color: constants . mutedForeground
font.pixelSize: constants . fontSizeSmall
}
2022-09-30 14:40:35 +02:00
}
2022-11-11 15:13:39 +01:00
FlatButton {
Layout.topMargin: constants . paddingLarge
Layout.fillWidth: true
2024-10-23 11:45:42 +02:00
text: qsTr ( 'Pay...' )
2022-11-11 15:13:39 +01:00
icon.source: '../../icons/confirmed.png'
enabled: valid
2022-09-28 18:05:45 +02:00
onClicked: {
2023-03-23 12:43:43 +01:00
invoiceParser . lnurlGetInvoice ( comment . text )
2022-09-28 18:05:45 +02:00
dialog . close ( )
}
}
}
2023-03-23 14:00:46 +01:00
2022-09-28 18:05:45 +02:00
}