mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-21 02:58:55 +00:00
Onboarding: KeycardEnterPinPage cleanup
This commit is contained in:
parent
0ef547a645
commit
b98758cb08
@ -3,7 +3,6 @@ import QtQuick.Controls 2.15
|
|||||||
import QtQuick.Layouts 1.15
|
import QtQuick.Layouts 1.15
|
||||||
|
|
||||||
import AppLayouts.Onboarding2.pages 1.0
|
import AppLayouts.Onboarding2.pages 1.0
|
||||||
import AppLayouts.Onboarding.enums 1.0
|
|
||||||
|
|
||||||
import utils 1.0
|
import utils 1.0
|
||||||
|
|
||||||
@ -16,7 +15,8 @@ Item {
|
|||||||
id: page
|
id: page
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
authorizationState: authorizationProgressSelector.value
|
state: KeycardEnterPinPage.State.Idle
|
||||||
|
|
||||||
remainingAttempts: remainingAttemptsSpinBox.value
|
remainingAttempts: remainingAttemptsSpinBox.value
|
||||||
|
|
||||||
unblockWithPukAvailable: ctrlUnblockWithPUK.checked
|
unblockWithPukAvailable: ctrlUnblockWithPUK.checked
|
||||||
@ -61,10 +61,34 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgressSelector {
|
RowLayout {
|
||||||
id: authorizationProgressSelector
|
id: statesRow
|
||||||
|
|
||||||
label: "Authorization progress"
|
ButtonGroup {
|
||||||
|
buttons: statesRow.children
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
checkable: true
|
||||||
|
checked: true
|
||||||
|
text: "Idle"
|
||||||
|
onClicked: page.state = KeycardEnterPinPage.State.Idle
|
||||||
|
}
|
||||||
|
Button {
|
||||||
|
checkable: true
|
||||||
|
text: "InProgress"
|
||||||
|
onClicked: page.state = KeycardEnterPinPage.State.InProgress
|
||||||
|
}
|
||||||
|
Button {
|
||||||
|
checkable: true
|
||||||
|
text: "Success"
|
||||||
|
onClicked: page.state = KeycardEnterPinPage.State.Success
|
||||||
|
}
|
||||||
|
Button {
|
||||||
|
checkable: true
|
||||||
|
text: "WrongPin"
|
||||||
|
onClicked: page.state = KeycardEnterPinPage.State.WrongPin
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,20 @@ SQUtils.QObject {
|
|||||||
KeycardEnterPinPage {
|
KeycardEnterPinPage {
|
||||||
id: page
|
id: page
|
||||||
|
|
||||||
authorizationState: root.authorizationState
|
state: {
|
||||||
|
switch (root.authorizationState) {
|
||||||
|
case Onboarding.ProgressState.Success:
|
||||||
|
return KeycardEnterPinPage.State.Success
|
||||||
|
case Onboarding.ProgressState.InProgress:
|
||||||
|
return KeycardEnterPinPage.State.InProgress
|
||||||
|
// workaround by mapping all failures as wrong pin (#17289)
|
||||||
|
case Onboarding.ProgressState.Failed:
|
||||||
|
return KeycardEnterPinPage.State.WrongPin
|
||||||
|
}
|
||||||
|
|
||||||
|
return KeycardEnterPinPage.State.Idle
|
||||||
|
}
|
||||||
|
|
||||||
remainingAttempts: root.remainingPinAttempts
|
remainingAttempts: root.remainingPinAttempts
|
||||||
unblockWithPukAvailable: root.remainingPukAttempts > 0
|
unblockWithPukAvailable: root.remainingPukAttempts > 0
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ SQUtils.QObject {
|
|||||||
|
|
||||||
function onAuthorizationStateChanged() {
|
function onAuthorizationStateChanged() {
|
||||||
// workaround for entering pin because currently there is not possible
|
// workaround for entering pin because currently there is not possible
|
||||||
// to distinguish invalid pin and failed pin entering operation
|
// to distinguish invalid pin and failed pin entering operation (#17289)
|
||||||
if (root.stackView.currentItem instanceof KeycardEnterPinPage)
|
if (root.stackView.currentItem instanceof KeycardEnterPinPage)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import QtQuick 2.15
|
import QtQuick 2.15
|
||||||
import QtQuick.Layouts 1.15
|
|
||||||
|
|
||||||
import StatusQ.Components 0.1
|
import StatusQ.Components 0.1
|
||||||
import StatusQ.Controls 0.1
|
import StatusQ.Controls 0.1
|
||||||
@ -9,14 +8,21 @@ import StatusQ.Core.Backpressure 0.1
|
|||||||
import StatusQ.Core.Theme 0.1
|
import StatusQ.Core.Theme 0.1
|
||||||
|
|
||||||
import AppLayouts.Onboarding2.controls 1.0
|
import AppLayouts.Onboarding2.controls 1.0
|
||||||
import AppLayouts.Onboarding.enums 1.0
|
|
||||||
|
|
||||||
import utils 1.0
|
import utils 1.0
|
||||||
|
|
||||||
KeycardBasePage {
|
KeycardBasePage {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
required property int authorizationState
|
enum State {
|
||||||
|
Idle,
|
||||||
|
InProgress,
|
||||||
|
Success,
|
||||||
|
WrongPin
|
||||||
|
}
|
||||||
|
|
||||||
|
required property int state
|
||||||
|
|
||||||
required property int remainingAttempts
|
required property int remainingAttempts
|
||||||
required property bool unblockWithPukAvailable
|
required property bool unblockWithPukAvailable
|
||||||
|
|
||||||
@ -25,17 +31,12 @@ KeycardBasePage {
|
|||||||
signal unblockWithPukRequested
|
signal unblockWithPukRequested
|
||||||
signal keycardFactoryResetRequested
|
signal keycardFactoryResetRequested
|
||||||
|
|
||||||
QtObject {
|
|
||||||
id: d
|
|
||||||
property string tempPin
|
|
||||||
}
|
|
||||||
|
|
||||||
StateGroup {
|
StateGroup {
|
||||||
|
id: states
|
||||||
states: [
|
states: [
|
||||||
State {
|
State { // entering
|
||||||
name: "entering"
|
when: root.state === KeycardEnterPinPage.State.Idle &&
|
||||||
when: root.authorizationState === Onboarding.ProgressState.Idle
|
root.remainingAttempts > 0
|
||||||
&& root.remainingAttempts > 0
|
|
||||||
|
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
target: root
|
target: root
|
||||||
@ -53,9 +54,8 @@ KeycardBasePage {
|
|||||||
source: Theme.png("onboarding/keycard/reading")
|
source: Theme.png("onboarding/keycard/reading")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
State {
|
State { // entering, wrong pin
|
||||||
name: "incorrect"
|
when: root.state === KeycardEnterPinPage.State.WrongPin
|
||||||
when: root.authorizationState === Onboarding.ProgressState.Failed
|
|
||||||
&& root.remainingAttempts > 0
|
&& root.remainingAttempts > 0
|
||||||
|
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
@ -78,10 +78,9 @@ KeycardBasePage {
|
|||||||
source: Theme.png("onboarding/keycard/error")
|
source: Theme.png("onboarding/keycard/error")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
State {
|
State { // in progress
|
||||||
name: "authorizing"
|
when: root.state === KeycardEnterPinPage.State.InProgress &&
|
||||||
when: root.authorizationState === Onboarding.ProgressState.InProgress
|
root.remainingAttempts > 0
|
||||||
&& root.remainingAttempts > 0
|
|
||||||
|
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
target: root
|
target: root
|
||||||
@ -101,9 +100,8 @@ KeycardBasePage {
|
|||||||
source: Theme.png("onboarding/keycard/reading")
|
source: Theme.png("onboarding/keycard/reading")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
State {
|
State { // success
|
||||||
name: "pinSuccess"
|
when: root.state === KeycardEnterPinPage.State.Success
|
||||||
when: root.authorizationState === Onboarding.ProgressState.Success
|
|
||||||
&& root.remainingAttempts > 0
|
&& root.remainingAttempts > 0
|
||||||
|
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
@ -120,8 +118,7 @@ KeycardBasePage {
|
|||||||
source: Theme.png("onboarding/keycard/success")
|
source: Theme.png("onboarding/keycard/success")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
State {
|
State { // blocked
|
||||||
name: "blocked"
|
|
||||||
when: root.remainingAttempts <= 0
|
when: root.remainingAttempts <= 0
|
||||||
|
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
@ -165,8 +162,9 @@ KeycardBasePage {
|
|||||||
pinLen: Constants.keycard.general.keycardPinLength
|
pinLen: Constants.keycard.general.keycardPinLength
|
||||||
validator: StatusIntValidator { bottom: 0; top: 999999 }
|
validator: StatusIntValidator { bottom: 0; top: 999999 }
|
||||||
onPinInputChanged: {
|
onPinInputChanged: {
|
||||||
if (pinInput.pinInput.length === pinInput.pinLen)
|
if (pinInput.pinInput.length === pinInput.pinLen) {
|
||||||
root.authorizationRequested(pinInput.pinInput)
|
root.authorizationRequested(pinInput.pinInput)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
StatusBaseText {
|
StatusBaseText {
|
||||||
@ -178,15 +176,6 @@ KeycardBasePage {
|
|||||||
color: Theme.palette.dangerColor1
|
color: Theme.palette.dangerColor1
|
||||||
visible: false
|
visible: false
|
||||||
},
|
},
|
||||||
StatusBaseText {
|
|
||||||
id: errorExportingText
|
|
||||||
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
|
||||||
text: qsTr("Error exporting the keys, please try again")
|
|
||||||
font.pixelSize: Theme.tertiaryTextFontSize
|
|
||||||
color: Theme.palette.dangerColor1
|
|
||||||
visible: false
|
|
||||||
},
|
|
||||||
StatusLoadingIndicator {
|
StatusLoadingIndicator {
|
||||||
id: loadingIndicator
|
id: loadingIndicator
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user