Files
pay/guis/mobile/UnlockApplication.qml
T

147 lines
4.5 KiB
QML
Raw Permalink Normal View History

/*
* This file is part of the Flowee project
2025-03-03 15:55:44 +01:00
* Copyright (C) 2023-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
2025-02-05 20:52:38 +01:00
import QtQuick.Controls as QQC2
import "../Flowee" as Flowee
import Flowee.org.pay;
FocusScope {
2025-03-03 15:55:44 +01:00
id: root
Rectangle {
anchors.fill: parent
color: palette.window
}
MouseArea { // eat all mouse events.
anchors.fill: parent
}
2025-02-05 20:52:38 +01:00
Image {
source: "qrc:/background.jpg"
width: parent.width
height: {
if (Pay.unlockingKeyboard === FloweePay.FullKeyboard)
return parent.height;
if (Pay.unlockingKeyboard === FloweePay.SmallNumbersKeyboard)
return parent.height - 225;
return 0;
}
}
UnlockWidget {
anchors.fill: parent
anchors.margins: 10
onPasswordEntered: if (!Pay.checkAppPassword(password)) passwordIncorrect();
2025-02-07 00:18:44 +01:00
// the above background means the widget should prefer white text
assumeDarkBackground: Pay.unlockingKeyboard !== FloweePay.BigNumbersKeyboard
}
Keys.onPressed: (event)=> {
2025-03-03 15:55:44 +01:00
event.accepted = true;
if (event.key === Qt.Key_Escape || event.key === Qt.Key_Back)
mainWindow.close(); // exit app on 'back'.
}
2025-02-05 20:52:38 +01:00
Column {
id: quickReceive
x: 60
y: {
var uk = Pay.unlockingKeyboard;
if (uk === FloweePay.BigNumbersKeyboard)
return parent.height + 10;
if (uk === FloweePay.FullKeyboard)
2025-02-10 20:46:35 +01:00
return 300;
2025-02-05 20:52:38 +01:00
if (uk === FloweePay.SmallNumbersKeyboard)
2025-02-10 20:46:35 +01:00
return parent.height - 270 - height
2025-02-05 20:52:38 +01:00
}
spacing: 6
2025-02-10 20:58:54 +01:00
opacity: 0
property bool havePortfolio: typeof portfolio !== "undefined";
onHavePortfolioChanged: opacity = portfolio.current.isSingleAddressAccount ? 0 : 1
Behavior on opacity { NumberAnimation { } }
2025-02-05 20:52:38 +01:00
Image {
source: "qrc:/back-arrow"
rotation: 270
width: 30
height: 30
}
Flowee.Label {
color: "white"
text: qsTr("Quick Receive")
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
horizontalAlignment: Qt.AlignHCenter
x: 15 - width / 2
width: 90
}
}
MouseArea {
2025-03-03 15:55:44 +01:00
id: quickReceiveButton
focus: true
enabled: quickReceive.visible
2025-02-05 20:52:38 +01:00
anchors.fill: quickReceive
onClicked: myLittleStack.push(receive)
}
FocusScope {
anchors.fill: parent
Rectangle {
2025-02-09 22:57:14 +01:00
id: background
2025-02-05 20:52:38 +01:00
anchors.fill: parent
color: palette.window
visible: myLittleStack.depth > 0
2025-02-09 22:57:14 +01:00
MouseArea { anchors.fill: parent; acceptedButtons: Qt.AllButtons } // catch all
2025-02-05 20:52:38 +01:00
QQC2.StackView {
id: myLittleStack
anchors.fill: parent
onCurrentItemChanged: if (currentItem != null) currentItem.takeFocus();
}
}
Keys.onPressed: (event)=> {
if (event.key === Qt.Key_Escape || event.key === Qt.Key_Back) {
2025-03-03 15:55:44 +01:00
if (myLittleStack.depth <= 1) {
2025-02-05 20:52:38 +01:00
myLittleStack.clear();
2025-03-03 15:55:44 +01:00
quickReceiveButton.forceActiveFocus();
}
2025-02-05 20:52:38 +01:00
else
myLittleStack.pop();
event.accepted = true;
}
}
}
Component {
id: receive
Page {
function takeFocus() {
receiveTab.verticalTab = 1; // the money input
receiveTab.forceActiveFocus();
}
2025-02-05 20:52:38 +01:00
backHandler: function handler() { myLittleStack.clear() }
2025-02-09 22:57:14 +01:00
headerText: receiveTab.title
2025-02-10 16:04:45 +01:00
function switchToTab(tab) {
myLittleStack.clear();
}
2025-02-05 20:52:38 +01:00
ReceiveTab {
id: receiveTab
anchors.fill: parent
2025-02-09 22:57:14 +01:00
showInstructions: false
2025-02-05 20:52:38 +01:00
}
}
}
}