mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-24 04:28:58 +00:00
- integrate it into the UI and StoryBook - a new keycardState is introduced: `FactoryResetting` (matching the backend) - a new store method introduced: `startKeycardFactoryReset()` Fixes: #17094
109 lines
3.8 KiB
QML
109 lines
3.8 KiB
QML
import QtQuick 2.15
|
|
import QtQuick.Controls 2.15
|
|
|
|
import StatusQ.Core 0.1
|
|
import StatusQ.Controls 0.1
|
|
import StatusQ.Components 0.1
|
|
import StatusQ.Core.Theme 0.1
|
|
import StatusQ.Core.Utils 0.1 as SQUtils
|
|
|
|
import AppLayouts.Onboarding2.pages 1.0
|
|
import AppLayouts.Onboarding.enums 1.0
|
|
|
|
SQUtils.QObject {
|
|
id: root
|
|
|
|
required property StackView stackView
|
|
required property int keycardState
|
|
|
|
signal performKeycardFactoryResetRequested
|
|
|
|
signal finished
|
|
|
|
function init(fromLoginScreen = false) {
|
|
d.fromLoginScreen = fromLoginScreen
|
|
root.stackView.push(d.initialComponent())
|
|
}
|
|
|
|
QtObject {
|
|
id: d
|
|
|
|
property bool fromLoginScreen
|
|
|
|
function initialComponent() {
|
|
if (root.keycardState === Onboarding.KeycardState.FactoryResetting)
|
|
return keycardResetPageComponent
|
|
return keycardResetAcks
|
|
}
|
|
}
|
|
|
|
Component {
|
|
id: keycardResetAcks
|
|
|
|
KeycardBasePage {
|
|
image.source: Theme.png("onboarding/keycard/reading")
|
|
title: qsTr("Factory reset Keycard")
|
|
subtitle: "<font color='%1'>".arg(Theme.palette.dangerColor1) +
|
|
qsTr("All data including the stored key pair and derived accounts will be removed from the Keycard") +
|
|
"</font>"
|
|
buttons: [
|
|
StatusCheckBox {
|
|
id: ack
|
|
width: Math.min(implicitWidth, parent.width)
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
text: qsTr("I understand the key pair will be deleted")
|
|
},
|
|
Item {
|
|
width: parent.width
|
|
height: parent.spacing
|
|
},
|
|
StatusButton {
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
type: StatusBaseButton.Type.Danger
|
|
text: qsTr("Factory reset this Keycard")
|
|
enabled: ack.checked
|
|
onClicked: {
|
|
root.performKeycardFactoryResetRequested()
|
|
root.stackView.replace(null, keycardResetPageComponent)
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
|
|
Component {
|
|
id: keycardResetPageComponent
|
|
|
|
KeycardBasePage {
|
|
id: keycardResetPage
|
|
readonly property bool resetting: root.keycardState === Onboarding.KeycardState.FactoryResetting
|
|
|
|
image.source: resetting ? Theme.png("onboarding/keycard/empty") // FIXME correct image
|
|
: Theme.png("onboarding/keycard/success")
|
|
title: resetting ? qsTr("Reseting Keycard") : qsTr("Keycard successfully factory reset")
|
|
subtitle: resetting ? "" : qsTr("You can now use this Keycard like it's a brand-new, empty Keycard")
|
|
infoText.text: resetting ? qsTr("Do not remove your Keycard or reader") : ""
|
|
buttons: [
|
|
Row {
|
|
spacing: 4
|
|
visible: keycardResetPage.resetting
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
StatusLoadingIndicator {
|
|
color: Theme.palette.directColor1
|
|
}
|
|
StatusBaseText {
|
|
text: qsTr("Please wait while the Keycard is being reset")
|
|
}
|
|
},
|
|
StatusButton {
|
|
visible: !keycardResetPage.resetting
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
width: 320
|
|
text: d.fromLoginScreen ? qsTr("Back to Login screen") : qsTr("Log in or Create profile")
|
|
onClicked: root.finished()
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|