Skip to content

Commit

Permalink
Merge pull request #3097 from MerginMaps/drawers2
Browse files Browse the repository at this point in the history
Update MMDrawer and MMPage API
  • Loading branch information
PeterPetrik authored Mar 4, 2024
2 parents e0db300 + 3ad7442 commit 7eb3529
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 204 deletions.
24 changes: 22 additions & 2 deletions app/qml/components/MMDrawer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ Drawer {
property alias drawerHeader: mmDrawerHeader
property alias content: contentGroup.children

property double drawerSpacing: __style.spacing40 // Change this to 20 if using searchbar
property double drawerSpacing: __style.spacing20
property double drawerBottomMargin: __style.margin8 // set to 0 to draw behind navigation bar

property real maxHeight: ( ApplicationWindow.window?.height ?? 0 ) - __style.safeAreaTop

signal backClicked()

implicitHeight: contentHeight > maxHeight ? maxHeight : contentHeight
implicitWidth: ApplicationWindow.window?.width ?? 0
Expand Down Expand Up @@ -55,13 +57,20 @@ Drawer {
height: parent.height / 2
y: parent.height / 2
}

Keys.onReleased: function( event ) {
if ( event.key === Qt.Key_Back || event.key === Qt.Key_Escape ) {
root.backClicked()
event.accepted = true
}
}
}

contentItem: Column {
id: mainColumn

anchors.fill: parent
spacing: root.drawerSpacing
spacing: 0

height: mmDrawerHeader.height + contentGroup.height + root.drawerSpacing

Expand All @@ -75,6 +84,11 @@ Drawer {
}
}

Item {
width: parent.width
height: root.drawerSpacing
}

Item {
id: contentGroup

Expand Down Expand Up @@ -106,6 +120,12 @@ Drawer {
// center the content
x: leftPadding
}

// Bottom spacer
Item {
width: parent.width
height: root.drawerBottomMargin > 0 ? __style.safeAreaBottom + root.drawerBottomMargin :0
}
}

QtObject {
Expand Down
3 changes: 2 additions & 1 deletion app/qml/components/MMPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Page {
property alias content: contentGroup.children

property double pageSpacing: __style.spacing40 // Change this to 20 if using searchbar
property real pageBottomMargin: __style.margin20 // Set to 0 to draw behind navigation bar

signal backClicked()

Expand Down Expand Up @@ -63,7 +64,7 @@ Page {
return minRightPadding
}

height: parent.height - root.pageSpacing
height: parent.height - root.pageSpacing - root.pageBottomMargin
width: parent.width - leftPadding - rightPadding

// center the content
Expand Down
Loading

0 comments on commit 7eb3529

Please sign in to comment.