1/*
2 * \copyright Copyright (c) 2015-2021 Governikus GmbH & Co. KG, Germany
3 */
4
5import QtQuick 2.12
6
7import Governikus.EnterPasswordView 1.0
8import Governikus.Global 1.0
9import Governikus.Style 1.0
10import Governikus.TitleBar 1.0
11import Governikus.ProgressView 1.0
12import Governikus.ResultView 1.0
13import Governikus.View 1.0
14import Governikus.Workflow 1.0
15import Governikus.Type.ApplicationModel 1.0
16import Governikus.Type.ChangePinModel 1.0
17import Governikus.Type.NumberModel 1.0
18
19
20SectionPage {
21	id: baseItem
22
23	title: changePinController.currentState === "" ?
24			//: LABEL ANDROID IOS
25			qsTr("Change my (Transport) PIN") :
26			NumberModel.requestTransportPin ?
27				//: LABEL ANDROID IOS
28				qsTr("Change Transport PIN") :
29				//: LABEL ANDROID IOS
30				qsTr("Change PIN")
31
32	navigationAction: NavigationAction {
33		state: "back"
34		onClicked: appWindow.close()
35	}
36
37	ChangePinController {
38		id: changePinController
39	}
40
41	Connections {
42		target: ChangePinModel
43		//: INFO ANDROID IOS The ID card has just been unblocked and the user can now continue with their PIN change.
44		onFireOnPinUnlocked: ApplicationModel.showFeedback(qsTr("Your PIN is unblocked. You now have three more attempts to change your PIN."))
45	}
46
47	ChangePinViewContent {
48		height: baseItem.height
49		width: baseItem.width
50		onNoPinAvailable: {
51			navBar.lockedAndHidden = true
52			firePush(noPinAvailableView)
53		}
54		onMoreInformationRequested: firePush(passwordInfoView)
55	}
56
57	GeneralWorkflow {
58		id: pinWorkflow
59		visible: false
60
61		controller: changePinController
62		workflowModel: ChangePinModel
63		workflowTitle: baseItem.title
64	}
65
66	ResultView {
67		id: noPinAvailableView
68
69		navigationAction: NavigationAction {
70			state: "cancel"
71			onClicked: {
72				firePop()
73				navBar.lockedAndHidden = false
74			}
75		}
76
77		visible: false
78
79		title: qsTr("No PIN available")
80		resultType: ResultView.Type.IsInfo
81		buttonText: ""
82		//: LABEL ANDROID IOS
83		text: qsTr("You cannot find your PIN letter? You have set a PIN when picking up the ID card or later that you cannot recall now?\n\nIf this is the case please turn to the competent authority and set a new PIN there.")
84	}
85
86	PasswordInfoView {
87		id: passwordInfoView
88
89		visible: false
90
91		navigationAction: NavigationAction { state: "back"; onClicked: firePop() }
92	}
93
94	ResultView {
95		id: cardPositionView
96		navigationAction: NavigationAction { state: "cancel"; onClicked: ChangePinModel.cancelWorkflow() }
97		title: baseItem.title
98		resultType: ResultView.Type.IsInfo
99		//: LABEL ANDROID IOS
100		buttonText: qsTr("Retry")
101		//: INFO ANDROID IOS The NFC signal is weak or unstable, the user is asked to change the card's position to (hopefully) reduce the distance to the NFC chip.
102		text: qsTr("Weak NFC signal. Please\n- change the card position\n- remove the mobile phone case (if present)\n- connect the smartphone with a charging cable")
103		onClicked: {
104			firePop()
105			ChangePinModel.continueWorkflow()
106		}
107		visible: false
108	}
109
110	ResultView {
111		id: pinResult
112		title: baseItem.title
113		resultType: ChangePinModel.error ? ResultView.Type.IsError : ResultView.Type.IsSuccess
114		text: ChangePinModel.resultString
115		onClicked: {
116			ChangePinModel.continueWorkflow()
117			firePopAll()
118			navBar.lockedAndHidden = false
119		}
120		visible: false
121	}
122
123	EnterPasswordView {
124		id: enterPinView
125		navigationAction: NavigationAction { state: "cancel"; onClicked: ChangePinModel.cancelWorkflow() }
126		//: LABEL ANDROID IOS
127		title: qsTr("Change PIN")
128		visible: false
129
130		onPasswordEntered: {
131			pinProgressView.wasNewPin = pWasNewPin
132			firePop()
133			ChangePinModel.continueWorkflow()
134		}
135	}
136
137	ProgressView {
138		id: pinProgressView
139
140		property bool wasNewPin
141
142		navigationAction: NavigationAction {
143			state: ChangePinModel.isBasicReader ? "cancel" : "";
144			onClicked: ChangePinModel.cancelWorkflow()
145		}
146		title: baseItem.title
147		visible: false
148		text: wasNewPin
149			//: LABEL ANDROID IOS Processing screen label while the card communication is running after the new PIN has been entered during PIN change process.
150			? qsTr("Setting new PIN")
151			//: LABEL ANDROID IOS Processing screen label while the card communication is running before the new PIN has been entered during PIN change process.
152			: qsTr("Change PIN")
153		subText: (!visible ? ""
154				 //: INFO ANDROID IOS Loading screen during PIN change process, data communcation is currently ongoing. Message is usually not visible since the password handling with basic reader is handled by EnterPasswordView.
155			   : ChangePinModel.isBasicReader ? qsTr("Please do not move the ID card.")
156			   : !!NumberModel.inputError ? NumberModel.inputError
157				 //: INFO ANDROID IOS The card communcation was aborted, the online identification functionality is deactivated and needs to be actived by the authorities.
158			   : NumberModel.pinDeactivated ? qsTr("The online identification function of your ID card is not activated. Please contact your responsible authority to activate the online identification function.")
159			   : changePinController.workflowState === ChangePinController.WorkflowStates.Update
160				 || changePinController.workflowState === ChangePinController.WorkflowStates.Pin
161				 //: INFO ANDROID IOS Either an comfort card reader or smartphone-as-card-reader is used, the user needs to react to request on that device.
162				 || changePinController.workflowState === ChangePinController.WorkflowStates.NewPin ? qsTr("Please observe the display of your card reader.")
163				 //: INFO ANDROID IOS The wrong PIN was entered twice, the next attempt requires additional verifcation via CAN.
164			   : changePinController.workflowState === ChangePinController.WorkflowStates.Can ? qsTr("A wrong PIN has been entered twice on your ID card. For a third attempt, please first enter the six-digit Card Access Number (CAN). You can find your Card Access Number (CAN) in the bottom right on the front of your ID card.")
165				 //: INFO ANDROID IOS The PIN (including the CAN) was entered wrongfully three times, the PUK is required to unlock the ID card.
166			   : changePinController.workflowState === ChangePinController.WorkflowStates.Puk ? qsTr("A wrong PIN has been entered three times on your ID card. Your PIN is now blocked. To unblock your PIN you have to enter the PUK.")
167				 //: INFO ANDROID IOS Generic progress message during PIN change process.
168			   : qsTr("Please do not move the ID card."))
169		subTextColor: !ChangePinModel.isBasicReader && (NumberModel.inputError
170														|| NumberModel.pinDeactivated
171														|| changePinController.workflowState === ChangePinController.WorkflowStates.Can
172														|| changePinController.workflowState === ChangePinController.WorkflowStates.Puk) ? Constants.red : Style.color.secondary_text
173	}
174}
175