Files
pay/guis/mobile/PriceDetails.qml
T

104 lines
3.2 KiB
QML
Raw Permalink Normal View History

2023-02-19 18:42:33 +01:00
/*
* This file is part of the Flowee project
* Copyright (C) 2023 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 "../Flowee" as Flowee
2023-02-19 18:53:53 +01:00
import Flowee.org.pay;
2023-02-19 18:42:33 +01:00
Item {
id: root
implicitHeight: mainPrice.height + changes.height + 10
property int currentPrice: Fiat.price
2023-02-19 18:53:53 +01:00
Image {
2023-02-19 18:42:33 +01:00
anchors.right: parent.right
2023-02-19 18:53:53 +01:00
width: 16
height: 16
smooth: true
source: "qrc:/settingsIcon" + (Pay.useDarkSkin ? "-light" : "") + ".svg"
2023-02-19 18:42:33 +01:00
MouseArea {
anchors.fill: parent
onClicked: {
thePile.push("./CurrencySelector.qml")
popupOverlay.close();
}
}
}
Flowee.Label {
id: mainPrice
2023-02-20 10:11:26 +01:00
text: qsTr("1 BCH is: %1", "Price of a whole bitcoin cash"). arg(Fiat.formattedPrice(100000000, root.currentPrice))
2023-02-19 18:42:33 +01:00
}
2023-02-20 16:53:23 +01:00
Component {
id: historyLabel
Item {
property int days: 0
height: buddy.height
width: buddy.width + 3 + main.width
2023-03-09 22:44:17 +01:00
visible: main.priceThen > 0
2023-02-20 16:53:23 +01:00
Flowee.Label {
id: buddy
2023-02-20 18:05:22 +01:00
anchors.baseline: main.baseline
2023-02-20 16:53:23 +01:00
text: title + ":"
}
Flowee.Label {
id: main
anchors.left: buddy.right
anchors.leftMargin: 3
2023-03-09 22:44:17 +01:00
property int priceThen: Fiat.historicalPriceAccurate(daysAgo);
property double percentage: (root.currentPrice - priceThen) / priceThen * 100;
2023-02-20 16:53:23 +01:00
text: {
var sign = "";
if (percentage < 0)
sign = "↓";
else if (percentage > 0)
sign = "↑";
return sign + Math.abs(percentage.toFixed(1))+ "%"
}
color: {
if (percentage > 0)
return Pay.useDarkSkin ? mainWindow.floweeGreen : "#31993d";
return Pay.useDarkSkin ? "#ff5050" : "#c33d3d";
}
}
}
}
2023-02-19 18:42:33 +01:00
Flow {
id: changes
anchors.top: mainPrice.bottom
anchors.topMargin: 10
width: parent.width
2023-02-20 16:53:23 +01:00
spacing: 10
Repeater {
model: ListModel {
ListElement { title: qsTr("7d", "7 days"); // 7 days
daysAgo: 7 }
ListElement { title: qsTr("1m", "1 month"); // 30 days
daysAgo: 30 }
ListElement { title: qsTr("3m", "3 months"); // 90 days
daysAgo: 90 }
}
delegate: historyLabel
2023-02-19 18:42:33 +01:00
}
}
}