HPage with SwipeView to show reduced side pane

This commit is contained in:
miruka 2019-07-16 12:37:11 -04:00
parent 29e21bc7c2
commit a813b1c715
5 changed files with 83 additions and 54 deletions

View File

@ -1,3 +1,4 @@
- Way to round avatar corners to allow box radius
- If avatar is set, name color from average color? - If avatar is set, name color from average color?
- Wrong avatar for group rooms - Wrong avatar for group rooms
- Reduce messages ListView cacheBuffer height once http thumbnails - Reduce messages ListView cacheBuffer height once http thumbnails

55
src/qml/Base/HPage.qml Normal file
View File

@ -0,0 +1,55 @@
// 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
property alias flickable: innerFlickable
property bool wide: width > 414 + leftPadding + rightPadding
property int currentSpacing:
Math.min(theme.spacing * width / 400, theme.spacing * 2)
id: swipeView
currentIndex: 1
clip: true
interactive: sidePane.reduce
SidePane {
canAutoSize: false
autoWidthRatio: 1.0
visible: swipeView.interactive
onVisibleChanged: swipeView.setCurrentIndex(1)
}
Page {
id: innerPage
background: null
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
}
}
}
}

View File

@ -7,18 +7,15 @@ import QtQuick.Layouts 1.12
import "../../Base" import "../../Base"
import "../../utils.js" as Utils import "../../utils.js" as Utils
Page { HPage {
id: editAccount id: editAccount
property bool wide: width > 414 + padding * 2
property int avatarPreferredSize: theme.minimumSupportedWidth property int avatarPreferredSize: theme.minimumSupportedWidth
property int currentSpacing:
Math.min(theme.spacing * width / 400, theme.spacing * 2)
property string userId: "" property string userId: ""
readonly property var userInfo: users.find(userId) readonly property var userInfo: users.find(userId)
header: HRectangle { page.header: HRectangle {
width: parent.width width: parent.width
color: theme.pageHeadersBackground color: theme.pageHeadersBackground
@ -50,29 +47,8 @@ Page {
} }
} }
background: null
leftPadding: currentSpacing < theme.spacing ? 0 : currentSpacing
rightPadding: leftPadding
Behavior on leftPadding { HNumberAnimation {} }
Flickable {
id: flickable
anchors.fill: parent
clip: true
contentWidth: parent.width
contentHeight: boxColumn.childrenRect.height
interactive: contentWidth > width || contentHeight > height
HColumnLayout {
id: boxColumn
spacing: theme.spacing * 2
width: flickable.width
height: flickable.height
HRectangle { HRectangle {
color: theme.box.background color: theme.box.background
// radius: theme.box.radius
Layout.alignment: Qt.AlignCenter Layout.alignment: Qt.AlignCenter
@ -96,6 +72,4 @@ Page {
// radius: theme.box.radius // radius: theme.box.radius
// Devices { width: parent.width } // Devices { width: parent.width }
// } // }
}
}
} }

View File

@ -13,6 +13,7 @@ HRectangle {
property bool canAutoSize: true property bool canAutoSize: true
property int parentWidth: parent.width property int parentWidth: parent.width
property real autoWidthRatio: theme.sidePane.autoWidthRatio
// Needed for SplitView because it breaks the binding on collapse // Needed for SplitView because it breaks the binding on collapse
onParentWidthChanged: if (canAutoSize) { onParentWidthChanged: if (canAutoSize) {
@ -21,10 +22,7 @@ HRectangle {
property int autoWidth: property int autoWidth:
Math.min( Math.min(parentWidth * autoWidthRatio, theme.sidePane.maximumAutoWidth)
parentWidth * theme.sidePane.autoWidthRatio,
theme.sidePane.maximumAutoWidth
)
property bool collapse: property bool collapse:
canAutoSize ? canAutoSize ?

View File

@ -41,10 +41,11 @@ Item {
canAutoSize: uiSplitView.canAutoSize canAutoSize: uiSplitView.canAutoSize
width: implicitWidth // Initial width width: implicitWidth // Initial width
Layout.maximumWidth: parent.width
Layout.minimumWidth: reduce ? 0 : theme.sidePane.collapsedWidth Layout.minimumWidth: reduce ? 0 : theme.sidePane.collapsedWidth
Behavior on Layout.minimumWidth { HNumberAnimation {} } Behavior on Layout.minimumWidth {
HNumberAnimation { duration: theme.animationDuration / 2 }
}
} }
StackView { StackView {