moment/src/qml/Base/HPage.qml

92 lines
2.7 KiB
QML
Raw Normal View History

// Copyright 2019 miruka
// This file is part of harmonyqml, licensed under LGPLv3.
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import "../SidePane"
SwipeView {
default property alias columnChildren: contentColumn.children
property alias page: innerPage
2019-07-17 07:08:06 +10:00
property alias header: innerPage.header
property alias footer: innerPage.header
property alias flickable: innerFlickable
property alias headerLabel: innerHeaderLabel
property var hideHeaderUnderHeight: null
property int currentSpacing:
Math.min(theme.spacing * width / 400, theme.spacing * 2)
id: swipeView
currentIndex: 1
clip: true
interactive: sidePane.reduce
SidePane {
implicitWidth: swipeView.width
2019-07-17 07:08:06 +10:00
collapse: false
reduce: false
visible: swipeView.interactive
2019-07-17 07:08:06 +10:00
onVisibleChanged: if (currentIndex != 1) swipeView.setCurrentIndex(1)
}
Page {
id: innerPage
background: null
header: HRectangle {
2019-07-17 07:08:06 +10:00
implicitWidth: parent ? parent.width : 0
color: theme.pageHeadersBackground
height: ! hideHeaderUnderHeight ||
window.height >=
hideHeaderUnderHeight +
theme.baseElementsHeight +
currentSpacing * 2 ?
theme.baseElementsHeight : 0
Behavior on height { HNumberAnimation {} }
visible: height > 0
HRowLayout {
width: parent.width
HLabel {
id: innerHeaderLabel
textFormat: Text.StyledText
font.pixelSize: theme.fontSize.big
elide: Text.ElideRight
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
Layout.leftMargin: currentSpacing
Layout.rightMargin: Layout.leftMargin
Layout.fillWidth: true
}
}
}
leftPadding: currentSpacing < theme.spacing ? 0 : currentSpacing
rightPadding: leftPadding
Behavior on leftPadding { HNumberAnimation {} }
Flickable {
id: innerFlickable
anchors.fill: parent
clip: true
contentWidth: parent.width
contentHeight: contentColumn.childrenRect.height
interactive: contentWidth > width || contentHeight > height
HColumnLayout {
id: contentColumn
spacing: theme.spacing
width: innerFlickable.width
height: innerFlickable.height
}
}
}
}