Skip to content

Commit 98dc036

Browse files
committed
Add List Item demo, working on a Simple Menu list item
1 parent fbcb35b commit 98dc036

File tree

4 files changed

+87
-1
lines changed

4 files changed

+87
-1
lines changed

demo/ListItemsDemo.qml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import QtQuick 2.0
2+
import Material 0.1
3+
import Material.ListItems 0.1 as ListItem
4+
import Material.Extras 0.1
5+
6+
Item {
7+
View {
8+
anchors {
9+
fill: parent
10+
margins: units.dp(32)
11+
}
12+
13+
elevation: 1
14+
15+
Column {
16+
anchors.fill: parent
17+
18+
ListItem.Header {
19+
text: "Section header"
20+
}
21+
22+
ListItem.Standard {
23+
text: "Standard list item"
24+
}
25+
26+
ListItem.Subtitled {
27+
text: "Subtitled list item"
28+
subText: "With some subtext!"
29+
}
30+
31+
ListItem.SimpleMenu {
32+
text: "Subtitled list item"
33+
model: ["A", "B", "C"]
34+
}
35+
}
36+
}
37+
}

demo/main.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ApplicationWindow {
1111

1212
initialPage: page
1313

14-
property var components: ["Button", "Switch", "Radio Button", "Slider", "Progress Bar", "Icon", "TextField", "Page Stack"]
14+
property var components: ["Button", "Switch", "Radio Button", "Slider", "Progress Bar", "Icon", "TextField", "Page Stack", "List Items"]
1515
property string selectedComponent: components[0]
1616

1717
Page {
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import QtQuick 2.0
2+
import Material 0.1
3+
4+
Subtitled {
5+
id: listItem
6+
7+
property alias model: listView.model
8+
property alias selectedIndex: listView.currentIndex
9+
10+
subText: listView.currentItem.text
11+
12+
onTriggered: menu.open(listItem, units.dp(16), 0)
13+
14+
Dropdown {
15+
id: menu
16+
17+
anchor: Item.TopLeft
18+
19+
width: Math.max(units.dp(56 * 2), Math.min(listItem.width - 2 * x, listView.contentWidth))
20+
height: Math.min(10 * units.dp(48) + units.dp(16), listView.contentHeight + units.dp(16))
21+
22+
ListView {
23+
id: listView
24+
25+
anchors {
26+
left: parent.left
27+
right: parent.right
28+
top: parent.top
29+
topMargin: units.dp(8)
30+
}
31+
32+
interactive: false
33+
height: contentHeight
34+
35+
delegate: Standard {
36+
id: delegateItem
37+
38+
text: modelData
39+
40+
onTriggered: {
41+
listView.currentIndex = index
42+
menu.close()
43+
}
44+
}
45+
}
46+
}
47+
}
48+

modules/Material/ListItems/qmldir

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module Material.ListItems
22
BaseListItem 0.1 BaseListItem.qml
33
Header 0.1 Header.qml
4+
SimpleMenu 0.1 SimpleMenu.qml
45
Standard 0.1 Standard.qml
56
Subtitled 0.1 Subtitled.qml

0 commit comments

Comments
 (0)