Skip to content

Commit

Permalink
Add List Item demo, working on a Simple Menu list item
Browse files Browse the repository at this point in the history
  • Loading branch information
iBelieve committed Jan 29, 2015
1 parent fbcb35b commit 98dc036
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 1 deletion.
37 changes: 37 additions & 0 deletions demo/ListItemsDemo.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import QtQuick 2.0
import Material 0.1
import Material.ListItems 0.1 as ListItem
import Material.Extras 0.1

Item {
View {
anchors {
fill: parent
margins: units.dp(32)
}

elevation: 1

Column {
anchors.fill: parent

ListItem.Header {
text: "Section header"
}

ListItem.Standard {
text: "Standard list item"
}

ListItem.Subtitled {
text: "Subtitled list item"
subText: "With some subtext!"
}

ListItem.SimpleMenu {
text: "Subtitled list item"
model: ["A", "B", "C"]
}
}
}
}
2 changes: 1 addition & 1 deletion demo/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ApplicationWindow {

initialPage: page

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

Page {
Expand Down
48 changes: 48 additions & 0 deletions modules/Material/ListItems/SimpleMenu.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import QtQuick 2.0
import Material 0.1

Subtitled {
id: listItem

property alias model: listView.model
property alias selectedIndex: listView.currentIndex

subText: listView.currentItem.text

onTriggered: menu.open(listItem, units.dp(16), 0)

Dropdown {
id: menu

anchor: Item.TopLeft

width: Math.max(units.dp(56 * 2), Math.min(listItem.width - 2 * x, listView.contentWidth))
height: Math.min(10 * units.dp(48) + units.dp(16), listView.contentHeight + units.dp(16))

ListView {
id: listView

anchors {
left: parent.left
right: parent.right
top: parent.top
topMargin: units.dp(8)
}

interactive: false
height: contentHeight

delegate: Standard {
id: delegateItem

text: modelData

onTriggered: {
listView.currentIndex = index
menu.close()
}
}
}
}
}

1 change: 1 addition & 0 deletions modules/Material/ListItems/qmldir
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Material.ListItems
BaseListItem 0.1 BaseListItem.qml
Header 0.1 Header.qml
SimpleMenu 0.1 SimpleMenu.qml
Standard 0.1 Standard.qml
Subtitled 0.1 Subtitled.qml

0 comments on commit 98dc036

Please sign in to comment.