Files
pay/modules/send-sweep/SendPage.qml
T

182 lines
5.8 KiB
QML
Raw Permalink Normal View History

2024-10-01 21:26:01 +02:00
/*
* This file is part of the Flowee project
2025-01-06 21:47:04 +01:00
* Copyright (C) 2024-2025 Tom Zander <tom@flowee.org>
2024-10-01 21:26:01 +02:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick
import QtQuick.Controls as QQC2
import QtQuick.Layouts
import "../Flowee" as Flowee
import "../mobile" as Mobile;
import Flowee.org.pay;
2024-10-02 23:04:38 +02:00
import Flowee.org.pay.SendSweep;
2024-10-01 21:26:01 +02:00
Mobile.Page {
id: root
headerText: qsTr("Sweep coins")
2024-10-01 21:26:01 +02:00
2024-12-22 14:41:46 +01:00
property alias secret: sweeper.privKey
2024-10-02 23:04:38 +02:00
Item { // data
SweepHandler {
id: sweeper
account: pay.portfolio.current
}
2024-10-02 23:04:38 +02:00
}
2024-10-01 21:26:01 +02:00
Column {
width: parent.width
spacing: 6
Flowee.Label {
text: qsTr("Sweeping from address:")
font.bold: true
width: parent.width
horizontalAlignment: Qt.AlignHCenter
wrapMode: Text.Wrap
}
Flowee.Label {
text: sweeper.sweepAddress
width: parent.width
horizontalAlignment: Qt.AlignHCenter
fontSizeMode: Text.HorizontalFit
}
2024-10-09 16:51:37 +02:00
Flowee.Label {
id: coinsLabel
visible: sweeper.numOutputsFound > 0 || sweeper.prepared
2024-10-14 13:25:22 +02:00
text: qsTr("Found %1 coins on address.", "this is a simple number", sweeper.numOutputsFound).arg(sweeper.numOutputsFound)
2024-10-09 16:51:37 +02:00
}
Flowee.Label {
visible: sweeper.numTokensFound > 0
2024-10-14 13:25:22 +02:00
text: qsTr("Ignoring %1 tokens.", "Number of CashTokens", sweeper.numTokensFound).arg(sweeper.numTokensFound)
2024-10-09 16:51:37 +02:00
}
2024-10-06 22:36:10 +02:00
2024-10-14 19:55:53 +02:00
Flowee.Progressbar {
width: parent.width
visible: !sweeper.prepared && sweeper.error === SweepHandler.NoError
progress: sweeper.downloadProgress / 1000
}
2024-10-06 22:36:10 +02:00
Item {
id: busyIndicator
visible: !sweeper.prepared && sweeper.error === SweepHandler.NoError
width: 105
height: visible ? 105 : 1
anchors.horizontalCenter: parent.horizontalCenter
RotationAnimation on rotation {
loops: Animation.Infinite
from: 0
to: 360
duration: 6000
running: busyIndicator.visible
}
Repeater {
model: 6
Item {
width: 105
height: 35
y: 35
Rectangle {
color: mainWindow.floweeGreen
width: 30
height: 30
x: 70
radius: 15
}
rotation: 360 / 6 * index
}
}
}
Rectangle {
color: mainWindow.errorRedBg
width: parent.width
height: sweepErrorLabel.text === "" ? 0 : sweepErrorLabel.height + 20
radius: 6
Flowee.Label {
id: sweepErrorLabel
width: parent.width - 20
wrapMode: Text.Wrap
horizontalAlignment: Qt.AlignHCenter
anchors.centerIn: parent
text: {
var err = sweeper.error;
if (err === SweepHandler.InvalidInput)
return qsTr("Failed to understand QR");
if (err === SweepHandler.NoBackendFound)
return "No indexing servers found";
if (err === SweepHandler.FileError)
return "File not found error"; // not translated as this should never happen.
if (err === SweepHandler.DataInconsistency)
return qsTr("Indexer results invalid. Please try again.");
if (err === SweepHandler.NoError)
return "";
}
}
}
Flowee.BitcoinAmountLabel {
font.pixelSize: coinsLabel.font.pixelSize * 1.2
visible: sweeper.prepared
value: sweeper.sweepTotal
anchors.right: parent.right
}
2024-10-06 00:17:04 +02:00
}
Mobile.AccountSelectorWidget {
id: walletSelector
visible: !portfolio.singleAccountSetup
2024-10-14 19:55:53 +02:00
y: 320
onSelectedAccountChanged: sweeper.account = selectedAccount
}
Flowee.Label {
visible: walletSelector.visible
anchors.bottom: walletSelector.top
text: qsTr("Transfer to:")
}
2024-10-06 00:17:04 +02:00
Mobile.SlideToApprove {
id: slideToApprove
anchors.bottom: parent.bottom
anchors.bottomMargin: 10
width: parent.width
2024-10-09 16:51:37 +02:00
enabled: sweeper.prepared && sweeper.numOutputsFound > 0
2024-10-06 00:17:04 +02:00
visible: !sweeper.account.needsPinToOpen
onActivated: {
2024-10-06 22:36:10 +02:00
root.hideHeader = true;
2025-02-04 21:20:35 +01:00
broadcastFeedback.start();
2024-10-06 22:36:10 +02:00
sweeper.markUserApproved();
2024-10-06 00:17:04 +02:00
}
}
2025-02-04 21:20:35 +01:00
Flowee.BroadcastFeedback {
2024-10-06 00:17:04 +02:00
id: broadcastFeedback
2025-02-04 21:20:35 +01:00
status: sweeper.broadcastStatus
bitcoinAmount: sweeper.sweepTotal
fiatPrice: Fiat.price
targetAddress: sweeper.targetAddress
2025-02-04 22:33:08 +01:00
showPersonalNote: false
2024-10-06 00:17:04 +02:00
2025-02-04 22:33:08 +01:00
onCloseButtonPressed: {
2025-02-04 21:20:35 +01:00
var mainView = thePile.get(0);
mainView.currentIndex = 0; // go to the 'main' tab.
thePile.pop();
2024-10-06 00:17:04 +02:00
}
}
2024-10-01 21:26:01 +02:00
}