Skip to content

Commit 9fb3663

Browse files
committed
qml: Introduce RequestPayment page
This page contains the form for the user to fill out to create a payment request.
1 parent b502036 commit 9fb3663

File tree

4 files changed

+154
-2
lines changed

4 files changed

+154
-2
lines changed

src/Makefile.qt.include

+1
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ QML_RES_QML = \
444444
qml/pages/wallet/CreatePassword.qml \
445445
qml/pages/wallet/CreateWalletWizard.qml \
446446
qml/pages/wallet/DesktopWallets.qml \
447+
qml/pages/wallet/RequestPayment.qml \
447448
qml/pages/wallet/WalletBadge.qml \
448449
qml/pages/wallet/WalletSelect.qml
449450

src/qml/bitcoin_qml.qrc

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
<file>pages/wallet/CreatePassword.qml</file>
7979
<file>pages/wallet/CreateWalletWizard.qml</file>
8080
<file>pages/wallet/DesktopWallets.qml</file>
81+
<file>pages/wallet/RequestPayment.qml</file>
8182
<file>pages/wallet/WalletBadge.qml</file>
8283
<file>pages/wallet/WalletSelect.qml</file>
8384
</qresource>

src/qml/pages/wallet/DesktopWallets.qml

+1-2
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,8 @@ Page {
129129
id: sendTab
130130
CoreText { text: "Send" }
131131
}
132-
Item {
132+
RequestPayment {
133133
id: receiveTab
134-
CoreText { text: "Receive" }
135134
}
136135
Item {
137136
id: blockClockTab
+151
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
// Copyright (c) 2024 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
import QtQuick 2.15
6+
import QtQuick.Controls 2.15
7+
import QtQuick.Layouts 1.15
8+
import org.bitcoincore.qt 1.0
9+
10+
import "../../controls"
11+
import "../../components"
12+
import "../settings"
13+
14+
PageStack {
15+
id: stackView
16+
initialItem: pageComponent
17+
18+
Component {
19+
id: pageComponent
20+
Page {
21+
id: root
22+
background: null
23+
24+
header: NavigationBar2 {
25+
id: navbar
26+
centerItem: Item {
27+
id: header
28+
Layout.fillWidth: true
29+
30+
CoreText {
31+
anchors.left: parent.left
32+
text: qsTr("Request a payment")
33+
font.pixelSize: 21
34+
bold: true
35+
}
36+
}
37+
}
38+
39+
ScrollView {
40+
clip: true
41+
width: parent.width
42+
height: parent.height
43+
contentWidth: width
44+
45+
ColumnLayout {
46+
id: columnLayout
47+
anchors.horizontalCenter: parent.horizontalCenter
48+
width: Math.min(parent.width, 450)
49+
spacing: 30
50+
51+
CoreText {
52+
Layout.alignment: Qt.AlignHCenter
53+
text: qsTr("All fields are optional.")
54+
color: Theme.color.neutral7
55+
font.pixelSize: 15
56+
}
57+
58+
LabeledTextInput {
59+
id: label
60+
Layout.fillWidth: true
61+
labelText: qsTr("Label")
62+
placeholderText: qsTr("Enter label...")
63+
}
64+
65+
Item {
66+
BitcoinAmount {
67+
id: bitcoinAmount
68+
}
69+
70+
height: 50
71+
Layout.fillWidth: true
72+
CoreText {
73+
anchors.left: parent.left
74+
anchors.top: parent.top
75+
color: Theme.color.neutral7
76+
text: "Amount"
77+
font.pixelSize: 15
78+
}
79+
80+
TextField {
81+
id: amountInput
82+
anchors.left: parent.left
83+
anchors.bottom: parent.bottom
84+
leftPadding: 0
85+
font.family: "Inter"
86+
font.styleName: "Regular"
87+
font.pixelSize: 18
88+
color: Theme.color.neutral9
89+
placeholderTextColor: Theme.color.neutral7
90+
background: Item {}
91+
placeholderText: "0.00000000"
92+
onTextEdited: {
93+
amountInput.text = bitcoinAmount.sanitize(amountInput.text)
94+
}
95+
}
96+
Item {
97+
width: unitLabel.width + flipIcon.width
98+
height: Math.max(unitLabel.height, flipIcon.height)
99+
anchors.right: parent.right
100+
anchors.verticalCenter: parent.verticalCenter
101+
MouseArea {
102+
anchors.fill: parent
103+
onClicked: {
104+
if (bitcoinAmount.unit == BitcoinAmount.BTC) {
105+
amountInput.text = bitcoinAmount.convert(amountInput.text, BitcoinAmount.BTC)
106+
bitcoinAmount.unit = BitcoinAmount.SAT
107+
} else {
108+
amountInput.text = bitcoinAmount.convert(amountInput.text, BitcoinAmount.SAT)
109+
bitcoinAmount.unit = BitcoinAmount.BTC
110+
}
111+
}
112+
}
113+
CoreText {
114+
id: unitLabel
115+
anchors.right: flipIcon.left
116+
anchors.verticalCenter: parent.verticalCenter
117+
text: bitcoinAmount.unitLabel
118+
font.pixelSize: 18
119+
color: Theme.color.neutral7
120+
}
121+
Icon {
122+
id: flipIcon
123+
anchors.right: parent.right
124+
anchors.verticalCenter: parent.verticalCenter
125+
source: "image://images/flip-vertical"
126+
color: Theme.color.neutral8
127+
size: 30
128+
}
129+
}
130+
}
131+
132+
LabeledTextInput {
133+
id: message
134+
Layout.fillWidth: true
135+
labelText: qsTr("Message")
136+
placeholderText: qsTr("Enter message...")
137+
}
138+
139+
ContinueButton {
140+
id: continueButton
141+
Layout.preferredWidth: Math.min(300, parent.width - 2 * Layout.leftMargin)
142+
Layout.leftMargin: 20
143+
Layout.rightMargin: 20
144+
Layout.alignment: Qt.AlignCenter
145+
text: qsTr("Continue")
146+
}
147+
}
148+
}
149+
}
150+
}
151+
}

0 commit comments

Comments
 (0)