Merge PR #454: Clean up some list views

This commit is contained in:
Jenkins nymea 2020-10-24 02:19:05 +02:00
commit e49ed7f3db
4 changed files with 35 additions and 20 deletions

View File

@ -47,20 +47,22 @@ DeviceListPageBase {
Flickable { Flickable {
anchors.fill: parent anchors.fill: parent
contentHeight: contentGrid.implicitHeight contentHeight: contentGrid.implicitHeight
topMargin: app.margins / 2
GridLayout { GridLayout {
id: contentGrid id: contentGrid
width: parent.width width: parent.width - app.margins
columns: Math.ceil(width / 500) anchors.horizontalCenter: parent.horizontalCenter
columns: Math.ceil(width / 600)
rowSpacing: 0 rowSpacing: 0
columnSpacing: 0 columnSpacing: 0
Repeater { Repeater {
model: root.devicesProxy model: root.devicesProxy
delegate: ItemDelegate { delegate: Item {
id: itemDelegate id: itemDelegate
Layout.preferredWidth: contentGrid.width / contentGrid.columns Layout.preferredWidth: contentGrid.width / contentGrid.columns
height: contentItem.implicitHeight + app.margins
property bool inline: width > 500 property bool inline: width > 500
@ -72,9 +74,10 @@ DeviceListPageBase {
readonly property StateType playerTypeStateType: thing.thingClass.stateTypes.findByName("playerType") readonly property StateType playerTypeStateType: thing.thingClass.stateTypes.findByName("playerType")
readonly property State playerTypeState: thing.stateByName("playerType") readonly property State playerTypeState: thing.stateByName("playerType")
bottomPadding: index === root.devicesProxy.count - 1 ? topPadding : 0 Pane {
contentItem: Pane {
id: contentItem id: contentItem
width: parent.width - app.margins
anchors.centerIn: parent
Material.elevation: 2 Material.elevation: 2
leftPadding: 0 leftPadding: 0
rightPadding: 0 rightPadding: 0

View File

@ -39,25 +39,29 @@ DeviceListPageBase {
id: root id: root
header: NymeaHeader { header: NymeaHeader {
text: qsTr("Sensors") text: root.shownInterfaces.indexOf("heating") >= 0 ? qsTr("Heating") : qsTr("Sensors")
onBackPressed: pageStack.pop() onBackPressed: pageStack.pop()
} }
ListView { ListView {
anchors.fill: parent anchors.fill: parent
model: root.thingsProxy model: root.thingsProxy
topMargin: app.margins / 2
delegate: ItemDelegate { delegate: Item {
id: itemDelegate id: itemDelegate
width: parent.width width: parent.width - app.margins
anchors.horizontalCenter: parent.horizontalCenter
height: contentItem.implicitHeight + app.margins
property bool inline: width > 500 property bool inline: width > 500
property Thing thing: thingsProxy.getThing(model.id) property Thing thing: thingsProxy.getThing(model.id)
bottomPadding: index === ListView.view.count - 1 ? topPadding : 0 Pane {
contentItem: Pane {
id: contentItem id: contentItem
width: parent.width - app.margins
anchors.centerIn: parent
Material.elevation: 2 Material.elevation: 2
leftPadding: 0 leftPadding: 0
rightPadding: 0 rightPadding: 0
@ -173,7 +177,7 @@ DeviceListPageBase {
} }
Led { Led {
id: led id: led
visible: ["presencesensor", "daylightsensor"].indexOf(model.interfaceName) >= 0 visible: ["presencesensor", "daylightsensor", "heating"].indexOf(model.interfaceName) >= 0
state: visible && sensorValueDelegate.stateValue.value === true ? "on" : "off" state: visible && sensorValueDelegate.stateValue.value === true ? "on" : "off"
} }
Item { Item {

View File

@ -46,18 +46,22 @@ DeviceListPageBase {
ListView { ListView {
anchors.fill: parent anchors.fill: parent
model: root.devicesProxy model: root.devicesProxy
topMargin: app.margins / 2
delegate: ItemDelegate { delegate: Item {
id: itemDelegate id: itemDelegate
width: parent.width width: parent.width - app.margins
anchors.horizontalCenter: parent.horizontalCenter
height: contentItem.height + app.margins
property bool inline: width > 500 property bool inline: width > 500
property Thing thing: thingsProxy.getThing(model.id) property Thing thing: thingsProxy.getThing(model.id)
bottomPadding: index === ListView.view.count - 1 ? topPadding : 0 Pane {
contentItem: Pane {
id: contentItem id: contentItem
width: parent.width - app.margins
anchors.centerIn: parent
Material.elevation: 2 Material.elevation: 2
leftPadding: 0 leftPadding: 0
rightPadding: 0 rightPadding: 0

View File

@ -47,19 +47,23 @@ DeviceListPageBase {
ListView { ListView {
anchors.fill: parent anchors.fill: parent
model: root.devicesProxy model: root.devicesProxy
topMargin: app.margins / 2
delegate: ItemDelegate { delegate: Item {
id: itemDelegate id: itemDelegate
width: parent.width width: parent.width - app.margins
height: contentItem.height + app.margins
anchors.horizontalCenter: parent.horizontalCenter
property bool inline: width > 500 property bool inline: width > 500
property Device device: devicesProxy.getDevice(model.id) property Device device: devicesProxy.getDevice(model.id)
property DeviceClass deviceClass: device.deviceClass property DeviceClass deviceClass: device.deviceClass
bottomPadding: index === ListView.view.count - 1 ? topPadding : 0 Pane {
contentItem: Pane {
id: contentItem id: contentItem
width: parent.width - app.margins
anchors.centerIn: parent
Material.elevation: 2 Material.elevation: 2
leftPadding: 0 leftPadding: 0
rightPadding: 0 rightPadding: 0