Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
95 changes: 95 additions & 0 deletions storybook/pages/EnterSeedPhraseNewPage.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQml

import StatusQ
import StatusQ.Core
import StatusQ.Core.Utils
import StatusQ.Controls
import StatusQ.Components
import StatusQ.Core.Theme

import Models
import Storybook

import SortFilterProxyModel
import QtModelsToolkit

import shared
import shared.panels
import utils

Item {
id: root

MouseArea {
anchors.fill: parent

onClicked: root.focus = true
}

function isValid(mnemonic) {
return mnemonic === sampleValidPhrase
}

readonly property string sampleValidPhrase:
"abandon baby cat dad eager fabric gadget habit ice jacket kangaroo lab"

Rectangle {
anchors.fill: parent
anchors.margins: 150
border.width: 1
color: "transparent"

StatusScrollView {
id: scrollView

anchors.fill: parent
contentWidth: availableWidth

EnterSeedPhraseNew {
id: enterSeedPhrase

property var validSeedPhrase: []

width: scrollView.availableWidth
dictionary: BIP39_en {}

onSeedPhraseProvided: seedPhrase => {
const valid = seedPhrase.join(" ") === sampleValidPhrase
setError(valid ? "" : "Invalid seed phrase!")
}

onSeedPhraseAccepted: validSeedPhrase = seedPhrase
}
}
}

ColumnLayout {
anchors.bottom: parent.bottom

Button {
text: "Copy valid seed phrase to keyboard: " + root.sampleValidPhrase

onClicked: ClipboardUtils.setText(root.sampleValidPhrase)
}

Label {
text: "is seedphrase valid: " + enterSeedPhrase.seedPhraseIsValid
}

Label {
text: "valid seed phrase provided: " + enterSeedPhrase.validSeedPhrase.toString()
}

Label {
text: JSON.stringify(enterSeedPhrase.seedPhrase)

Layout.bottomMargin: 20
}
}
}

// category: Panels
// status: good
68 changes: 68 additions & 0 deletions ui/StatusQ/src/StatusQ/Controls/StatusSeedPhraseField.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import QtQuick
import QtQuick.Controls

import StatusQ.Core
import StatusQ.Core.Theme
import StatusQ.Core.Utils

TextField {
id: root

property int displayIndex
property bool valid: true

leftPadding: fontMetrics.advanceWidth("24") + Theme.bigPadding
rightPadding: Theme.halfPadding

verticalAlignment: TextInput.AlignVCenter

selectionColor: Theme.palette.primaryColor2
selectedTextColor: color
focus: !Utils.isMobile
font.pixelSize: Theme.primaryTextFontSize
font.family: Theme.baseFont.name
color: root.enabled ? Theme.palette.directColor1 : Theme.palette.baseColor1

inputMethodHints: Qt.ImhSensitiveData | Qt.ImhNoPredictiveText |
Qt.ImhNoAutoUppercase | Qt.ImhPreferLowercase

background: Rectangle {
id: background

color: Theme.palette.statusAppNavBar.backgroundColor
radius: Theme.radius

StatusBaseText {
id: text

FontMetrics {
id: fontMetrics
font: text.font
}

anchors.fill: parent
anchors.rightMargin: root.width - root.leftPadding

text: "" + root.displayIndex
font.family: Theme.monoFont.name

horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter

color: !root.valid ? Theme.palette.dangerColor1
: root.activeFocus ? Theme.palette.primaryColor1
: Theme.palette.baseColor1
}

border.width: 1
border.color: {
if (!root.valid)
return Theme.palette.dangerColor1

if (root.activeFocus)
return Theme.palette.primaryColor1

return root.hovered ? Theme.palette.primaryColor2 : "transparent"
}
}
}
49 changes: 49 additions & 0 deletions ui/StatusQ/src/StatusQ/Controls/StatusSeedPhraseTabBar.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import StatusQ.Controls

