Files
pay/guis/mobile/PlannedPayments.qml
T

176 lines
5.4 KiB
QML

/*
* This file is part of the Flowee project
* Copyright (C) 2025 Tom Zander <tom@flowee.org>
*
* 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
import Flowee.org.pay;
ListView {
id: root
model: RepeatPaymentsModel {
id: repeatPaymentsModel
}
onActiveFocusChanged: {
if (!activeFocus) // move 'approved' items to the proper section
model.updateOrdering();
}
clip: true
focus: true
spacing: 6
section.property: "section"
section.labelPositioning: ViewSection.InlineLabels + ViewSection.CurrentLabelAtStart
section.delegate: Item {
height: label.height + 3
width: root.width
Rectangle {
color: palette.base
anchors.fill: parent
}
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)
return qsTr("Approved Payments");
}
}
MouseArea { anchors.fill: parent } // eat all taps
}
delegate: Item {
id: delegateRoot
width: ListView.view.width
height: 10 + comment.height + 10 + upcomingDate.height + nextDate.height + amountBch.height + 8
property QtObject payment: model.payment
Flowee.Label {
id: comment
text: model.comment
width: parent.width - 20
elide: Text.ElideRight
x: 10
y: 10
height: text === "" ? 0: contentHeight
}
Flowee.Label {
id: upcomingDate
text: {
let d = model.upcomingDate;
let now = new Date();
// close to 'now'
if (Math.abs(now - d) < 18 * 3600 * 1000) { // 18h in ms
return Pay.formatDateTime(d);
}
Pay.formatDate(d)
}
anchors.right: parent.right
anchors.rightMargin: 30
anchors.top: comment.bottom
anchors.topMargin: 10
}
Flowee.Label {
id: nextDate
text: Pay.formatDate(model.nextDate)
anchors.right: upcomingDate.right
anchors.top: upcomingDate.bottom
font.pixelSize: upcomingDate.font.pixelSize * 0.9
color: palette.dark
}
Flowee.BitcoinAmountLabel {
// check if the payment prefers fiat over sats
id: amountBch
value: model.valueSats
anchors.right: parent.right
anchors.rightMargin: 10
showFiat: false
colorize: false
anchors.top: nextDate.bottom
anchors.topMargin: 6
visible: model.fiatFollows
}
Flowee.Label {
id: amountFiat
visible: !model.fiatFollows
text: Fiat.formattedPrice(model.valueFiat)
anchors.right: parent.right
anchors.rightMargin: 10
anchors.top: nextDate.bottom
anchors.topMargin: 6
}
MouseArea {
anchors.fill: parent
onClicked: thePile.push("RepeatPaymentDetails.qml", { savedPayment: model.payment});
}
Item {
anchors.bottom: upcomingDate.bottom
x: 10
width: checkLabel.contentWidth + 20
height: Math.max(24, checkLabel.contentHeight)
Rectangle {
radius: 4
color: palette.base
border.color: palette.highlight
border.width: 1.3
width: 24
height: 24
anchors.bottom: checkLabel.bottom
}
Flowee.Label {
id: checkLabel
x: 30
text: qsTr("Approved")
}
Flowee.CheckShape {
id: check
transformOrigin: Item.BottomLeft
smooth: true
scale: 1.6
anchors.bottom: parent.bottom
anchors.bottomMargin: 3
visible: model.isApproved
}
MouseArea {
anchors.fill: parent
anchors.margins: -5
onClicked: delegateRoot.payment.approved = !delegateRoot.payment.approved
}
}
Rectangle {
width: parent.width * 0.7
height: 1.2
color: palette.midlight
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
}
}
}