2017-07-03 09:33:28 +02:00
import QtQuick 2.5
import QtQuick . Layouts 1.1
2017-12-20 14:54:05 +01:00
import Governikus . Global 1.0
2017-07-03 09:33:28 +02:00
SectionPage
{
id: baseItem
2018-03-28 15:10:51 +02:00
property string remoteDeviceId: ""
2017-07-03 09:33:28 +02:00
signal pinEntered ( )
onVisibleChanged: {
pinField . text = ""
if ( state !== "PIN_NEW_AGAIN" ) {
pinField . inputConfirmation = ""
}
}
ColumnLayout
{
anchors.fill: parent
Item { /*spacer*/ Layout.fillHeight: true ; width: parent . width }
RowLayout {
spacing: Constants . component_spacing
width: parent . width
Item { /*spacer*/ Layout.fillWidth: true ; height: parent . height }
Image {
anchors.verticalCenter: parent . verticalCenter
width: Utils . dp ( 58 )
height: width
2018-03-28 15:10:51 +02:00
// because RowLayout uses implicitHeight that is based on sourceSize we have to explicitly set the sourceSize
sourceSize.height: baseItem . state === "REMOTE_PIN" ? Utils . dp ( 58 ) : 143
2017-07-03 09:33:28 +02:00
Layout.maximumWidth: width
2018-03-28 15:10:51 +02:00
source: baseItem . state === "REMOTE_PIN" ? "qrc:///images/icon_remote.svg" : "qrc:///images/NFCPhoneCard.png"
2017-07-03 09:33:28 +02:00
fillMode: Image . PreserveAspectFit
}
Text {
anchors.verticalCenter: parent . verticalCenter
Layout.fillWidth: true
Layout.maximumWidth: Math . ceil ( implicitWidth )
wrapMode: Text . WordWrap
font.pixelSize: text . length > 150 && ! PlatformConstants . is_tablet ? Utils . dp ( 15 ) : Constants . header_font_size
font.bold: true
color: {
if ( ! pinField . confirmedInput || ! ! numberModel . inputError || baseItem . state === "CAN" || baseItem . state === "PUK" ) {
Constants . red
} else {
Constants . blue
}
}
2017-12-20 14:54:05 +01:00
text: ( ! pinField . confirmedInput ? qsTr ( "The entered PIN does not match the new PIN. Please correct your input." ) :
! ! numberModel . inputError ? numberModel.inputError :
baseItem . state === "CAN" ? qsTr ( "You have entered the wrong PIN twice. Prior to a third attempt, you have to enter your six-digit card access number first. You can find your card access number on the front of your ID card." ) :
baseItem . state === "PUK" ? qsTr ( "You have entered a wrong PIN three times. Your PIN is now blocked. You have to enter the PUK now for unblocking." ) :
baseItem . state === "PIN_NEW" ? qsTr ( "Please enter a new 6-digit PIN of your choice." ) :
baseItem . state === "PIN_NEW_AGAIN" ? qsTr ( "Please enter your new 6-digit PIN again." ) :
baseItem . state === "PIN" ? qsTr ( "Please enter your personal PIN." ) :
2018-03-28 15:10:51 +02:00
baseItem . state === "REMOTE_PIN" ? qsTr ( "Enter the pairing code shown on your other device to use it as a card reader." ) :
2017-12-20 14:54:05 +01:00
/*"PIN_OR_TRANSPORT_PIN"*/ qsTr ( "Please enter your current PIN or your initial transport PIN first." )
) + settingsModel . translationTrigger
2017-07-03 09:33:28 +02:00
}
Item { /*spacer*/ Layout.fillWidth: true ; height: parent . height }
}
Item { /*spacer*/ Layout.fillHeight: true ; width: parent . width }
PinField {
id: pinField
anchors.horizontalCenter: parent . horizontalCenter
state: baseItem . state
Layout.preferredWidth: width
}
Item { /*spacer*/ height: Constants . component_spacing ; width: parent . width }
PinPad {
anchors.horizontalCenter: parent . horizontalCenter
state: baseItem . state
Layout.preferredWidth: width
Layout.preferredHeight: height
submitEnabled: pinField . validInput
deleteEnabled: pinField . text . length > 0
onDigitPressed: pinField . append ( digit )
onDeletePressed: pinField . removeLast ( )
onSubmitPressed: {
switch ( baseItem . state ) {
case "PIN" :
/* fall through */
case "PIN_OR_TRANSPORT_PIN" :
numberModel . pin = pinField . text
baseItem . pinEntered ( )
break
case "PIN_NEW" :
pinField . inputConfirmation = pinField . text
pinField . text = ""
baseItem . state = "PIN_NEW_AGAIN"
break
case "PIN_NEW_AGAIN" :
numberModel . newPin = pinField . text
baseItem . pinEntered ( )
break
case "CAN" :
numberModel . can = pinField . text
baseItem . pinEntered ( )
break
case "PUK" :
numberModel . puk = pinField . text
baseItem . pinEntered ( )
break
2018-03-28 15:10:51 +02:00
case "REMOTE_PIN" :
remoteServiceModel . connectToServer ( remoteDeviceId , pinField . text )
baseItem . pinEntered ( )
break
2017-07-03 09:33:28 +02:00
}
}
}
Item { /*spacer*/ Layout.fillHeight: true ; width: parent . width }
}
}