Add custom drawer behavior to pageHome, for mobile and desktop
This commit is contained in:
parent
058f8b544e
commit
3d999a503c
2 changed files with 121 additions and 58 deletions
|
@ -5,7 +5,6 @@ Drawer {
|
||||||
id: drawer
|
id: drawer
|
||||||
property bool needCloseButton: true
|
property bool needCloseButton: true
|
||||||
property bool isOpened: false
|
property bool isOpened: false
|
||||||
property int pageHeight
|
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: PageController
|
target: PageController
|
||||||
|
@ -51,26 +50,23 @@ Drawer {
|
||||||
if (PageController.getInitialPageNavigationBarColor() !== 0xFF1C1D21) {
|
if (PageController.getInitialPageNavigationBarColor() !== 0xFF1C1D21) {
|
||||||
PageController.updateNavigationBarColor(0xFF1C1D21)
|
PageController.updateNavigationBarColor(0xFF1C1D21)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needCloseButton) {
|
|
||||||
PageController.drawerOpen()
|
|
||||||
}
|
|
||||||
position = (dragMargin / pageHeight)
|
|
||||||
}
|
|
||||||
|
|
||||||
onAboutToHide: {
|
|
||||||
if (needCloseButton) {
|
|
||||||
PageController.drawerClose()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onOpened: {
|
onOpened: {
|
||||||
isOpened = true
|
isOpened = true
|
||||||
|
|
||||||
|
if (needCloseButton) {
|
||||||
|
PageController.drawerOpen()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onClosed: {
|
onClosed: {
|
||||||
isOpened = false
|
isOpened = false
|
||||||
|
|
||||||
|
if (needCloseButton) {
|
||||||
|
PageController.drawerClose()
|
||||||
|
}
|
||||||
|
|
||||||
var initialPageNavigationBarColor = PageController.getInitialPageNavigationBarColor()
|
var initialPageNavigationBarColor = PageController.getInitialPageNavigationBarColor()
|
||||||
if (initialPageNavigationBarColor !== 0xFF1C1D21) {
|
if (initialPageNavigationBarColor !== 0xFF1C1D21) {
|
||||||
PageController.updateNavigationBarColor(initialPageNavigationBarColor)
|
PageController.updateNavigationBarColor(initialPageNavigationBarColor)
|
||||||
|
@ -79,10 +75,9 @@ Drawer {
|
||||||
|
|
||||||
|
|
||||||
onPositionChanged: {
|
onPositionChanged: {
|
||||||
if (position < (dragMargin / root.height)) {
|
if (isOpened && (position <= 0.99 && position >= 0.95)) {
|
||||||
mouseArea.canceled()
|
mouseArea.canceled()
|
||||||
drawer.close()
|
drawer.close()
|
||||||
position = 0
|
|
||||||
mouseArea.exited()
|
mouseArea.exited()
|
||||||
dropArea.exited()
|
dropArea.exited()
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,10 +27,8 @@ PageType {
|
||||||
property string defaultContainerName: ContainersModel.defaultContainerName
|
property string defaultContainerName: ContainersModel.defaultContainerName
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
anchors.top: parent.top
|
anchors.fill: parent
|
||||||
anchors.bottom: buttonBackground.top
|
anchors.bottomMargin: buttonContent.collapsedHeight
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.left: parent.left
|
|
||||||
|
|
||||||
ConnectButton {
|
ConnectButton {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
|
@ -41,17 +39,45 @@ PageType {
|
||||||
target: PageController
|
target: PageController
|
||||||
|
|
||||||
function onRestorePageHomeState(isContainerInstalled) {
|
function onRestorePageHomeState(isContainerInstalled) {
|
||||||
menu.visible = true
|
buttonContent.state = "expanded"
|
||||||
if (isContainerInstalled) {
|
if (isContainerInstalled) {
|
||||||
containersDropDown.menuVisible = true
|
containersDropDown.menuVisible = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function onForceCloseDrawer() {
|
||||||
|
buttonContent.state = "collapsed"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: dragArea
|
||||||
|
|
||||||
|
anchors.fill: buttonBackground
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
hoverEnabled: true
|
||||||
|
|
||||||
|
drag.target: buttonContent
|
||||||
|
drag.axis: Drag.YAxis
|
||||||
|
drag.maximumY: root.height - buttonContent.collapsedHeight
|
||||||
|
drag.minimumY: 100
|
||||||
|
|
||||||
|
onReleased: {
|
||||||
|
if (buttonContent.state === "collapsed" && buttonContent.y < dragArea.drag.maximumY) {
|
||||||
|
buttonContent.state = "expanded"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (buttonContent.state === "expanded" && buttonContent.y > dragArea.drag.minimumY) {
|
||||||
|
buttonContent.state = "collapsed"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: buttonBackground
|
id: buttonBackground
|
||||||
anchors.fill: buttonContent
|
|
||||||
|
|
||||||
|
anchors { left: buttonContent.left; right: buttonContent.right; top: buttonContent.top }
|
||||||
|
height: root.height
|
||||||
radius: 16
|
radius: 16
|
||||||
color: root.defaultColor
|
color: root.defaultColor
|
||||||
border.color: root.borderColor
|
border.color: root.borderColor
|
||||||
|
@ -69,15 +95,67 @@ PageType {
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: buttonContent
|
id: buttonContent
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.left: parent.left
|
property int collapsedHeight: 0
|
||||||
anchors.bottom: parent.bottom
|
property bool expandedVisibility: buttonContent.state === "expanded" || (buttonContent.state === "collapsed" && dragArea.drag.active == true)
|
||||||
|
property bool collapsedVisibility: (buttonContent.state === "collapsed" && dragArea.drag.active == false) || buttonContent.state === "collapsed"
|
||||||
|
|
||||||
|
Drag.active: dragArea.drag.active
|
||||||
|
anchors.right: root.right
|
||||||
|
anchors.left: root.left
|
||||||
|
y: root.height - buttonContent.height
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
buttonContent.state = "collapsed"
|
||||||
|
}
|
||||||
|
|
||||||
|
onImplicitHeightChanged: {
|
||||||
|
if (buttonContent.state === "collapsed" && collapsedHeight == 0) {
|
||||||
|
collapsedHeight = implicitHeight
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onStateChanged: {
|
||||||
|
if (buttonContent.state === "collapsed") {
|
||||||
|
var initialPageNavigationBarColor = PageController.getInitialPageNavigationBarColor()
|
||||||
|
if (initialPageNavigationBarColor !== 0xFF1C1D21) {
|
||||||
|
PageController.updateNavigationBarColor(initialPageNavigationBarColor)
|
||||||
|
}
|
||||||
|
PageController.drawerClose()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (buttonContent.state === "expanded") {
|
||||||
|
if (PageController.getInitialPageNavigationBarColor() !== 0xFF1C1D21) {
|
||||||
|
PageController.updateNavigationBarColor(0xFF1C1D21)
|
||||||
|
}
|
||||||
|
PageController.drawerOpen()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
states: [
|
||||||
|
State {
|
||||||
|
name: "collapsed"
|
||||||
|
PropertyChanges {
|
||||||
|
target: buttonContent
|
||||||
|
y: root.height - collapsedHeight
|
||||||
|
}
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
name: "expanded"
|
||||||
|
PropertyChanges {
|
||||||
|
target: buttonContent
|
||||||
|
y: dragArea.drag.minimumY
|
||||||
|
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
Layout.topMargin: 24
|
Layout.topMargin: 24
|
||||||
Layout.leftMargin: 24
|
Layout.leftMargin: 24
|
||||||
Layout.rightMargin: 24
|
Layout.rightMargin: 24
|
||||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||||
|
visible: buttonContent.collapsedVisibility
|
||||||
|
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
|
@ -104,6 +182,7 @@ PageType {
|
||||||
LabelTextType {
|
LabelTextType {
|
||||||
Layout.bottomMargin: 44
|
Layout.bottomMargin: 44
|
||||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||||
|
visible: buttonContent.collapsedVisibility
|
||||||
|
|
||||||
text: {
|
text: {
|
||||||
var description = ""
|
var description = ""
|
||||||
|
@ -122,39 +201,13 @@ PageType {
|
||||||
return description
|
return description
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: buttonBackground
|
|
||||||
cursorShape: Qt.PointingHandCursor
|
|
||||||
hoverEnabled: true
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
menu.visible = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawerType {
|
|
||||||
id: menu
|
|
||||||
|
|
||||||
interactive: {
|
|
||||||
if (stackView && stackView.currentItem) {
|
|
||||||
return (stackView.currentItem.objectName === PageController.getPagePath(PageEnum.PageHome)) ? true : false
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dragMargin: buttonBackground.height + 56 // page start tabBar height
|
|
||||||
|
|
||||||
width: parent.width
|
|
||||||
height: parent.height * 0.9
|
|
||||||
pageHeight: root.height
|
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: serversMenuHeader
|
id: serversMenuHeader
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.right: parent.right
|
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
|
||||||
anchors.left: parent.left
|
Layout.fillWidth: true
|
||||||
|
visible: buttonContent.expandedVisibility
|
||||||
|
|
||||||
Header1TextType {
|
Header1TextType {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
@ -233,13 +286,14 @@ PageType {
|
||||||
Layout.topMargin: 48
|
Layout.topMargin: 48
|
||||||
Layout.leftMargin: 16
|
Layout.leftMargin: 16
|
||||||
Layout.rightMargin: 16
|
Layout.rightMargin: 16
|
||||||
|
visible: buttonContent.expandedVisibility
|
||||||
|
|
||||||
actionButtonImage: "qrc:/images/controls/plus.svg"
|
actionButtonImage: "qrc:/images/controls/plus.svg"
|
||||||
|
|
||||||
headerText: qsTr("Servers")
|
headerText: qsTr("Servers")
|
||||||
|
|
||||||
actionButtonFunction: function() {
|
actionButtonFunction: function() {
|
||||||
menu.visible = false
|
buttonContent.state = "collapsed"
|
||||||
connectionTypeSelection.visible = true
|
connectionTypeSelection.visible = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -249,10 +303,23 @@ PageType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FlickableType {
|
Flickable {
|
||||||
anchors.top: serversMenuHeader.bottom
|
id: serversContainer
|
||||||
anchors.topMargin: 16
|
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: 16
|
||||||
contentHeight: col.implicitHeight
|
contentHeight: col.implicitHeight
|
||||||
|
height: 500
|
||||||
|
visible: buttonContent.expandedVisibility
|
||||||
|
clip: true
|
||||||
|
|
||||||
|
ScrollBar.vertical: ScrollBar {
|
||||||
|
id: scrollBar
|
||||||
|
policy: serversContainer.height >= serversContainer.contentHeight ? ScrollBar.AlwaysOff : ScrollBar.AlwaysOn
|
||||||
|
}
|
||||||
|
|
||||||
|
Keys.onUpPressed: scrollBar.decrease()
|
||||||
|
Keys.onDownPressed: scrollBar.increase()
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: col
|
id: col
|
||||||
|
@ -266,6 +333,7 @@ PageType {
|
||||||
id: serversRadioButtonGroup
|
id: serversRadioButtonGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
id: serversMenuContent
|
id: serversMenuContent
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
@ -347,7 +415,7 @@ PageType {
|
||||||
onClicked: function() {
|
onClicked: function() {
|
||||||
ServersModel.currentlyProcessedIndex = index
|
ServersModel.currentlyProcessedIndex = index
|
||||||
PageController.goToPage(PageEnum.PageSettingsServerInfo)
|
PageController.goToPage(PageEnum.PageSettingsServerInfo)
|
||||||
menu.visible = false
|
buttonContent.state = "collapsed"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue