Files
pay/guis/mobile/NewAccount.qml
T

218 lines
7.7 KiB
QML
Raw Permalink Normal View History

2022-11-21 19:29:46 +01:00
/*
* This file is part of the Flowee project
* Copyright (C) 2022-2023 Tom Zander <tom@flowee.org>
2022-11-21 19:29:46 +01: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.Layouts
import "../Flowee" as Flowee
2022-11-22 23:11:33 +01:00
import Flowee.org.pay
2022-11-21 19:29:46 +01:00
Page {
id: root
headerText: qsTr("New Bitcoin Cash Wallet")
Flickable {
2022-12-05 20:31:00 +01:00
anchors.fill: parent
contentHeight: column.height + 20
contentWidth: width
2022-11-23 10:33:18 +01:00
Column {
id: column
2022-12-05 20:31:00 +01:00
width: parent.width
y: 10
spacing: 20
2022-11-21 19:29:46 +01:00
PageTitledBox {
title: qsTr("Create a New Wallet")
width: parent.width
2023-07-03 12:16:46 +02:00
spacing: 10
2022-12-05 20:31:00 +01:00
Flowee.CardTypeSelector {
title: qsTr("HD wallet")
2023-07-03 12:16:46 +02:00
onClicked: thePile.push(newHDWalletScreen);
width: parent.width * 0.75
anchors.horizontalCenter: parent.horizontalCenter
selected: true
features: [
qsTr("Seed-phrase based", "Context: wallet type"),
qsTr("Easy to backup", "Context: wallet type"),
qsTr("Most compatible", "The most compatible wallet type")
]
Rectangle {
anchors.fill: parent
color: "#00000000"
radius: 10
border.width: 5
border.color: mainWindow.floweeGreen
}
}
Flowee.CardTypeSelector {
title: qsTr("Basic")
width: parent.width * 0.75
2023-07-03 12:16:46 +02:00
onClicked: thePile.push(newBaseWalletScreen);
selected: true
anchors.horizontalCenter: parent.horizontalCenter
features: [
qsTr("Private keys based", "Property of a wallet"),
qsTr("Difficult to backup", "Context: wallet type"),
qsTr("Great for brief usage", "Context: wallet type")
]
}
2022-12-05 20:31:00 +01:00
}
PageTitledBox {
title: qsTr("Import Existing Wallet")
width: parent.width
Flowee.CardTypeSelector {
title: qsTr("Import")
width: parent.width * 0.75
2023-07-03 12:16:46 +02:00
onClicked: thePile.push("./ImportWalletPage.qml");
anchors.horizontalCenter: parent.horizontalCenter
selected: true
2022-11-21 19:29:46 +01:00
features: [
qsTr("Imports seed-phrase"),
qsTr("Imports private key")
]
}
2022-12-05 20:31:00 +01:00
}
2022-11-21 19:29:46 +01:00
}
2022-11-23 10:33:18 +01:00
}
2022-11-21 19:29:46 +01:00
2022-11-23 10:33:18 +01:00
// ------- the next screens
2022-11-21 19:29:46 +01:00
2022-11-23 10:33:18 +01:00
Item { // dummy item to allow components to be added to the parents GridLayout
Component {
id: newBaseWalletScreen
2022-11-21 19:29:46 +01:00
2022-11-23 10:33:18 +01:00
Page {
id: newWalletPage
headerText: qsTr("New Wallet")
2022-11-21 19:29:46 +01:00
2022-12-05 20:31:00 +01:00
ColumnLayout {
width: parent.width
spacing: 10
2022-12-05 20:31:00 +01:00
Flowee.Label {
id: title
text: qsTr("This creates a new empty wallet with simple multi-address capability")
Layout.fillWidth: true
wrapMode: Text.WordWrap
}
PageTitledBox {
title: qsTr("Name")
Flowee.TextField {
id: accountName
focus: true
width: parent.width
}
2022-12-05 20:31:00 +01:00
}
Flowee.CheckBox {
2023-07-05 12:24:31 +02:00
Layout.fillWidth: true
2022-12-05 20:31:00 +01:00
id: singleAddress
text: qsTr("Force Single Address");
toolTipText: qsTr("When enabled, this wallet will be limited to one address.\nThis ensures only one private key will need to be backed up")
2022-12-05 20:31:00 +01:00
}
Item {
width: parent.width
height: createButton.implicitHeight
2023-07-05 12:24:31 +02:00
Flowee.Button {
id: createButton
anchors.right: parent.right
text: qsTr("Create")
onClicked: {
var options = Pay.createNewBasicWallet(accountName.text);
options.forceSingleAddress = singleAddress.checked;
for (let a of portfolio.accounts) {
if (a.id === options.accountId) {
portfolio.current = a;
break;
}
}
thePile.pop();
thePile.pop();
}
}
2022-12-05 20:31:00 +01:00
}
2022-11-21 19:29:46 +01:00
}
}
}
2022-11-23 10:33:18 +01:00
Component {
id: newHDWalletScreen
Page {
headerText: qsTr("New HD-Wallet")
2022-12-05 20:31:00 +01:00
ColumnLayout {
width: parent.width
spacing: 10
2022-12-05 20:31:00 +01:00
Flowee.Label {
id: title
Layout.fillWidth: true
text: qsTr("This creates a new wallet that can be backed up with a seed-phrase")
2022-12-05 20:31:00 +01:00
wrapMode: Text.WordWrap
}
PageTitledBox {
title: qsTr("Name")
Flowee.TextField {
id: accountName
width: parent.width
focus: true
}
2022-12-05 20:31:00 +01:00
}
PageTitledBox {
title: qsTr("Derivation")
Flowee.TextField {
property bool derivationOk: Pay.checkDerivation(text);
id: derivationPath
width: parent.width
text: "m/44'/0'/0'" // What most BCH wallets are created with
color: derivationOk ? palette.text : "red"
}
}
Item {
width: parent.width
height: createButton.implicitHeight
2023-07-05 12:24:31 +02:00
Flowee.Button {
id: createButton
enabled: derivationPath.derivationOk
anchors.right: parent.right
text: qsTr("Create")
onClicked: {
var options = Pay.createNewWallet(derivationPath.text, /* password */"", accountName.text);
for (let a of portfolio.accounts) {
if (a.id === options.accountId) {
portfolio.current = a;
break;
}
}
thePile.pop();
thePile.pop();
}
}
2022-12-05 20:31:00 +01:00
}
2022-11-23 10:33:18 +01:00
}
}
}
}
2022-11-21 19:29:46 +01:00
}