Merge pull request #12665 from gcalero/android_bottombar_resize

Android - Resize bottombar after window size changes (to always fill …
This commit is contained in:
Sam Gondelman 2018-03-22 11:15:02 -07:00 committed by GitHub
commit bbded2215d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,6 +25,7 @@ import "."
Item {
id: bar
x:0
height: 255
property bool shown: true
@ -45,10 +46,10 @@ Item {
anchors.fill: parent
}
Rectangle {
Rectangle {
id: background
anchors.fill : parent
color: "#FF000000"
color: "#FF000000"
border.color: "#FFFFFF"
anchors.bottomMargin: -1
anchors.leftMargin: -1
@ -104,13 +105,25 @@ Item {
}
}
}
}
}
function relocateAndResize(newWindowWidth, newWindowHeight) {
width = newWindowWidth;
y = newWindowHeight - height;
}
function onWindowGeometryChanged(rect) {
relocateAndResize(rect.width, rect.height);
}
Component.onCompleted: {
// put on bottom
width = Window.innerWidth;
height = 255;
y = Window.innerHeight - height;
relocateAndResize(Window.innerWidth, Window.innerHeight);
Window.geometryChanged.connect(onWindowGeometryChanged); // In devices with bars appearing at startup we should listen for this
}
Component.onDestruction: {
Window.geometryChanged.disconnect(onWindowGeometryChanged);
}
function addButton(properties) {