Skip to content

Initial Template for Request Payment page #435

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

Merged
merged 6 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ QML_RES_QML = \
qml/pages/wallet/CreatePassword.qml \
qml/pages/wallet/CreateWalletWizard.qml \
qml/pages/wallet/DesktopWallets.qml \
qml/pages/wallet/RequestPayment.qml \
qml/pages/wallet/WalletBadge.qml \
qml/pages/wallet/WalletSelect.qml

Expand Down
1 change: 1 addition & 0 deletions src/qml/bitcoin_qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<file>pages/wallet/CreatePassword.qml</file>
<file>pages/wallet/CreateWalletWizard.qml</file>
<file>pages/wallet/DesktopWallets.qml</file>
<file>pages/wallet/RequestPayment.qml</file>
<file>pages/wallet/WalletBadge.qml</file>
<file>pages/wallet/WalletSelect.qml</file>
</qresource>
Expand Down
1 change: 1 addition & 0 deletions src/qml/controls/LabeledTextInput.qml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Item {
color: Theme.color.neutral9
placeholderTextColor: Theme.color.neutral7
background: Item {}
selectByMouse: true
onTextEdited: root.textEdited()
}

Expand Down
3 changes: 1 addition & 2 deletions src/qml/pages/wallet/DesktopWallets.qml
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,8 @@ Page {
id: sendTab
CoreText { text: "Send" }
}
Item {
RequestPayment {
id: receiveTab
CoreText { text: "Receive" }
}
Item {
id: blockClockTab
Expand Down
239 changes: 239 additions & 0 deletions src/qml/pages/wallet/RequestPayment.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
// Copyright (c) 2024 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import org.bitcoincore.qt 1.0

import "../../controls"
import "../../components"
import "../settings"

Page {
id: root
background: null

property int requestCounter: 0

ScrollView {
clip: true
width: parent.width
height: parent.height
contentWidth: width

CoreText {
id: title
anchors.left: contentRow.left
anchors.top: parent.top
anchors.topMargin: 20
text: qsTr("Request a payment")
font.pixelSize: 21
bold: true
}

RowLayout {
id: contentRow
anchors.top: title.bottom
anchors.topMargin: 40
anchors.horizontalCenter: parent.horizontalCenter
spacing: 30
ColumnLayout {
id: columnLayout
Layout.minimumWidth: 450
Layout.maximumWidth: 470

spacing: 5

Item {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Maybe amount input deserves it's own control?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it will be. I haven't committed to doing that just yet as I don't have a clear idea of exactly how the BitcoinAmounts and the Bitcoin Address inputs will be handled. I think the PR to do the input formatting of the amounts should take care of having this component extracted out with clear signals/properties.

BitcoinAmount {
id: bitcoinAmount
}

height: amountInput.height
Layout.fillWidth: true
CoreText {
id: amountLabel
width: 110
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
horizontalAlignment: Text.AlignLeft
color: Theme.color.neutral9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should be neutral7 like the other labels

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll double check this. There has been some flip flopping on the design side but it should be decided now

text: "Amount"
font.pixelSize: 18
}

TextField {
id: amountInput
anchors.left: amountLabel.right
anchors.verticalCenter: parent.verticalCenter
leftPadding: 0
font.family: "Inter"
font.styleName: "Regular"
font.pixelSize: 18
color: Theme.color.neutral9
placeholderTextColor: Theme.color.neutral7
background: Item {}
placeholderText: "0.00000000"
selectByMouse: true
onTextEdited: {
amountInput.text = bitcoinAmount.sanitize(amountInput.text)
}
}
Item {
width: unitLabel.width + flipIcon.width
height: Math.max(unitLabel.height, flipIcon.height)
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
MouseArea {
anchors.fill: parent
onClicked: {
if (bitcoinAmount.unit == BitcoinAmount.BTC) {
amountInput.text = bitcoinAmount.convert(amountInput.text, BitcoinAmount.BTC)
bitcoinAmount.unit = BitcoinAmount.SAT
} else {
amountInput.text = bitcoinAmount.convert(amountInput.text, BitcoinAmount.SAT)
bitcoinAmount.unit = BitcoinAmount.BTC
}
}
}
CoreText {
id: unitLabel
anchors.right: flipIcon.left
anchors.verticalCenter: parent.verticalCenter
text: bitcoinAmount.unitLabel
font.pixelSize: 18
color: Theme.color.neutral7
}
Icon {
id: flipIcon
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
source: "image://images/flip-vertical"
color: Theme.color.neutral8
size: 30
}
}
}

Separator {
Layout.fillWidth: true
}

LabeledTextInput {
id: label
Layout.fillWidth: true
labelText: qsTr("Label")
placeholderText: qsTr("Enter label...")
}

Separator {
Layout.fillWidth: true
}

LabeledTextInput {
id: message
Layout.fillWidth: true
labelText: qsTr("Message")
placeholderText: qsTr("Enter message...")
}

Separator {
Layout.fillWidth: true
}

Item {
Layout.fillWidth: true
Layout.minimumHeight: addressLabel.height + copyLabel.height
Layout.topMargin: 10
height: addressLabel.height + copyLabel.height
CoreText {
id: addressLabel
anchors.left: parent.left
anchors.top: parent.top
horizontalAlignment: Text.AlignLeft
width: 110
text: qsTr("Address")
font.pixelSize: 18
color: Theme.color.neutral9
}
CoreText {
id: copyLabel
anchors.left: parent.left
anchors.top: addressLabel.bottom
horizontalAlignment: Text.AlignLeft
width: 110
text: qsTr("copy")
font.pixelSize: 18
color: Theme.color.neutral7
}

Rectangle {
anchors.left: addressLabel.right
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom
color: Theme.color.neutral2
radius: 5
CoreText {
id: address
anchors.fill: parent
anchors.leftMargin: 5
horizontalAlignment: Text.AlignLeft
font.pixelSize: 18
color: Theme.color.neutral9
wrap: true
}
}
}

ContinueButton {
id: continueButton
Layout.fillWidth: true
Layout.topMargin: 30
text: qsTr("Create bitcoin address")
onClicked: {
if (!clearRequest.visible) {
requestCounter = requestCounter + 1
clearRequest.visible = true
title.text = qsTr("Payment request #" + requestCounter)
address.text = "bc1q f5xe y2tf 89k9 zy6k gnru wszy 5fsa truy 9te1 bu"
Copy link
Contributor

@davidgumberg davidgumberg Mar 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not likely to happen, but it seems to me like a bad idea to put a placeholder address here when someone curious might build this branch and try to use it with mainnet funds, maybe insert an invalid character or something else to indicate this is a placeholder?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @GBKS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ill remove the address from the code asap

continueButton.text = qsTr("Copy payment request")
}
}
}

ContinueButton {
id: clearRequest
Layout.fillWidth: true
Layout.topMargin: 10
visible: false
borderColor: Theme.color.neutral6
borderHoverColor: Theme.color.orangeLight1
borderPressedColor: Theme.color.orangeLight2
backgroundColor: "transparent"
backgroundHoverColor: "transparent"
backgroundPressedColor: "transparent"
text: qsTr("Clear")
onClicked: {
clearRequest.visible = false
title.text = qsTr("Request a payment")
address.text = ""
continueButton.text = qsTr("Create bitcoin address")
}
}
}

Rectangle {
id: qrPlaceholder
Layout.alignment: Qt.AlignTop
Layout.minimumWidth: 150
Layout.maximumWidth: 150
color: Theme.color.neutral2
width: 150
height: 150
}
}
}
}
Loading