Add sample qml application
[staging/HomeScreen.git] / sample-qml / imports / components / NumberPad.qml
diff --git a/sample-qml/imports/components/NumberPad.qml b/sample-qml/imports/components/NumberPad.qml
new file mode 100644 (file)
index 0000000..b7763ca
--- /dev/null
@@ -0,0 +1,101 @@
+/* Copyright (C) 2015, Jaguar Land Rover. All Rights Reserved.\r
+ *\r
+ * This Source Code Form is subject to the terms of the Mozilla Public\r
+ * License, v. 2.0. If a copy of the MPL was not distributed with this\r
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\r
+\r
+import QtQuick 2.0\r
+import utils 1.0\r
+\r
+Item {\r
+    id: root\r
+    height: childrenRect.height\r
+    property var letters: ["","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"]\r
+    property var bottomRow: ["*","0","#"]\r
+\r
+    signal number(string number)\r
+\r
+    Grid {\r
+        id: numberGrid\r
+        columns: 3\r
+        spacing: 20\r
+\r
+        Repeater {\r
+            model: 9\r
+            delegate: Item {\r
+                id: numberKey\r
+                width: (root.width - ( numberGrid.spacing*(numberGrid.columns-1)))/numberGrid.columns\r
+                height: numberKey.width * 0.8\r
+                anchors.margins: 10\r
+\r
+                Rectangle {\r
+                    id: shadowTarget\r
+                    anchors.fill: parent\r
+                    border.width: 1\r
+                    border.color: "white"\r
+                    color: "#6653b5ce"\r
+                }\r
+\r
+                Item {\r
+                    height: childrenRect.height\r
+                    width: parent.width\r
+                    anchors.centerIn: parent\r
+\r
+                    Label {\r
+                        anchors.horizontalCenter: parent.horizontalCenter\r
+                        id: keypadNumber\r
+                        text: index + 1\r
+                    }\r
+\r
+                    Label {\r
+                        anchors.horizontalCenter: parent.horizontalCenter\r
+                        id: keypadLetters\r
+                        anchors.top: keypadNumber.bottom\r
+                        fontSize: 30\r
+                        fontColor: "#53b5ce"\r
+                        text: letters[index]\r
+                    }\r
+                }\r
+\r
+                MouseArea {\r
+                    anchors.fill: parent\r
+                    onClicked: root.number(keypadNumber.text)\r
+                }\r
+            }\r
+        }\r
+\r
+        Repeater {\r
+            model: 3\r
+            delegate: Item {\r
+                width: (root.width - ( numberGrid.spacing*(numberGrid.columns-1)))/numberGrid.columns\r
+                height: width * 0.8\r
+                anchors.margins: 10\r
+\r
+                Rectangle {\r
+                    id: shadowTarget\r
+                    anchors.fill: parent\r
+                    border.width: 1\r
+                    border.color: "white"\r
+                    color: "#6653b5ce"\r
+                }\r
+\r
+                Item {\r
+                    height: childrenRect.height\r
+                    width: parent.width\r
+                    anchors.centerIn: parent\r
+\r
+                    Label {\r
+                        anchors.horizontalCenter: parent.horizontalCenter\r
+                        id: keypadNumber\r
+                        text: bottomRow[index]\r
+                    }\r
+                }\r
+\r
+                MouseArea {\r
+                    anchors.fill: parent\r
+                    onClicked: root.number(keypadNumber.text)\r
+                }\r
+            }\r
+        }\r
+    }\r
+}\r