summaryrefslogtreecommitdiffstats
path: root/examples/declarative/contacts/contacts.qml
blob: fa50010c39b9ce1bef2c6502af1b3b0775a03d40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
Rect {
    id: page
    width: 320
    height: 480
    color: "white"
    resources: [
        Component {
            id: contactDelegate
            Rect {
                id: wrapper
                x: 20
                width: List.width-40
                color: "#FEFFEE"
                pen.color: "#FFBE4F"
                radius: 5
                filter: Shadow {
                    xOffset: 5
                    yOffset: 5
                }
                MouseRegion {
                    id: pageMouse
                    anchors.fill: parent
                    onClicked: { if (wrapper.state == 'Details') { wrapper.state = '';} else {wrapper.state = 'Details';} }
                }
                Image {
                    id: portraitPic
                    src: portrait
                    x: 10
                    y: 10
                }
                Text {
                    id: name
                    text: firstName + ' ' + lastName
                    anchors.left: portraitPic.right
                    anchors.leftMargin: 10
                    anchors.top: portraitPic.top
                    anchors.right: wrapper.right
                    anchors.rightMargin: 10
                    font.family: "Comic Sans MS"
                    font.bold: true
                    font.size: 11
                }
                VerticalLayout {
                    id: email_layout
                    anchors.left: name.left
                    anchors.top: name.bottom
                    anchors.topMargin: 10
                    Repeater {
                        id: email_list
                        dataSource: emails
                        Component {
                            Text {
                                text: modelData
                                height: 18
                                font.italic: true
                                color: "midnightblue"
                            }
                        }
                    }
                }
                height: Math.max(email_layout.height + name.height + 25, portraitPic.height+20)
                states: [
                    State {
                        name: "Details"
                        SetProperty {
                            target: wrapper
                            property: "color"
                            value: "white"
                        }
                        SetProperty {
                            target: wrapper
                            property: "x"
                            value: 0
                        }
                        SetProperty {
                            target: wrapper
                            property: "height"
                            value: List.height
                        }
                        SetProperty {
                            target: wrapper
                            property: "width"
                            value: List.width
                        }
                        SetProperty {
                            target: wrapper.ListView.view
                            property: "yPosition"
                            value: wrapper.y
                        }
                        SetProperty {
                            target: wrapper.ListView.view
                            property: "locked"
                            value: 1
                        }
                    }
                ]
                transitions: [
                    Transition {
                        ParallelAnimation {
                            ColorAnimation {
                                duration: 500
                            }
                            NumericAnimation {
                                duration: 150
                                properties: "x,yPosition,height,width"
                            }
                        }
                    }
                ]
            }
        }
    ]
    ListView {
        id: List
        model: contactModel
        width: 320
        height: 480
        clip: true
        delegate: contactDelegate
    }
}