import QtQuick import QtQuick.Window import QtQuick.Controls import QtQuick.Controls.Basic import QtQuick.Layouts import FluentUI Item { enum DisplayMode { Open, Compact, Minimal, Auto } property url logo property string title: "" property FluObject items property FluObject footerItems property int displayMode: FluNavigationView.Auto property Component autoSuggestBox property var window : { if(Window.window == null) return null return Window.window } id:control QtObject{ id:d property bool enableStack: true property int displayMode: { if(control.displayMode !==FluNavigationView.Auto){ return control.displayMode } if(control.width<=700){ return FluNavigationView.Minimal }else if(control.width<=900){ return FluNavigationView.Compact }else{ return FluNavigationView.Open } } property var stackItems: [] property bool enableNavigationPanel: false property bool isCompact: d.displayMode === FluNavigationView.Compact property bool isMinimal: d.displayMode === FluNavigationView.Minimal property bool isCompactAndPanel: d.displayMode === FluNavigationView.Compact && d.enableNavigationPanel property bool isCompactAndNotPanel:d.displayMode === FluNavigationView.Compact && !d.enableNavigationPanel property bool isMinimalAndPanel: d.displayMode === FluNavigationView.Minimal && d.enableNavigationPanel onIsCompactAndNotPanelChanged: { collapseAll() } onDisplayModeChanged: { if(d.displayMode === FluNavigationView.Compact){ collapseAll() } if(d.displayMode === FluNavigationView.Minimal){ anim_layout_list_x.enabled = false d.enableNavigationPanel = false timer_anim_x_enable.restart() } } function handleItems(){ var idx = 0 var data = [] if(items){ for(var i=0;i" Layout.leftMargin: 2 font: FluTextStyle.Body } FluText{ id: nav_app_bar_pane_title Layout.alignment: Qt.AlignVCenter text:"主页" Layout.leftMargin: 2 font: FluTextStyle.Body } } } Item{ anchors{ left: d.isMinimal || d.isCompactAndPanel ? parent.left : layout_list.right top: nav_app_bar.bottom right: parent.right bottom: parent.bottom leftMargin: d.isCompactAndPanel ? 50 : 0 } StackView{ id:nav_swipe anchors.fill: parent clip: true popEnter : Transition{} popExit : Transition { NumberAnimation { properties: "y" from: 0 to: nav_swipe.height duration: 167 easing.type: Easing.BezierSpline easing.bezierCurve: [ 1, 0, 0, 0 ] } } pushEnter: Transition { NumberAnimation { properties: "y"; from: nav_swipe.height; to: 0 duration: 167 easing.type: Easing.BezierSpline easing.bezierCurve: [ 0, 0, 0, 1 ] } } pushExit : Transition{} replaceEnter : Transition{} replaceExit : Transition{} } } MouseArea{ anchors.fill: parent visible: d.isMinimalAndPanel||d.isCompactAndPanel onClicked: { d.enableNavigationPanel = false } } Rectangle{ id:layout_list width: { if(d.isCompactAndNotPanel){ return 50 } return 200 } Behavior on width{ NumberAnimation{ duration: 167 easing.type: Easing.BezierSpline easing.bezierCurve: [ 0, 0, 0, 1 ] } } Behavior on x{ id:anim_layout_list_x NumberAnimation{ duration: 167 easing.type: Easing.BezierSpline easing.bezierCurve: [ 0, 0, 0, 1 ] } } anchors{ top: parent.top bottom: parent.bottom } border.color: FluTheme.dark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(226/255,230/255,234/255,1) border.width: d.isMinimal || d.isCompactAndPanel ? 1 : 0 color: { if(d.isMinimal || d.isCompactAndPanel){ return FluTheme.dark ? Qt.rgba(61/255,61/255,61/255,1) : Qt.rgba(243/255,243/255,243/255,1) } if(window && window.active){ return FluTheme.dark ? Qt.rgba(26/255,34/255,41/255,1) : Qt.rgba(238/255,244/255,249/255,1) } return FluTheme.dark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(243/255,243/255,243/255,1) } Behavior on color{ ColorAnimation { duration: 300 } } x: { if(d.displayMode !== FluNavigationView.Minimal) return 0 return d.isMinimalAndPanel ? 0 : -width } Item{ id:layout_header width: layout_list.width clip: true y:nav_app_bar.height height: autoSuggestBox ? 38 : 0 Loader{ id:loader_auto_suggest_box anchors.centerIn: parent sourceComponent: autoSuggestBox opacity: { if(d.isCompactAndNotPanel){ return false } return true } visible: opacity Behavior on opacity{ NumberAnimation{ duration: 83 } } } FluIconButton{ visible:opacity opacity:d.isCompactAndNotPanel Behavior on opacity{ NumberAnimation{ duration: 83 } } hoverColor: FluTheme.dark ? Qt.rgba(1,1,1,0.03) : Qt.rgba(0,0,0,0.03) pressedColor: FluTheme.dark ? Qt.rgba(1,1,1,0.03) : Qt.rgba(0,0,0,0.03) normalColor: FluTheme.dark ? Qt.rgba(0,0,0,0) : Qt.rgba(0,0,0,0) width:38 height:34 x:6 y:2 iconSize: 15 iconSource: { if(loader_auto_suggest_box.item){ return loader_auto_suggest_box.item.autoSuggestBoxReplacement } return 0 } onClicked: { d.enableNavigationPanel = !d.enableNavigationPanel } } } ListView{ id:nav_list clip: true ScrollBar.vertical: FluScrollBar {} model:d.handleItems() highlightMoveDuration: 150 highlight: Item{ clip: true Rectangle{ height: 18 radius: 1.5 color: FluTheme.primaryColor.dark width: 3 anchors{ verticalCenter: parent.verticalCenter left: parent.left leftMargin: 6 } } } onCurrentIndexChanged: { if(d.enableStack){ var item = model[currentIndex] if(item instanceof FluPaneItem){ item.tap() d.stackItems.push(item) } } } currentIndex: -1 anchors{ top: layout_header.bottom topMargin: 0 left: parent.left right: parent.right bottom: layout_footer.top } delegate: Loader{ property var model: modelData property var idx: index property int type: 0 sourceComponent: { if(modelData instanceof FluPaneItem){ return com_panel_item } if(modelData instanceof FluPaneItemHeader){ return com_panel_item_header } if(modelData instanceof FluPaneItemSeparator){ return com_panel_item_separatorr } if(modelData instanceof FluPaneItemExpander){ return com_panel_item_expander } if(modelData instanceof FluPaneItemEmpty){ return com_panel_item_empty } } } } ListView{ id:layout_footer clip: true width: layout_list.width height: childrenRect.height anchors.bottom: parent.bottom interactive: false currentIndex: -1 model: { if(footerItems){ return footerItems.children } } highlightMoveDuration: 150 highlight: Item{ clip: true Rectangle{ height: 18 radius: 1.5 color: FluTheme.primaryColor.dark width: 3 anchors{ verticalCenter: parent.verticalCenter left: parent.left leftMargin: 6 } } } delegate: Loader{ property var model: modelData property var idx: index property int type: 1 sourceComponent: { if(modelData instanceof FluPaneItem){ return com_panel_item } if(modelData instanceof FluPaneItemHeader){ return com_panel_item_header } if(modelData instanceof FluPaneItemSeparator){ return com_panel_item_separatorr } } } } } Popup{ property var childModel id:control_popup enter: Transition { NumberAnimation { property: "opacity" from:0 to:1 duration: 83 } } background: Rectangle{ width: 160 radius: 4 FluShadow{ radius: 4 } color: FluTheme.dark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(248/255,250/255,253/255,1) height: 38*Math.min(Math.max(list_view.count,1),8) ListView{ id:list_view anchors.fill: parent clip: true currentIndex: -1 model: control_popup.childModel ScrollBar.vertical: FluScrollBar {} delegate:Button{ width: 160 padding:10 background: Rectangle{ color: { if(hovered){ return FluTheme.dark ? Qt.rgba(63/255,60/255,61/255,1) : Qt.rgba(237/255,237/255,242/255,1) } return FluTheme.dark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(0,0,0,0) } } contentItem: FluText{ text:modelData.title anchors{ verticalCenter: parent.verticalCenter } } onClicked: { if(modelData.tapFunc){ modelData.tapFunc() }else{ nav_list.currentIndex = idx layout_footer.currentIndex = -1 if(d.isMinimal || d.isCompact){ d.enableNavigationPanel = false } } control_popup.close() } } } } function showPopup(pos,model){ control_popup.x = pos.x control_popup.y = pos.y control_popup.childModel = model control_popup.open() } } Timer{ id:timer_anim_x_enable interval: 150 onTriggered: { anim_layout_list_x.enabled = true } } function collapseAll(){ for(var i=0;i