Introduce and use Onboardinginfo control #146

Manually merged
jarolrod merged 2 commits from onboardinginfo-control into main 2022-08-14 07:21:09 +00:00 AGit
jarolrod commented 2022-08-08 05:20:02 +00:00 (Migrated from github.com)

This introduces the OnboardingInfo control which represents the contents of an onboarding page that displays an image, some body text, and the continue button. This type of onboarding page is thus categorized as in info page. This is a nice simplification for the onboarding views pages which display this type of info.

Extensible now with a loader for when the current temp images are replaced with Lottie animations.

no visual difference, comparison between master and pr below for reference:

master

onboarding01a.qml onboarding02.qml onboarding03.qml
Screen Shot 2022-08-08 at 1 09 27 AM Screen Shot 2022-08-08 at 1 09 33 AM Screen Shot 2022-08-08 at 1 09 46 AM

pr

onboarding01a.qml onboarding02.qml onboarding03.qml
Screen Shot 2022-08-08 at 1 08 30 AM Screen Shot 2022-08-08 at 1 08 38 AM Screen Shot 2022-08-08 at 1 08 43 AM

Windows
Intel macOS
Apple Silicon macOS
ARM64 Android

This introduces the `OnboardingInfo` control which represents the contents of an onboarding page that displays an image, some body text, and the continue button. This type of onboarding page is thus categorized as in info page. This is a nice simplification for the onboarding views pages which display this type of info. Extensible now with a loader for when the current temp images are replaced with Lottie animations. no visual difference, comparison between master and pr below for reference: **master** | onboarding01a.qml | onboarding02.qml | onboarding03.qml | | ------------------- | ------------------ | ------------------- | | <img width="708" alt="Screen Shot 2022-08-08 at 1 09 27 AM" src="https://user-images.githubusercontent.com/23396902/183359912-629c1152-3d1e-46ab-8dfd-b69d543e34f5.png"> | <img width="752" alt="Screen Shot 2022-08-08 at 1 09 33 AM" src="https://user-images.githubusercontent.com/23396902/183359948-8ede57ff-80f0-4dfc-933e-b2bbeb10bf84.png"> | <img width="752" alt="Screen Shot 2022-08-08 at 1 09 46 AM" src="https://user-images.githubusercontent.com/23396902/183359973-9c80d61d-4f3a-45dc-b79b-88e23b80109a.png"> | **pr** | onboarding01a.qml | onboarding02.qml | onboarding03.qml | | ------------------- | ------------------ | ------------------- | | <img width="708" alt="Screen Shot 2022-08-08 at 1 08 30 AM" src="https://user-images.githubusercontent.com/23396902/183360053-091a898b-a216-46e3-8ea4-bbdaf250b442.png"> | <img width="752" alt="Screen Shot 2022-08-08 at 1 08 38 AM" src="https://user-images.githubusercontent.com/23396902/183360077-bf165055-e3a0-4c5f-86c3-daebb2aac794.png"> | <img width="752" alt="Screen Shot 2022-08-08 at 1 08 43 AM" src="https://user-images.githubusercontent.com/23396902/183360097-69958c50-d2bb-402c-a663-5feab82bd48c.png"> | [![Windows](https://img.shields.io/badge/OS-Windows-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/win64/insecure_win_gui.zip?branch=pull/146) [![Intel macOS](https://img.shields.io/badge/OS-Intel%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos/insecure_mac_gui.zip?branch=pull/146) [![Apple Silicon macOS](https://img.shields.io/badge/OS-Apple%20Silicon%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos_arm64/insecure_mac_arm64_gui.zip?branch=pull/<PR>) [![ARM64 Android](https://img.shields.io/badge/OS-Android-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/android/insecure_android_apk.zip?branch=pull/146)
shaavan (Migrated from github.com) reviewed 2022-08-12 14:41:40 +00:00
shaavan (Migrated from github.com) left a comment

Concept ACK

This PR provides a nice cleanup for information-based onboarding views pages. And I agree with the approach of PR.
I have some suggestions to help further clean up the intended files.

  1. The width and anchoring of contents on the pages are the same for all the onboarding views. So they can be moved to OnboardingInfo.qml
  2. The descriptionMargin value can be changed from 10 -> 20, which is equal for pages 2 and 3. This will save up on a redundant declaration for this property.
  3. In the banner source component, we can avoid declaring three properties for each usage of OnboardingInfo.
    a. Layout.fillWidth = true -> Since we are explicitly providing the sourceSize width and height, setting this property is redundant.
    b. Layout.alignment -> Since the Loader already sets the alignment for the sourceComponent, defining this is also redundant.
    c. Layout.topMargin -> We can instead set the margin of the Loader itself, using, say, bannerMargin and set it to the default value 20 property. This will make the usage of banner in OnboardingInfo less cumbersome.

Here is the diff incorporating all the suggested changes. The onboarding views remain visually identical after applying the diff.

Diff:

diff --git a/src/qml/controls/OnboardingInfo.qml b/src/qml/controls/OnboardingInfo.qml
index 299d8d818..e4b774e60 100644
--- a/src/qml/controls/OnboardingInfo.qml
+++ b/src/qml/controls/OnboardingInfo.qml
@@ -9,6 +9,7 @@ import QtQuick.Layouts 1.15
 Control {
     id: root
     property alias banner: banner_loader.sourceComponent
+    property int bannerMargin: 20
     required property string buttonText
     property bool bold: false
     property bool center: true
@@ -16,12 +17,16 @@ Control {
     property int headerMargin: 30
     property int headerSize: 28
     property string description: ""
-    property int descriptionMargin: 10
+    property int descriptionMargin: 20
     property int descriptionSize: 18
     property string subtext: ""
     property int subtextMargin: 30
     property int subtextSize: 15
 
+    anchors.top: parent.top
+    anchors.horizontalCenter: parent.horizontalCenter
+    width: 600
+
     contentItem: ColumnLayout {
         spacing: 0
         Loader {
@@ -29,6 +34,7 @@ Control {
             active: true
             visible: active
             Layout.alignment: Qt.AlignCenter
+            Layout.topMargin: root.bannerMargin
             sourceComponent: root.actionItem
         }
         Header {
diff --git a/src/qml/pages/onboarding/onboarding01a.qml b/src/qml/pages/onboarding/onboarding01a.qml
index ef18a4a7d..bca18e17d 100644
--- a/src/qml/pages/onboarding/onboarding01a.qml
+++ b/src/qml/pages/onboarding/onboarding01a.qml
@@ -49,20 +49,17 @@ Page {
         }
     }
     OnboardingInfo {
-        width: 600
-        anchors.top: parent.top
-        anchors.horizontalCenter: parent.horizontalCenter
         banner: Image {
-            Layout.fillWidth: true
-            Layout.alignment: Qt.AlignCenter
             source: "image://images/app"
             sourceSize.width: 100
             sourceSize.height: 100
         }
+        bannerMargin: 0
         bold: true
         header: 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: "Start"
diff --git a/src/qml/pages/onboarding/onboarding02.qml b/src/qml/pages/onboarding/onboarding02.qml
index 3d6f62653..77172dc8c 100644
--- a/src/qml/pages/onboarding/onboarding02.qml
+++ b/src/qml/pages/onboarding/onboarding02.qml
@@ -48,22 +48,14 @@ Page {
         }
     }
     OnboardingInfo {
-      width: 600
-      anchors.top: parent.top
-      anchors.horizontalCenter: parent.horizontalCenter
       banner: Image {
-          Layout.fillWidth: true
-          Layout.topMargin: 20
-          Layout.alignment: Qt.AlignCenter
           source: "image://images/app"
           sourceSize.width: 200
           sourceSize.height: 200
       }
       bold: true
       header: qsTr("Strengthen bitcoin")
-      headerMargin: 30
       description: qsTr("Bitcoin Core runs a full Bitcoin node which verifies the rules of the network are being followed.\n\nUsers running nodes is what makes bitcoin\nso resilient and trustworthy.")
-      descriptionMargin: 20
       buttonText: "Next"
     }
 }
diff --git a/src/qml/pages/onboarding/onboarding03.qml b/src/qml/pages/onboarding/onboarding03.qml
index f46f03e5e..b24d99f08 100644
--- a/src/qml/pages/onboarding/onboarding03.qml
+++ b/src/qml/pages/onboarding/onboarding03.qml
@@ -48,21 +48,14 @@ Page {
         }
     }
     OnboardingInfo {
-        width: 600
-        anchors.top: parent.top
-        anchors.horizontalCenter: parent.horizontalCenter
         banner: Image {
-            Layout.topMargin: 20
-            Layout.alignment: Qt.AlignCenter
             source: "image://images/app"
             sourceSize.width: 200
             sourceSize.height: 200
         }
         bold: true
         header: qsTr("The block clock")
-        headerMargin: 30
         description: qsTr("The Bitcoin network targets a new block every\n10 minutes. Sometimes it's faster and sometimes slower.\n\nThe block clock indicates each block on a dial\nthat represents the current day.")
-        descriptionMargin: 20
         buttonText: "Next"
     }
 }
Concept ACK This PR provides a nice cleanup for information-based onboarding views pages. And I agree with the approach of PR. I have some suggestions to help further clean up the intended files. 1. The `width` and anchoring of contents on the pages are the same for all the onboarding views. So they can be moved to `OnboardingInfo.qml` 2. The `descriptionMargin` value can be changed from `10` -> `20`, which is equal for pages 2 and 3. This will save up on a redundant declaration for this property. 3. In the `banner` source component, we can avoid declaring three properties for each usage of **OnboardingInfo**. a. `Layout.fillWidth = true` -> Since we are explicitly providing the `sourceSize` `width` and `height`, setting this property is redundant. b. `Layout.alignment` -> Since the **Loader** already sets the alignment for the `sourceComponent`, defining this is also redundant. c. `Layout.topMargin` -> We can instead set the margin of the **Loader** itself, using, say, `bannerMargin` and set it to the default value `20` property. This will make the usage of banner in **OnboardingInfo** less cumbersome. Here is the diff incorporating all the suggested changes. The onboarding views remain visually identical after applying the diff. **Diff:** ```diff diff --git a/src/qml/controls/OnboardingInfo.qml b/src/qml/controls/OnboardingInfo.qml index 299d8d818..e4b774e60 100644 --- a/src/qml/controls/OnboardingInfo.qml +++ b/src/qml/controls/OnboardingInfo.qml @@ -9,6 +9,7 @@ import QtQuick.Layouts 1.15 Control { id: root property alias banner: banner_loader.sourceComponent + property int bannerMargin: 20 required property string buttonText property bool bold: false property bool center: true @@ -16,12 +17,16 @@ Control { property int headerMargin: 30 property int headerSize: 28 property string description: "" - property int descriptionMargin: 10 + property int descriptionMargin: 20 property int descriptionSize: 18 property string subtext: "" property int subtextMargin: 30 property int subtextSize: 15 + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + width: 600 + contentItem: ColumnLayout { spacing: 0 Loader { @@ -29,6 +34,7 @@ Control { active: true visible: active Layout.alignment: Qt.AlignCenter + Layout.topMargin: root.bannerMargin sourceComponent: root.actionItem } Header { diff --git a/src/qml/pages/onboarding/onboarding01a.qml b/src/qml/pages/onboarding/onboarding01a.qml index ef18a4a7d..bca18e17d 100644 --- a/src/qml/pages/onboarding/onboarding01a.qml +++ b/src/qml/pages/onboarding/onboarding01a.qml @@ -49,20 +49,17 @@ Page { } } OnboardingInfo { - width: 600 - anchors.top: parent.top - anchors.horizontalCenter: parent.horizontalCenter banner: Image { - Layout.fillWidth: true - Layout.alignment: Qt.AlignCenter source: "image://images/app" sourceSize.width: 100 sourceSize.height: 100 } + bannerMargin: 0 bold: true header: 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: "Start" diff --git a/src/qml/pages/onboarding/onboarding02.qml b/src/qml/pages/onboarding/onboarding02.qml index 3d6f62653..77172dc8c 100644 --- a/src/qml/pages/onboarding/onboarding02.qml +++ b/src/qml/pages/onboarding/onboarding02.qml @@ -48,22 +48,14 @@ Page { } } OnboardingInfo { - width: 600 - anchors.top: parent.top - anchors.horizontalCenter: parent.horizontalCenter banner: Image { - Layout.fillWidth: true - Layout.topMargin: 20 - Layout.alignment: Qt.AlignCenter source: "image://images/app" sourceSize.width: 200 sourceSize.height: 200 } bold: true header: qsTr("Strengthen bitcoin") - headerMargin: 30 description: qsTr("Bitcoin Core runs a full Bitcoin node which verifies the rules of the network are being followed.\n\nUsers running nodes is what makes bitcoin\nso resilient and trustworthy.") - descriptionMargin: 20 buttonText: "Next" } } diff --git a/src/qml/pages/onboarding/onboarding03.qml b/src/qml/pages/onboarding/onboarding03.qml index f46f03e5e..b24d99f08 100644 --- a/src/qml/pages/onboarding/onboarding03.qml +++ b/src/qml/pages/onboarding/onboarding03.qml @@ -48,21 +48,14 @@ Page { } } OnboardingInfo { - width: 600 - anchors.top: parent.top - anchors.horizontalCenter: parent.horizontalCenter banner: Image { - Layout.topMargin: 20 - Layout.alignment: Qt.AlignCenter source: "image://images/app" sourceSize.width: 200 sourceSize.height: 200 } bold: true header: qsTr("The block clock") - headerMargin: 30 description: qsTr("The Bitcoin network targets a new block every\n10 minutes. Sometimes it's faster and sometimes slower.\n\nThe block clock indicates each block on a dial\nthat represents the current day.") - descriptionMargin: 20 buttonText: "Next" } } ```
jarolrod commented 2022-08-13 20:06:04 +00:00 (Migrated from github.com)

Updated from d606f85 to 661d4d2

changes:

  • rebased over master
  • picked up some of the review feedback from here: https://github.com/bitcoin-core/gui-qml/pull/146#pullrequestreview-1071199645, differing from the review by:
    • not setting any anchors within the OnboardingInfo control because we don't know from within the control definition what the parent will be, and how it should behave within the parent
    • setting an implicitWidth within the control instead of width
Updated from d606f85 to 661d4d2 changes: - rebased over master - picked up some of the review feedback from here: https://github.com/bitcoin-core/gui-qml/pull/146#pullrequestreview-1071199645, differing from the review by: - not setting any anchors within the OnboardingInfo control because we don't know from within the control definition what the parent will be, and how it should behave within the parent - setting an `implicitWidth` within the control instead of `width`
hebasto (Migrated from github.com) approved these changes 2022-08-14 07:18:49 +00:00
hebasto (Migrated from github.com) left a comment

ACK 661d4d2a4a, tested on Ubuntu 22.04.

ACK 661d4d2a4a6287bdfde829997f40edbe80faf785, tested on Ubuntu 22.04.
Sign in to join this conversation.
No description provided.