Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to PageStacks #428

Merged
merged 4 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ QML_RES_QML = \
qml/controls/OptionButton.qml \
qml/controls/OptionSwitch.qml \
qml/controls/OutlineButton.qml \
qml/controls/PageStack.qml \
qml/controls/ProgressIndicator.qml \
qml/controls/qmldir \
qml/controls/Setting.qml \
Expand All @@ -420,6 +421,7 @@ QML_RES_QML = \
qml/pages/onboarding/OnboardingStorageAmount.qml \
qml/pages/onboarding/OnboardingStorageLocation.qml \
qml/pages/onboarding/OnboardingStrengthen.qml \
qml/pages/onboarding/OnboardingWizard.qml \
qml/pages/settings/SettingsAbout.qml \
qml/pages/settings/SettingsBlockClockDisplayMode.qml \
qml/pages/settings/SettingsConnection.qml \
Expand Down
2 changes: 2 additions & 0 deletions src/qml/bitcoin_qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<file>controls/OptionButton.qml</file>
<file>controls/OptionSwitch.qml</file>
<file>controls/OutlineButton.qml</file>
<file>controls/PageStack.qml</file>
<file>controls/ProgressIndicator.qml</file>
<file>controls/qmldir</file>
<file>controls/Setting.qml</file>
Expand All @@ -60,6 +61,7 @@
<file>pages/onboarding/OnboardingStorageAmount.qml</file>
<file>pages/onboarding/OnboardingStorageLocation.qml</file>
<file>pages/onboarding/OnboardingStrengthen.qml</file>
<file>pages/onboarding/OnboardingWizard.qml</file>
<file>pages/settings/SettingsAbout.qml</file>
<file>pages/settings/SettingsBlockClockDisplayMode.qml</file>
<file>pages/settings/SettingsConnection.qml</file>
Expand Down
51 changes: 51 additions & 0 deletions src/qml/controls/PageStack.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (c) 2024 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

import QtQuick 2.15
import QtQuick.Controls 2.15

StackView {
property bool vertical: false

pushEnter: Transition {
NumberAnimation {
property: vertical ? "y" : "x"
from: vertical ? parent.height : parent.width
to: 0
duration: 400
easing.type: Easing.Bezier
easing.bezierCurve: [0.5, 0.0, 0.2, 1.0]
}
}
pushExit: Transition {
NumberAnimation {
property: vertical ? "y" : "x"
from: 0
to: vertical ? -parent.height : -parent.width
duration: 400
easing.type: Easing.Bezier
easing.bezierCurve: [0.5, 0.0, 0.2, 1.0]
}
}
popEnter: Transition {
NumberAnimation {
property: vertical ? "y" : "x"
from: vertical ? -parent.height : -parent.width
to: 0
duration: 400
easing.type: Easing.Bezier
easing.bezierCurve: [0.5, 0.0, 0.2, 1.0]
}
}
popExit: Transition {
NumberAnimation {
property: vertical ? "y" : "x"
from: 0
to: vertical ? parent.height : parent.width
duration: 400
easing.type: Easing.Bezier
easing.bezierCurve: [0.5, 0.0, 0.2, 1.0]
}
}
}
60 changes: 19 additions & 41 deletions src/qml/pages/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ApplicationWindow {
ColorAnimation { duration: 150 }
}

