From 13f15e69da773e7cbf0c0210da687fb5795b4395 Mon Sep 17 00:00:00 2001 From: uncor3 Date: Fri, 22 May 2026 11:56:13 +0000 Subject: [PATCH] refactor: implement AnimatedTab component for tab management in Tabs.qml --- src/ui/Tabs.qml | 39 ++++++++++++++++++------------------- src/ui/base/AnimatedTab.qml | 23 ++++++++++++++++++++++ 2 files changed, 42 insertions(+), 20 deletions(-) create mode 100644 src/ui/base/AnimatedTab.qml diff --git a/src/ui/Tabs.qml b/src/ui/Tabs.qml index 779a981..8ccc817 100644 --- a/src/ui/Tabs.qml +++ b/src/ui/Tabs.qml @@ -1,36 +1,35 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 +import "./base" Item { id: root required property int currentIndex - DeviceTab { - id : device - anchors.fill: parent - visible : currentIndex == 0 - opacity: root.currentIndex === 0 ? 1 : 0 - property real slideY: root.currentIndex === 0 ? 0 : 20 - transform: Translate { y: device.slideY } - - Behavior on opacity { - NumberAnimation { duration: 167; easing.type: Easing.OutCubic } - } - Behavior on slideY { - NumberAnimation { duration: 167; easing.type: Easing.OutCubic } + AnimatedTab { + index: 0 + currentIndex : root.currentIndex + DeviceTab { + anchors.fill: parent } } - AppsTab { - anchors.fill: parent - visible : currentIndex == 1 + AnimatedTab { + index: 1 + currentIndex : root.currentIndex + AppsTab { + anchors.fill: parent + } } - - Toolbox { - anchors.fill: parent - visible : currentIndex == 2 + AnimatedTab { + index: 2 + currentIndex : root.currentIndex + Toolbox { + anchors.fill: parent + } } + } diff --git a/src/ui/base/AnimatedTab.qml b/src/ui/base/AnimatedTab.qml new file mode 100644 index 0000000..b019e59 --- /dev/null +++ b/src/ui/base/AnimatedTab.qml @@ -0,0 +1,23 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts + +Item { + id: root + anchors.fill: parent + required property int index + required property int currentIndex + property bool isActive : root.currentIndex === index + + visible : currentIndex == index + opacity: isActive ? 1 : 0 + property real slideY: isActive ? 0 : 20 + transform: Translate { y: root.slideY } + + Behavior on opacity { + NumberAnimation { duration: 167; easing.type: Easing.OutCubic } + } + Behavior on slideY { + NumberAnimation { duration: 167; easing.type: Easing.OutCubic } + } +} \ No newline at end of file