StatusSwitchTabBar {
id: root

padding: 0

readonly property var lengths: [12, 18, 24]
readonly property int selectedLength: {
if (v12.checked)
return 12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: Maybe you could use constants instead everywhere here for 12, 18 and 14

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it's local thing I would just keep as it is. Those constants would have those number in its name as well...

if (v18.checked)
return 18
return 24
}

function selectLength(length: int) {
if (length === 12)
v12.checked = true
else if(length === 18)
v18.checked = true
else
v24.checked = true
}

StatusSwitchTabButton {
id: v12

verticalPadding: 0
text: qsTr("12 word")
objectName: "12SeedButton"
}

StatusSwitchTabButton {
id: v18

verticalPadding: 0
text: qsTr("18 word")
objectName: "18SeedButton"
}

StatusSwitchTabButton {
id: v24

verticalPadding: 0
text: qsTr("24 word")
objectName: "24SeedButton"
}
}
2 changes: 2 additions & 0 deletions ui/StatusQ/src/StatusQ/Controls/qmldir
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ StatusProgressBar 0.1 StatusProgressBar.qml
StatusRadioButton 0.1 StatusRadioButton.qml
StatusRoundButton 0.1 StatusRoundButton.qml
StatusScrollBar 0.1 StatusScrollBar.qml
StatusSeedPhraseField 0.1 StatusSeedPhraseField.qml
StatusSeedPhraseInput 0.1 StatusSeedPhraseInput.qml
StatusSeedPhraseTabBar 0.1 StatusSeedPhraseTabBar.qml
StatusSelect 0.1 StatusSelect.qml
StatusSelectableText 0.1 StatusSelectableText.qml
StatusSlider 0.1 StatusSlider.qml
Expand Down
2 changes: 2 additions & 0 deletions ui/StatusQ/src/statusq.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@
<file>StatusQ/Controls/StatusRadioButton.qml</file>
<file>StatusQ/Controls/StatusRoundButton.qml</file>
<file>StatusQ/Controls/StatusScrollBar.qml</file>
<file>StatusQ/Controls/StatusSeedPhraseField.qml</file>
<file>StatusQ/Controls/StatusSeedPhraseInput.qml</file>
<file>StatusQ/Controls/StatusSeedPhraseTabBar.qml</file>
<file>StatusQ/Controls/StatusSelect.qml</file>
<file>StatusQ/Controls/StatusSelectableText.qml</file>
<file>StatusQ/Controls/StatusSlider.qml</file>
Expand Down
22 changes: 22 additions & 0 deletions ui/i18n/qml_base_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7428,6 +7428,13 @@ Please add it and try again.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EnterSeedPhraseNew</name>
<message>
<source>The phrase you’ve entered is invalid</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EnterSeedPhraseWord</name>
<message>
Expand Down Expand Up @@ -16457,6 +16464,21 @@ to load</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>StatusSeedPhraseTabBar</name>
<message>
<source>12 word</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>18 word</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>24 word</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>StatusStackModal</name>
<message>
Expand Down
26 changes: 26 additions & 0 deletions ui/i18n/qml_base_lokalise_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9072,6 +9072,14 @@
<translation>Enter recovery phrase for %1 key pair</translation>
</message>
</context>
<context>
<name>EnterSeedPhraseNew</name>
<message>
<source>The phrase you’ve entered is invalid</source>
<comment>EnterSeedPhraseNew</comment>
<translation>The phrase you’ve entered is invalid</translation>
</message>
</context>
<context>
<name>EnterSeedPhraseWord</name>
<message>
Expand Down Expand Up @@ -20022,6 +20030,24 @@
<translation>In:</translation>
</message>
</context>
<context>
<name>StatusSeedPhraseTabBar</name>
<message>
<source>12 word</source>
<comment>StatusSeedPhraseTabBar</comment>
<translation>12 word</translation>
</message>
<message>
<source>18 word</source>
<comment>StatusSeedPhraseTabBar</comment>
<translation>18 word</translation>
</message>
<message>
<source>24 word</source>
<comment>StatusSeedPhraseTabBar</comment>
<translation>24 word</translation>
</message>
</context>
<context>
<name>StatusStackModal</name>
<message>
Expand Down
22 changes: 22 additions & 0 deletions ui/i18n/qml_cs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7456,6 +7456,13 @@ Please add it and try again.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EnterSeedPhraseNew</name>
<message>
<source>The phrase you’ve entered is invalid</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EnterSeedPhraseWord</name>
<message>
Expand Down Expand Up @@ -16530,6 +16537,21 @@ to load</source>
<translation>V: </translation>
</message>
</context>
<context>
<name>StatusSeedPhraseTabBar</name>
<message>
<source>12 word</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>18 word</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>24 word</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>StatusStackModal</name>
<message>
Expand Down
22 changes: 22 additions & 0 deletions ui/i18n/qml_ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7400,6 +7400,13 @@ Please add it and try again.</source>
<translation>%1 키 페어의 복구 구문을 입력하세요</translation>
</message>
</context>
<context>
<name>EnterSeedPhraseNew</name>
<message>
<source>The phrase you’ve entered is invalid</source>
<translation type="unfinished">입력한 구문이 올바르지 않습니다</translation>
</message>
</context>
<context>
<name>EnterSeedPhraseWord</name>
<message>
Expand Down Expand Up @@ -16388,6 +16395,21 @@ to load</source>
<translation>다음에서: </translation>
</message>
</context>
<context>
<name>StatusSeedPhraseTabBar</name>
<message>
<source>12 word</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>18 word</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>24 word</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>StatusStackModal</name>
<message>
Expand Down
Loading