StackView {
PageStack {
id: main
initialItem: {
if (needOnboarding) {
Expand Down Expand Up @@ -65,36 +65,8 @@ ApplicationWindow {

Component {
id: onboardingWizard
SwipeView {
id: swipeView
property bool finished: false
interactive: false

OnboardingCover {
onNext: swipeView.incrementCurrentIndex()
}
OnboardingStrengthen {
onBack: swipeView.decrementCurrentIndex()
onNext: swipeView.incrementCurrentIndex()
}
OnboardingBlockclock {
onBack: swipeView.decrementCurrentIndex()
onNext: swipeView.incrementCurrentIndex()
}
OnboardingStorageLocation {
onBack: swipeView.decrementCurrentIndex()
onNext: swipeView.incrementCurrentIndex()
}
OnboardingStorageAmount {
onBack: swipeView.decrementCurrentIndex()
onNext: swipeView.incrementCurrentIndex()
}
OnboardingConnection {
onBack: swipeView.decrementCurrentIndex()
onNext: swipeView.finished = true
}

onFinishedChanged: {
OnboardingWizard {
onFinished: {
optionsModel.onboard()
if (AppMode.walletEnabled && AppMode.isDesktop) {
main.push(desktopWallets)
Expand Down Expand Up @@ -127,18 +99,24 @@ ApplicationWindow {

Component {
id: node
SwipeView {
id: node_swipe
interactive: false
orientation: Qt.Vertical
NodeRunner {
onSettingsClicked: {
node_swipe.incrementCurrentIndex()
PageStack {
id: nodeStack
vertical: true
initialItem: node
Component {
id: node
NodeRunner {
onSettingsClicked: {
nodeStack.push(nodeSettings)
}
}
}
NodeSettings {
onDoneClicked: {
node_swipe.decrementCurrentIndex()
Component {
id: nodeSettings
NodeSettings {
onDoneClicked: {
nodeStack.pop()
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/qml/pages/node/NodeSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Item {

id: root

StackView {
PageStack {
id: nodeSettingsView
anchors.fill: parent

Expand Down
76 changes: 41 additions & 35 deletions src/qml/pages/onboarding/OnboardingConnection.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,46 +15,52 @@ Page {
signal next
background: null
clip: true
SwipeView {
id: connections
PageStack {
id: connectionStack
anchors.fill: parent
interactive: false
orientation: Qt.Vertical
InformationPage {
navLeftDetail: NavButton {
iconSource: "image://images/caret-left"
text: qsTr("Back")
onClicked: root.back()
}
bannerItem: Image {
Layout.topMargin: 20
Layout.alignment: Qt.AlignCenter
source: Theme.image.storage
sourceSize.width: 200
sourceSize.height: 200
}
bold: true
headerText: qsTr("Starting initial download")
headerMargin: 30
description: qsTr("The application will connect to the Bitcoin network and start downloading and verifying transactions.\n\nThis may take several hours, or even days, based on your connection.")
descriptionMargin: 10
detailActive: true
detailTopMargin: 10
detailItem: RowLayout {
TextButton {
vertical: true
initialItem: onboardingConnection
Component {
id: onboardingConnection
InformationPage {
navLeftDetail: NavButton {
iconSource: "image://images/caret-left"
text: qsTr("Back")
onClicked: root.back()
}
bannerItem: Image {
Layout.topMargin: 20
Layout.alignment: Qt.AlignCenter
text: qsTr("Connection settings")
onClicked: connections.incrementCurrentIndex()
source: Theme.image.storage
sourceSize.width: 200
sourceSize.height: 200
}
bold: true
headerText: qsTr("Starting initial download")
headerMargin: 30
description: qsTr("The application will connect to the Bitcoin network and start downloading and verifying transactions.\n\nThis may take several hours, or even days, based on your connection.")
descriptionMargin: 10
detailActive: true
detailTopMargin: 10
detailItem: RowLayout {
TextButton {
Layout.alignment: Qt.AlignCenter
text: qsTr("Connection settings")
onClicked: connectionStack.push(connectionSettings)
}
}
lastPage: true
buttonText: qsTr("Next")
buttonMargin: 20
onNext: root.next()
}
lastPage: true
buttonText: qsTr("Next")
buttonMargin: 20
onNext: root.next()
}
SettingsConnection {
onboarding: true
onBack: connections.decrementCurrentIndex()
Component {
id: connectionSettings
SettingsConnection {
onboarding: true
onBack: connectionStack.pop()
}
}
}
}
75 changes: 39 additions & 36 deletions src/qml/pages/onboarding/OnboardingCover.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,50 @@ Page {
signal next
background: null
clip: true
SwipeView {
id: introductions
PageStack {
id: coverStack
anchors.fill: parent
interactive: false
orientation: Qt.Horizontal
InformationPage {
navRightDetail: NavButton {
iconSource: "image://images/info"
iconHeight: 24
iconWidth: 24
iconColor: Theme.color.neutral0
iconBackground: Rectangle {
radius: 12
color: Theme.color.neutral9
initialItem: onboardingCover
Component {
id: onboardingCover
InformationPage {
navRightDetail: NavButton {
iconSource: "image://images/info"
iconHeight: 24
iconWidth: 24
iconColor: Theme.color.neutral0
iconBackground: Rectangle {
radius: 12
color: Theme.color.neutral9
}
onClicked: coverStack.push(coverSettings)
}
onClicked: {
introductions.incrementCurrentIndex()
bannerItem: Image {
Layout.fillWidth: true
Layout.alignment: Qt.AlignCenter
source: "image://images/app"
// Bitcoin icon has ~11% padding
sourceSize.width: 112
sourceSize.height: 112
}
bannerMargin: 0
bold: true
headerText: qsTr("Bitcoin Core App")
headerSize: 36
description: qsTr("Be part of the Bitcoin network.")
descriptionMargin: 10
descriptionSize: 24
subtext: qsTr("100% open-source & open-design")
buttonText: qsTr("Start")
onNext: root.next()
}
bannerItem: Image {
Layout.fillWidth: true
Layout.alignment: Qt.AlignCenter
source: "image://images/app"
// Bitcoin icon has ~11% padding
sourceSize.width: 112
sourceSize.height: 112
}
bannerMargin: 0
bold: true
headerText: qsTr("Bitcoin Core App")
headerSize: 36
description: qsTr("Be part of the Bitcoin network.")
descriptionMargin: 10
descriptionSize: 24
subtext: qsTr("100% open-source & open-design")
buttonText: qsTr("Start")
onNext: root.next()
}
SettingsAbout {
onboarding: true
onBack: introductions.decrementCurrentIndex()
Component {
id: coverSettings
SettingsAbout {
onboarding: true
onBack: coverStack.pop()
}
}
}
}
Loading
Loading