shift-shell/components/mobileshell/qml/actiondrawer/PortraitContentContainer.qml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

98 lines
4.4 KiB
QML
Raw Normal View History

// SPDX-FileCopyrightText: 2021-2024 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: LGPL-2.0-or-later
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts
import QtQuick.Window 2.2
import org.kde.plasma.private.mobileshell as MobileShell
import org.kde.plasma.components 3.0 as PlasmaComponents
import org.kde.kirigami 2.20 as Kirigami
import org.kde.plasma.private.mobileshell.quicksettingsplugin as QS
/**
2024-06-16 20:50:06 +00:00
* Root element that contains all the ActionDrawer's contents, and is anchored to the screen.
*/
Item {
id: root
2024-07-27 03:47:44 +00:00
required property var actionDrawer
2024-07-27 03:47:44 +00:00
// pinned position (disabled when openToPinnedMode is false)
readonly property real minimizedQuickSettingsOffset: quickSettingsDrawer.minimizedHeight
2024-07-27 03:47:44 +00:00
// fully open position
readonly property real maximizedQuickSettingsOffset: minimizedQuickSettingsOffset + quickSettingsDrawer.maxAddedHeight
property alias quickSettings: quickSettingsDrawer.quickSettings
property alias statusBar: quickSettingsDrawer.statusBar
property alias mediaControlsWidget: quickSettingsDrawer.mediaControlsWidget
property alias notificationsWidget: notificationWidgetProxy.contentItem
2024-07-27 03:47:44 +00:00
Kirigami.Theme.colorSet: Kirigami.Theme.View
Kirigami.Theme.inherit: false
2024-07-27 03:47:44 +00:00
function applyMinMax(val) {
return Math.max(0, Math.min(1, val));
}
2024-07-27 03:47:44 +00:00
MobileShell.QuickSettingsDrawer {
id: quickSettingsDrawer
z: 1 // ensure it's above notifications
// physically move the drawer when between closed <-> pinned mode
readonly property real offsetHeight: actionDrawer.openToPinnedMode ? minimizedQuickSettingsOffset : maximizedQuickSettingsOffset
anchors.topMargin: Math.min(root.actionDrawer.offset - offsetHeight, 0)
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
2024-07-27 03:47:44 +00:00
actionDrawer: root.actionDrawer
2024-07-27 03:47:44 +00:00
// opacity and move animation (disabled when openToPinnedMode is false)
property real offsetDist: actionDrawer.offset - minimizedQuickSettingsOffset
property real totalOffsetDist: maximizedQuickSettingsOffset - minimizedQuickSettingsOffset
minimizedToFullProgress: actionDrawer.openToPinnedMode ? (actionDrawer.opened ? applyMinMax(offsetDist / totalOffsetDist) : 0) : 1
2024-07-27 03:47:44 +00:00
// this drawer opens in two stages when pinned mode is enabled:
// ---
// stage 1: the transform effect is used, the drawer physically moves down to the pinned mode
// stage 2: the rectangle increases height to reveal content, but the content stays still
// when pinned mode is disabled, only stage 1 happens
2024-07-27 03:47:44 +00:00
// increase height of drawer when between pinned mode <-> maximized mode
addedHeight: {
if (!actionDrawer.openToPinnedMode) {
// if pinned mode disabled, just go to full height
let progress = (root.actionDrawer.offset - maximizedQuickSettingsOffset) / (quickSettingsDrawer.maxAddedHeight * 4);
let effectProgress = Math.atan(Math.max(0, progress));
return (quickSettingsDrawer.maxAddedHeight * effectProgress) + quickSettingsDrawer.maxAddedHeight;
} else if (!actionDrawer.opened) {
// over-scroll effect for initial opening
let progress = (root.actionDrawer.offset - minimizedQuickSettingsOffset) / quickSettingsDrawer.maxAddedHeight;
let effectProgress = Math.atan(Math.max(0, progress));
return quickSettingsDrawer.maxAddedHeight * 0.25 * effectProgress;
} else {
// over-scroll effect for full drawer
let progress = (root.actionDrawer.offset - maximizedQuickSettingsOffset) / (quickSettingsDrawer.maxAddedHeight * 4);
let effectProgress = Math.atan(Math.max(0, progress));
// as the drawer opens, add height to the rectangle, revealing content
return (quickSettingsDrawer.maxAddedHeight * effectProgress) + Math.max(0, Math.min(quickSettingsDrawer.maxAddedHeight, root.actionDrawer.offset - minimizedQuickSettingsOffset));
}
}
}
2024-07-27 03:47:44 +00:00
MobileShell.BaseItem {
id: notificationWidgetProxy
2024-07-27 03:47:44 +00:00
anchors {
top: quickSettingsDrawer.bottom
bottom: parent.bottom
left: parent.left
right: parent.right
}
opacity: applyMinMax(root.actionDrawer.offset / root.minimizedQuickSettingsOffset)
}
}