2024-10-15 19:26:12 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
import QtQuick.Controls 2.15
|
2022-10-12 17:08:59 +00:00
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2022-12-16 09:37:08 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as StatusQUtils
|
2022-10-12 17:08:59 +00:00
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import "../helpers"
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property var sharedKeycardModule
|
|
|
|
|
|
|
|
signal validation(bool result)
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
property bool entryValid: false
|
|
|
|
|
|
|
|
function updateValidity() {
|
2022-12-16 09:37:08 +00:00
|
|
|
d.entryValid = root.sharedKeycardModule.keyPairForProcessing.name.trim().length > 0
|
|
|
|
if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.renameKeycard) {
|
|
|
|
d.entryValid = d.entryValid && root.sharedKeycardModule.keyPairForProcessing.name !== root.sharedKeycardModule.getNameFromKeycard()
|
|
|
|
}
|
2022-10-12 17:08:59 +00:00
|
|
|
root.validation(d.entryValid)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
2022-12-26 12:52:21 +00:00
|
|
|
if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.setupNewKeycardNewSeedPhrase ||
|
|
|
|
root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.setupNewKeycardOldSeedPhrase) {
|
2022-12-16 09:37:08 +00:00
|
|
|
if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.enterKeycardName) {
|
|
|
|
if (root.sharedKeycardModule.keyPairForProcessing.name.trim() !== "") {
|
|
|
|
d.updateValidity()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-05-22 15:55:47 +00:00
|
|
|
let color = Theme.palette.customisationColorsArray[Math.floor(Math.random() * Theme.palette.customisationColorsArray.length)]
|
2024-08-15 17:36:32 +00:00
|
|
|
let emoji = StatusQUtils.Emoji.getRandomEmoji(StatusQUtils.Emoji.size.verySmall) // TODO: Reuse status-go RandomWalletEmoji
|
2022-12-16 09:37:08 +00:00
|
|
|
root.sharedKeycardModule.keyPairForProcessing.observedAccount.name = " "
|
2023-05-22 15:55:47 +00:00
|
|
|
root.sharedKeycardModule.keyPairForProcessing.observedAccount.colorId = Utils.getIdForColor(color)
|
2022-12-16 09:37:08 +00:00
|
|
|
root.sharedKeycardModule.keyPairForProcessing.observedAccount.emoji = emoji
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
d.updateValidity()
|
2022-10-12 17:08:59 +00:00
|
|
|
keycardName.input.edit.forceActiveFocus()
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.topMargin: Theme.xlPadding
|
|
|
|
anchors.bottomMargin: Theme.halfPadding
|
|
|
|
anchors.leftMargin: Theme.xlPadding
|
|
|
|
anchors.rightMargin: Theme.xlPadding
|
|
|
|
spacing: Theme.padding
|
2022-10-12 17:08:59 +00:00
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: title
|
|
|
|
Layout.alignment: Qt.AlignCenter
|
|
|
|
font.weight: Font.Bold
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusInput {
|
|
|
|
id: keycardName
|
|
|
|
Layout.preferredWidth: Constants.keycard.general.keycardNameInputWidth
|
|
|
|
Layout.alignment: Qt.AlignCenter
|
|
|
|
charLimit: Constants.keycard.general.keycardNameLength
|
2022-12-16 09:37:08 +00:00
|
|
|
text: root.sharedKeycardModule.keyPairForProcessing.name
|
2022-10-12 17:08:59 +00:00
|
|
|
input.acceptReturn: true
|
|
|
|
|
|
|
|
onTextChanged: {
|
2022-12-16 09:37:08 +00:00
|
|
|
root.sharedKeycardModule.keyPairForProcessing.name = text
|
2022-10-12 17:08:59 +00:00
|
|
|
d.updateValidity()
|
|
|
|
}
|
|
|
|
|
|
|
|
onKeyPressed: {
|
|
|
|
if (d.entryValid &&
|
|
|
|
(input.edit.keyEvent === Qt.Key_Return ||
|
|
|
|
input.edit.keyEvent === Qt.Key_Enter)) {
|
|
|
|
event.accepted = true
|
|
|
|
root.sharedKeycardModule.currentState.doPrimaryAction()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.alignment: Qt.AlignLeft
|
|
|
|
text: qsTr("Preview")
|
|
|
|
font.pixelSize: Constants.keycard.general.fontSize2
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
}
|
|
|
|
|
|
|
|
KeyPairItem {
|
|
|
|
Layout.preferredWidth: parent.width
|
2022-12-16 09:37:08 +00:00
|
|
|
keyPairType: root.sharedKeycardModule.keyPairForProcessing.pairType
|
2023-05-18 18:28:46 +00:00
|
|
|
keyPairKeyUid: root.sharedKeycardModule.keyPairForProcessing.keyUid
|
2022-12-16 09:37:08 +00:00
|
|
|
keyPairName: root.sharedKeycardModule.keyPairForProcessing.name
|
|
|
|
keyPairIcon: root.sharedKeycardModule.keyPairForProcessing.icon
|
|
|
|
keyPairImage: root.sharedKeycardModule.keyPairForProcessing.image
|
|
|
|
keyPairDerivedFrom: root.sharedKeycardModule.keyPairForProcessing.derivedFrom
|
|
|
|
keyPairAccounts: root.sharedKeycardModule.keyPairForProcessing.accounts
|
|
|
|
keyPairCardLocked: root.sharedKeycardModule.keyPairForProcessing.locked
|
2022-10-12 17:08:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: Constants.keycardSharedState.enterKeycardName
|
|
|
|
when: root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.enterKeycardName
|
|
|
|
PropertyChanges {
|
|
|
|
target: title
|
2022-12-16 09:37:08 +00:00
|
|
|
text: {
|
|
|
|
if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.renameKeycard) {
|
|
|
|
qsTr("Rename this Keycard")
|
|
|
|
}
|
|
|
|
|
|
|
|
return qsTr("Name this Keycard")
|
|
|
|
}
|
2022-10-12 17:08:59 +00:00
|
|
|
font.pixelSize: Constants.keycard.general.fontSize1
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
2022-12-16 09:37:08 +00:00
|
|
|
PropertyChanges {
|
|
|
|
target: keycardName
|
|
|
|
placeholderText: {
|
|
|
|
if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.renameKeycard) {
|
|
|
|
return qsTr("Keycard name")
|
|
|
|
}
|
|
|
|
|
|
|
|
return qsTr("What would you like this Keycard to be called?")
|
|
|
|
}
|
|
|
|
}
|
2022-10-12 17:08:59 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|