@@ -19,16 +19,12 @@ import Ubuntu.Components 0.1
19import Ubuntu.Components.ListItems 0.1
19import Ubuntu.Components.ListItems 0.1
20import "../Components"
20import "../Components"
27 property string infoText
25 property string infoText
28 property string retryText
26 property string retryText
29 property string errorText
27 property string errorText
30− property int padWidth: units.gu(34)
31− property int padHeight: units.gu(28)
32 property int minPinLength: -1
28 property int minPinLength: -1
33 property int maxPinLength: -1
29 property int maxPinLength: -1
34 property bool showCancelButton: true
30 property bool showCancelButton: true
@@ -49,123 +45,151 @@ Column {
52− id: shakeContainer
48+ anchors {
53− anchors.horizontalCenter: parent.horizontalCenter
49+ left: parent.left;
54− width: parent.width
50+ right: parent.right;
55− spacing: units.gu(1)
51+ verticalCenter: parent.verticalCenter;
56−
52+ verticalCenterOffset: Math.max(-units.gu(10), -(root.height - height) / 2) + units.gu(4)
59− objectName: "infoTextLabel"
62− anchors.horizontalCenter: parent.horizontalCenter
67− id: pinContainer
57+ id: shakeContainer
68− anchors { left: parent.left; right: parent.right; margins: units.gu(2) }
58+ anchors.horizontalCenter: parent.horizontalCenter
69− height: units.gu(4)
60+ spacing: units.gu(1)
72− id: pinentryField
63+ id: infoField
73− objectName: "pinentryField"
64+ objectName: "infoTextLabel"
74 anchors.horizontalCenter: parent.horizontalCenter
67 anchors.horizontalCenter: parent.horizontalCenter
75− anchors.verticalCenter: parent.verticalCenter
68+ text: root.infoText
76− spacing: Math.max(0, Math.min(units.gu(3), (parent.width / root.maxPinLength) - units.gu(3)))
69+ }
73+ anchors { left: parent.left; right: parent.right; margins: units.gu(2) }
78+ objectName: "pinentryField"
79+ anchors.horizontalCenter: parent.horizontalCenter
80+ anchors.verticalCenter: parent.verticalCenter
81+ spacing: Math.max(0, Math.min(units.gu(3), (parent.width / root.maxPinLength) - units.gu(3)))
78− property string text
83+ property string text
79− property bool incorrectOverride: false
84+ property bool incorrectOverride: false
87+ model: pinentryField.text.length
88+ delegate: Rectangle {
90+ width: Math.min(units.gu(2), (pinContainer.width - pinContainer.height*2 ) / (root.maxPinLength >= 0 ? root.maxPinLength : 16))
81− Repeater {
96+ function appendNumber(number) {
97+ if (incorrectOverride) {
98+ incorrectOverride = false;
82− model: pinentryField.text.length
101+ pinentryField.text = pinentryField.text + number
83− delegate: Rectangle {
102+
84− color: "#f3f3e7"
103+ if (root.minPinLength > 0 && root.maxPinLength > 0
85− width: Math.min(units.gu(2), (pinContainer.width - pinContainer.height*2 ) / (root.maxPinLength >= 0 ? root.maxPinLength : 16))
104+ && root.minPinLength == root.maxPinLength && pinentryField.text.length == root.minPinLength) {
86− height: width
105+ root.entered(pinentryField.text)
87− radius: width / 2
106+ }
109+ function backspace() {
110+ pinentryField.text = pinentryField.text.substring(0, pinentryField.text.length-1)
114+ id: wrongNoticeLabel
115+ objectName: "wrongNoticeLabel"
118+ anchors.horizontalCenter: parent.horizontalCenter
119+ horizontalAlignment: Text.AlignHCenter
120+ text: root.errorText
121+ visible: pinentryField.incorrectOverride
122+ scale: Math.min(1, parent.width / width)
126+ objectName: "backspaceIcon"
127+ anchors { right: parent.right; top: parent.top; bottom: parent.bottom }
129+ enabled: root.entryEnabled
91− function appendNumber(number) {
131+ Icon {
92− if (incorrectOverride) {
132+ anchors.fill: parent
93− incorrectOverride = false;
133+ name: "erase"
96− pinentryField.text = pinentryField.text + number
137+ opacity: (pinentryField.text.length > 0 && !pinentryField.incorrectOverride) ? 1 : 0
98− if (root.minPinLength > 0 && root.maxPinLength > 0
139+ Behavior on opacity {
99− && root.minPinLength == root.maxPinLength && pinentryField.text.length == root.minPinLength) {
140+ UbuntuNumberAnimation {}
100− root.entered(pinentryField.text)
104− function backspace() {
143+ onClicked: pinentryField.backspace()
105− pinentryField.text = pinentryField.text.substring(0, pinentryField.text.length-1)
109− id: wrongNoticeLabel
110− objectName: "wrongNoticeLabel"
148+ objectName: "retryLabel"
111− fontSize: "x-large"
149+ fontSize: "x-small"
112 color: "#f3f3e7"
150 color: "#f3f3e7"
113 anchors.horizontalCenter: parent.horizontalCenter
151 anchors.horizontalCenter: parent.horizontalCenter
114− horizontalAlignment: Text.AlignHCenter
115− text: root.errorText
152+ text: root.retryText || " "
116− visible: pinentryField.incorrectOverride
117− scale: Math.min(1, parent.width / width)
121− objectName: "backspaceIcon"
122− anchors { right: parent.right; top: parent.top; bottom: parent.bottom }
124− enabled: root.entryEnabled
127− anchors.fill: parent
132− opacity: (pinentryField.text.length > 0 && !pinentryField.incorrectOverride) ? 1 : 0
134− Behavior on opacity {
135− UbuntuNumberAnimation {}
138− onClicked: pinentryField.backspace()
142− Label {
156+ ThinDivider {
143− objectName: "retryLabel"
157+ anchors { left: parent.left; right: parent.right; margins: units.gu(2) }
146− anchors.horizontalCenter: parent.horizontalCenter
147− text: root.retryText || " "
152− anchors { left: parent.left; right: parent.right; margins: units.gu(2) }
157− anchors { horizontalCenter: parent.horizontalCenter }
160− property int buttonHeight: units.gu(8)
161− property int buttonWidth: units.gu(12)
162+ objectName: "numbersGrid"
163+ anchors { horizontalCenter: parent.horizontalCenter }
166+ property int maxWidth: Math.min(units.gu(50), root.width - units.gu(8))
167+ property int buttonWidth: maxWidth / 3
168+ property int buttonHeight: buttonWidth * 2 / 3
174+ objectName: "pinPadButton" + text
176+ height: numbersGrid.buttonHeight
177+ width: numbersGrid.buttonWidth
178+ enabled: root.entryEnabled && (root.maxPinLength == -1 ||
179+ pinentryField.text.length < root.maxPinLength ||
180+ pinentryField.incorrectOverride)
183+ pinentryField.appendNumber(index + 1)
188+ height: numbersGrid.buttonHeight
189+ width: numbersGrid.buttonWidth
166 PinPadButton {
191 PinPadButton {
167− objectName: "pinPadButton" + text
192+ text: "0"
169 height: numbersGrid.buttonHeight
193 height: numbersGrid.buttonHeight
170 width: numbersGrid.buttonWidth
194 width: numbersGrid.buttonWidth
171 enabled: root.entryEnabled && (root.maxPinLength == -1 ||
195 enabled: root.entryEnabled && (root.maxPinLength == -1 ||
@@ -173,56 +197,41 @@ Column {
173 pinentryField.incorrectOverride)
197 pinentryField.incorrectOverride)
175 onClicked: {
199 onClicked: {
176− pinentryField.appendNumber(index + 1)
200+ pinentryField.appendNumber(0)
181− height: numbersGrid.buttonHeight
182− width: numbersGrid.buttonWidth
186− height: numbersGrid.buttonHeight
204+ height: numbersGrid.buttonHeight
187− width: numbersGrid.buttonWidth
205+ width: numbersGrid.buttonWidth
188− enabled: root.entryEnabled && (root.maxPinLength == -1 ||
189− pinentryField.text.length < root.maxPinLength ||
190− pinentryField.incorrectOverride)
193− pinentryField.appendNumber(0)
197− height: numbersGrid.buttonHeight
198− width: numbersGrid.buttonWidth
200− PinPadButton {
207+ PinPadButton {
201− iconName: "close"
208+ iconName: "close"
202− height: units.gu(5) // visual spec has this row a little closer in
209+ height: units.gu(5) // visual spec has this row a little closer in
203− width: numbersGrid.buttonWidth
210+ width: numbersGrid.buttonWidth
205− onClicked: root.cancel()
212+ onClicked: root.cancel()
206− visible: root.showCancelButton
213+ visible: root.showCancelButton
209− height: units.gu(5)
216+ height: units.gu(5)
217+ width: numbersGrid.buttonWidth
221+ objectName: "confirmButton"
210− width: numbersGrid.buttonWidth
223+ width: numbersGrid.buttonWidth
224+ enabled: root.enabled && pinentryField.text.length >= root.minPinLength
225+ visible: root.minPinLength == -1 || root.minPinLength !== root.maxPinLength
227+ onClicked: root.entered(pinentryField.text)
212− PinPadButton {
230+ WrongPasswordAnimation {
213− iconName: "tick"
231+ id: wrongPasswordAnimation
214− objectName: "confirmButton"
232+ objectName: "wrongPasswordAnimation"
215− height: units.gu(5)
233+ target: shakeContainer
216− width: numbersGrid.buttonWidth
217− enabled: root.enabled && pinentryField.text.length >= root.minPinLength
218− visible: root.minPinLength == -1 || root.minPinLength !== root.maxPinLength
220− onClicked: root.entered(pinentryField.text)
223− WrongPasswordAnimation {
224− id: wrongPasswordAnimation
225− objectName: "wrongPasswordAnimation"
226− target: shakeContainer