How to implement a menu sidebar, that slides in and out?
I wand to implement a menu sidebar with the following requirements:
- The user should be able to slide in and out the sidebar
- The expanded sidebar should overlapp the page content respectively columns
- The list should beginn from the bottom to improve one hand control
A Drawer or DockedPanel seem to be the appropriate UI elements. It's possible to embed SilicaListView in both of them. I'm struggling with the following challenges:
- The Drawer has a full trasparent background. How to confiugre a background like the DockedPanel? The Drawer's animation feels more fluent than the animation of the DockedPanel.
- I could only manage to align the SilicaListView to the top of the panel, not at the button. I didn't found any property to invert the alignment.
Here are some code snippets:
DockedPanel {
id: panel
height: parent.height
width: Theme.itemSizeExtraLarge+ 2 * Theme.paddingLarge
dock: Dock.Right
SilicaListView {
anchors.fill : parent
model: ListModel {
ListElement { content: "one" }
ListElement { content: "two" }
ListElement { content: "three" }
ListElement { content: "four" }
ListElement { content: "five" }
}
VerticalScrollDecorator {}
delegate: ListItem {
id: menuItem
Label {
x: Theme.horizontalPageMargin
y: Theme.paddingLarge
text: content
anchors.leftMargin: Theme.horizontalPageMargin
anchors.bottom: parent.Bottom
color: menuItem.highlighted ? Theme.highlightColor : Theme.primaryColor
}
}
}
}
And this is the one for the Drawer:
Drawer {
id: leftMenu
anchors.fill: parent
dock: Dock.Left
background: SilicaListView {
anchors.fill: parent
model: 5
VerticalScrollDecorator {}
delegate: ListItem {
id: listItem
Label {
x: Theme.horizontalPageMargin
text: "Menu Item " + modelData
anchors.verticalCenter: parent.verticalCenter
color: listItem.highlighted ? Theme.highlightColor : Theme.primaryColor
}
}
}
}
You should look at the installed contents of the default media player which contains a docked panel for the music controls within the app.
There are a couple of paths to examine,
/usr/share/jolla-mediaplayer/*
and;
Spam Hunter ( 2018-10-21 18:58:41 +0300 )edit/usr/lib/qt5/qml/Sailfish/Media/*
Quickbar doesn't already do this?
bocephus ( 2018-10-22 22:58:35 +0300 )edit@bocephus I don't find this UI element in the Silica documentation. Could you post a link to the documentation? If the element is not covered by Silica, it may break a consistent look and feel.
@Edz Indeed. So it should work. I will have a look at the recommended path. The apps are not deployed as binaries but readable qml files? I'm surprised.
jsommer ( 2018-10-28 12:06:56 +0300 )edit@bocephus I seems, that Jolla uses a DockedPanel, defined in the MediaPlayerControlsPanel.qml.
It seems, that the app drwas the background and doesn't use a standard:
Do I also need the opacity property? I'm new with QML.
jsommer ( 2018-10-28 18:44:47 +0300 )edit@jsommer Quickbar is a 3rd party app in Harbour.
bocephus ( 2018-11-01 19:40:49 +0300 )edit