From 28b3727e88116784c066c5c086cbfe714174ae32 Mon Sep 17 00:00:00 2001 From: miruka Date: Sat, 7 Dec 2019 08:56:32 -0400 Subject: [PATCH] New HTabbedBoxes component, base AddChat on it --- src/qml/Base/HTabbedBoxes.qml | 42 ++++++++++++++++++++++++++ src/qml/Pages/AddChat/AddChat.qml | 50 +++++-------------------------- 2 files changed, 49 insertions(+), 43 deletions(-) create mode 100644 src/qml/Base/HTabbedBoxes.qml diff --git a/src/qml/Base/HTabbedBoxes.qml b/src/qml/Base/HTabbedBoxes.qml new file mode 100644 index 00000000..0e26f580 --- /dev/null +++ b/src/qml/Base/HTabbedBoxes.qml @@ -0,0 +1,42 @@ +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 + +HColumnLayout { + implicitWidth: Math.min( + parent.width, + Math.max(tabBar.contentWidth, swipeView.contentWidth), + ) + + Layout.alignment: Qt.AlignCenter + Layout.fillWidth: false + Layout.fillHeight: false + + property alias tabIndex: tabBar.currentIndex + property alias tabModel: tabRepeater.model + default property alias boxes: swipeView.contentData + + HTabBar { + id: tabBar + Component.onCompleted: shortcuts.tabsTarget = this + + Layout.fillWidth: true + + Repeater { + id: tabRepeater + HTabButton { text: modelData } + } + } + + SwipeView { + id: swipeView + clip: true + currentIndex: tabBar.currentIndex + interactive: false + + Layout.fillWidth: true + + Behavior on implicitWidth { HNumberAnimation {} } + Behavior on implicitHeight { HNumberAnimation {} } + } +} diff --git a/src/qml/Pages/AddChat/AddChat.qml b/src/qml/Pages/AddChat/AddChat.qml index d12db846..187ab72f 100644 --- a/src/qml/Pages/AddChat/AddChat.qml +++ b/src/qml/Pages/AddChat/AddChat.qml @@ -6,7 +6,6 @@ import "../../utils.js" as Utils HPage { id: addChatPage - onFocusChanged: findSomeone.forceActiveFocus() property string userId @@ -15,48 +14,13 @@ HPage { Utils.getItem(modelSources["Account"] || [], "user_id", userId) - HColumnLayout { - Layout.alignment: Qt.AlignCenter - Layout.minimumWidth: Layout.maximumWidth - Layout.maximumWidth: Math.min( - parent.width, - Math.max(tabBar.contentWidth, swipeView.contentWidth), - ) + HTabbedBoxes { + tabModel: [ + qsTr("Find someone"), qsTr("Join room"), qsTr("Create room"), + ] - HTabBar { - id: tabBar - currentIndex: 0 - Component.onCompleted: shortcuts.tabsTarget = this - - Layout.fillWidth: true - - Repeater { - model: [ - qsTr("Find someone"), - qsTr("Join room"), - qsTr("Create room"), - ] - - HTabButton { - text: modelData - } - } - } - - SwipeView { - id: swipeView - clip: true - currentIndex: tabBar.currentIndex - interactive: false - - Layout.fillWidth: true - - Behavior on implicitWidth { HNumberAnimation {} } - Behavior on implicitHeight { HNumberAnimation {} } - - FindSomeone { id: findSomeone } - JoinRoom {} - CreateRoom {} - } + FindSomeone { Component.onCompleted: forceActiveFocus() } + JoinRoom {} + CreateRoom {} } }