Add sample application[phone]
[staging/soundmanager.git] / sample / phone / app / ContactsView.qml
1 /*
2  * Copyright (C) 2016 The Qt Company Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 import QtQuick 2.6
18 import QtQuick.Layouts 1.1
19 import QtQuick.Controls 2.0
20 import AGL.Demo.Controls 1.0
21 import 'models'
22
23 Item {
24     id: root
25
26     signal call(var contact)
27     signal cancel
28
29     ListView {
30         anchors.fill: parent
31         header: Item {
32             width: parent.width
33             height: 200
34             RowLayout {
35                 anchors.fill: parent
36                 anchors.margins: 50
37                 Label {
38                     Layout.fillWidth: true
39                     text: 'Contacts'
40                 }
41                 ImageButton {
42                     offImage: './images/HMI_ContactScreen_X-01.svg'
43                     onClicked: root.cancel()
44                 }
45             }
46         }
47         model: ContactsModel {}
48         delegate: MouseArea {
49             width: ListView.view.width
50             height: width / 5
51             RowLayout {
52                 anchors.fill: parent
53                 anchors.leftMargin: 200
54                 spacing: 20
55                 Image {
56                     source: './images/HMI_ContactScreen_ImageHolder-01.svg'
57                 }
58                 ColumnLayout {
59                     Label {
60                         Layout.fillWidth: true
61                         color: '#59FF7F'
62                         text: model.name
63                     }
64
65                     Label {
66                         Layout.fillWidth: true
67                         font.pixelSize: 30
68                         text: model.number
69                     }
70                 }
71             }
72             onClicked: {
73                 root.call(model)
74             }
75         }
76         section.property: 'name'
77         section.criteria: ViewSection.FirstCharacter
78         section.delegate: Item {
79             Label {
80                 width: root.width / 5
81                 height: width
82                 horizontalAlignment: Text.AlignHCenter
83                 verticalAlignment: Text.AlignVCenter
84                 color: '#59FF7F'
85                 text: section
86             }
87         }
88     }
89 }