status-desktop/ui/imports/shared/popups/keycard/KeycardPopup.qml

105 lines
4.5 KiB
QML
Raw Normal View History

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: {
if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.setupNewKeycard) {
return qsTr("Set up a new Keycard with an existing account")
}
if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.factoryReset) {
return qsTr("Factory reset a Keycard")
}
if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.authentication) {
return qsTr("Authenticate")
}
if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.unlockKeycard) {
return qsTr("Unlock Keycard")
}
if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.displayKeycardContent) {
return qsTr("Check whats on a Keycard")
}
if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.renameKeycard) {
return qsTr("Rename Keycard")
}
if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.changeKeycardPin) {
return qsTr("Change pin")
}
if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.changeKeycardPuk) {
return qsTr("Create a 12-digit personal unblocking key (PUK)")
}
if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.changePairingCode) {
return qsTr("Create a new pairing code")
}
return ""
}
KeycardPopupDetails {
id: d
sharedKeycardModule: root.sharedKeycardModule
onDisablePopupCloseChanged: {
hasCloseButton = !disablePopupClose
}
}
onClosed: {
root.sharedKeycardModule.currentState.doTertiaryAction()
}
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
}