Files
pay/guis/mobile/PlannedPayments.qml
T

177 lines
5.7 KiB
QML
Raw Permalink Normal View History

2025-06-24 22:19:37 +02:00
/*
* This file is part of the Flowee project
2026-02-04 19:28:03 +01:00
* Copyright (C) 2025-2026 Tom Zander <tom@flowee.org>
2025-06-24 22:19:37 +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.Basic as QQC2
import "../Flowee" as Flowee
import "../Utils.js" as Utils
2026-02-04 19:28:03 +01:00
import Flowee.org.pay
2025-06-24 22:19:37 +02:00
ListView {
id: root
2025-08-11 16:40:11 +02:00
model: RepeatPaymentsModel {
id: repeatPaymentsModel
}
onActiveFocusChanged: {
if (!activeFocus) // move 'approved' items to the proper section
2026-02-04 15:02:32 +01:00
model.updateOrdering()
}
2025-06-24 22:19:37 +02:00
clip: true
focus: true
section.property: "section"
section.labelPositioning: ViewSection.InlineLabels + ViewSection.CurrentLabelAtStart
section.delegate: Item {
height: label.height + 3
width: root.width
Flowee.Label {
id: label
x: 10
font.bold: true
font.pixelSize: mainWindow.font.pixelSize * 1.1
text: {
if (section == 1) // yes, 2 equals
return qsTr("Payments to Approve")
// if (section == 2)
2026-02-04 15:02:32 +01:00
return qsTr("Approved Payments")
}
}
MouseArea { anchors.fill: parent } // eat all taps
}
2026-02-04 19:28:03 +01:00
delegate: Rectangle {
2025-06-26 00:02:57 +02:00
id: delegateRoot
width: ListView.view.width
2026-02-04 19:28:03 +01:00
height: 16 + amountFiat.height + 6 + comment.height + 6 + approvedLine.height + 6 + walletChoice.height + 24
color: palette.base
2025-06-26 00:02:57 +02:00
2025-08-12 21:16:19 +02:00
property QtObject payment: model.payment
2026-02-04 19:28:03 +01:00
Rectangle {
anchors.fill: parent
anchors.margins: 10
gradient: Gradient {
GradientStop {
position: Pay.useDarkSkin ? 2 : 1
color: Pay.useDarkSkin ? palette.midlight : palette.mid
}
GradientStop {
position: 0
color: palette.base
2025-08-11 16:40:11 +02:00
}
}
2026-02-04 19:28:03 +01:00
radius: 10
MouseArea {
anchors.fill: parent
onClicked: thePile.push("RepeatPaymentDetails.qml", { savedPayment: model.payment})
}
2025-06-26 00:02:57 +02:00
}
2025-08-11 16:40:11 +02:00
2025-06-26 00:02:57 +02:00
Flowee.BitcoinAmountLabel {
id: amountBch
2025-08-11 16:40:11 +02:00
value: model.valueSats
2026-02-04 19:28:03 +01:00
x: 16
y: 24
2025-06-26 00:02:57 +02:00
showFiat: false
colorize: false
2025-08-11 16:40:11 +02:00
anchors.top: nextDate.bottom
2025-06-26 00:02:57 +02:00
anchors.topMargin: 6
2026-02-04 19:28:03 +01:00
visible: model.fiatFollows // check if the payment prefers fiat over sats
2025-06-26 00:02:57 +02:00
}
Flowee.Label {
id: amountFiat
2026-02-04 19:28:03 +01:00
text: {
let txt = Fiat.formattedPrice(model.valueFiat)
if (amountBch.visible)
return "("+ txt + ")"
return txt
}
x: 16 + (amountBch.visible ? amountBch.width + 10 : 0)
y: 24
anchors.left: amountBch.visible ? amountBch.right : parent.left
anchors.leftMargin: amountBch.visible ? 6 : 16
2025-06-26 00:02:57 +02:00
}
2026-02-04 19:28:03 +01:00
Flowee.Label {
id: comment
text: model.comment
width: parent.width - 32
elide: Text.ElideRight
x: 16
anchors.top: amountFiat.bottom
height: text === "" ? 0: contentHeight
2025-08-12 21:16:19 +02:00
}
Item {
2026-02-04 19:28:03 +01:00
id: approvedLine
anchors.top: comment.bottom
anchors.topMargin: 6
x: 16
width: checkLabel.contentWidth + 20
height: Math.max(24, checkLabel.contentHeight)
2025-08-12 21:16:19 +02:00
Rectangle {
radius: 4
color: palette.base
border.color: palette.highlight
border.width: 1.3
width: 24
height: 24
anchors.bottom: checkLabel.bottom
2026-02-05 13:53:01 +01:00
MouseArea {
anchors.fill: parent
anchors.margins: -10
onClicked: delegateRoot.payment.approved = !delegateRoot.payment.approved
}
2025-08-12 21:16:19 +02:00
}
Flowee.Label {
id: checkLabel
2025-08-12 21:16:19 +02:00
x: 30
2026-02-04 19:28:03 +01:00
text: {
let d = model.upcomingDate
let now = new Date()
// close to 'now', or in the past
if (d - now < 18 * 3600 * 1000) // 18h in ms
return qsTr("Approve to pay: today")
return qsTr("Approve to pay on %1", "The arg is a date").arg(Pay.formatDate(d))
}
2025-08-12 21:16:19 +02:00
}
Flowee.CheckShape {
id: check
transformOrigin: Item.BottomLeft
smooth: true
scale: 1.6
anchors.bottom: parent.bottom
anchors.bottomMargin: 3
visible: model.isApproved
}
2025-06-26 00:02:57 +02:00
}
2026-02-04 19:28:03 +01:00
Flowee.Label {
id: walletChoice
anchors.left: approvedLine.left
anchors.top: approvedLine.bottom
anchors.topMargin: 6
visible: !portfolio.singleAccountSetup
text: qsTr("From wallet: %1").arg(delegateRoot.payment.accountName)
height: visible ? contentHeight : 0
2025-08-11 16:40:11 +02:00
}
2025-06-24 22:19:37 +02:00
}
}