mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-10 05:36:23 +00:00
Since tertiary action for the keycard popup module is always used to cancel/invalidate the current flow, it's renamed now to cancel action (avoids confusion this way and it seems more intuitive. It doesn't set any state. It should be defined if it's possible to cancel the flow from the current state.
99 lines
4.0 KiB
QML
99 lines
4.0 KiB
QML
import QtQuick 2.14
|
||
import QtQuick.Controls 2.14
|
||
|
||
import StatusQ.Core 0.1
|
||
import StatusQ.Popups 0.1
|
||
|
||
import utils 1.0
|
||
|
||
StatusModal {
|
||
id: root
|
||
|
||
property var sharedKeycardModule
|
||
|
||
width: Constants.keycard.general.popupWidth
|
||
anchors.centerIn: parent
|
||
closePolicy: d.disablePopupClose? Popup.NoAutoClose : Popup.CloseOnEscape
|
||
|
||
header.title: {
|
||
switch (root.sharedKeycardModule.currentState.flowType) {
|
||
case Constants.keycardSharedFlow.setupNewKeycard:
|
||
return qsTr("Set up a new Keycard with an existing account")
|
||
case Constants.keycardSharedFlow.factoryReset:
|
||
return qsTr("Factory reset a Keycard")
|
||
case Constants.keycardSharedFlow.authentication:
|
||
return qsTr("Authenticate")
|
||
case Constants.keycardSharedFlow.unlockKeycard:
|
||
return qsTr("Unlock Keycard")
|
||
case Constants.keycardSharedFlow.displayKeycardContent:
|
||
return qsTr("Check what’s on a Keycard")
|
||
case Constants.keycardSharedFlow.renameKeycard:
|
||
return qsTr("Rename Keycard")
|
||
case Constants.keycardSharedFlow.changeKeycardPin:
|
||
return qsTr("Change pin")
|
||
case Constants.keycardSharedFlow.changeKeycardPuk:
|
||
return qsTr("Create a 12-digit personal unblocking key (PUK)")
|
||
case Constants.keycardSharedFlow.changePairingCode:
|
||
return qsTr("Create a new pairing code")
|
||
}
|
||
|
||
return ""
|
||
}
|
||
|
||
KeycardPopupDetails {
|
||
id: d
|
||
sharedKeycardModule: root.sharedKeycardModule
|
||
|
||
onDisablePopupCloseChanged: {
|
||
hasCloseButton = !disablePopupClose
|
||
}
|
||
}
|
||
|
||
onClosed: {
|
||
root.sharedKeycardModule.currentState.doCancelAction()
|
||
}
|
||
|
||
contentItem: StatusScrollView {
|
||
id: scrollView
|
||
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
||
width: parent.width
|
||
height: {
|
||
let availableSpace = Global.applicationWindow.height - (root.margins * 2 + root.topPadding + root.bottomPadding)
|
||
return Math.min(content.height, availableSpace)
|
||
}
|
||
|
||
KeycardPopupContent {
|
||
id: content
|
||
width: scrollView.availableWidth
|
||
height: {
|
||
if (!root.sharedKeycardModule.keyPairStoredOnKeycardIsKnown) {
|
||
if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.setupNewKeycard) {
|
||
if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay ||
|
||
root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.factoryResetConfirmationDisplayMetadata) {
|
||
return Constants.keycard.general.popupBiggerHeight
|
||
}
|
||
}
|
||
if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.factoryReset) {
|
||
if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay ||
|
||
root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.factoryResetConfirmationDisplayMetadata) {
|
||
return Constants.keycard.general.popupBiggerHeight
|
||
}
|
||
}
|
||
if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.displayKeycardContent) {
|
||
if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay) {
|
||
return Constants.keycard.general.popupBiggerHeight
|
||
}
|
||
}
|
||
}
|
||
return Constants.keycard.general.popupHeight
|
||
}
|
||
|
||
sharedKeycardModule: root.sharedKeycardModule
|
||
onPrimaryButtonEnabledChanged: d.primaryButtonEnabled = primaryButtonEnabled
|
||
}
|
||
}
|
||
|
||
leftButtons: d.leftButtons
|
||
rightButtons: d.rightButtons
|
||
}
|