From ed8e26e67e68c9fdc63f84d17d7171e88be15dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Thu, 26 Feb 2026 15:48:31 +0100 Subject: [PATCH] Add margin handling --- nymea-app/ui/MainPage.qml | 2 ++ nymea-app/ui/RootItem.qml | 20 +++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/nymea-app/ui/MainPage.qml b/nymea-app/ui/MainPage.qml index 23832c1f..c4b7ad0c 100644 --- a/nymea-app/ui/MainPage.qml +++ b/nymea-app/ui/MainPage.qml @@ -43,6 +43,8 @@ Page { // a deepter layer as we need to include it in the blurring of the header and footer. // We don't want to paint the background on the entire screen twice (overdraw is costly) background: null + readonly property bool applyRootItemBottomMarginCompaction: true + readonly property int bottomMargin: footer.shown ? contentContainer.footerSize : 0 function configureViews() { if (Configuration.hasOwnProperty("mainViewsFilter")) { diff --git a/nymea-app/ui/RootItem.qml b/nymea-app/ui/RootItem.qml index cdf03e3c..0920bf9d 100644 --- a/nymea-app/ui/RootItem.qml +++ b/nymea-app/ui/RootItem.qml @@ -37,11 +37,25 @@ import "connection" Item { id: root + readonly property var currentPage: swipeView.currentItem ? swipeView.currentItem.pageStack.currentItem : null + readonly property bool currentPageCompactsBottomMargin: currentPage + && currentPage.hasOwnProperty("applyRootItemBottomMarginCompaction") + && currentPage.applyRootItemBottomMarginCompaction + readonly property bool currentPageDefinesBottomMargin: currentPage && currentPage.hasOwnProperty("bottomMargin") + readonly property int currentPageBottomMargin: currentPageDefinesBottomMargin ? currentPage.bottomMargin : 0 + readonly property int safeAreaBottomMargin: { - if (Qt.platform.os !== "ios") { - return PlatformHelper.bottomPadding + var margin = PlatformHelper.bottomPadding + + if (Qt.platform.os === "ios") { + margin = Math.round(PlatformHelper.bottomPadding * Math.max(0, Configuration.iosSafeAreaBottomMarginScale)) + + if (currentPageCompactsBottomMargin && !app.landscape && currentPageBottomMargin > 0 && margin > 0) { + margin = Math.floor(margin * 0.5) + } } - return Math.round(PlatformHelper.bottomPadding * Math.max(0, Configuration.iosSafeAreaBottomMarginScale)) + + return margin } function handleAndroidBackButton() {