This commit is contained in:
zhuzichu 2023-06-20 12:53:32 +08:00
parent 4efb91084a
commit 82f606dd65
7 changed files with 93 additions and 51 deletions

View File

@ -17,7 +17,6 @@ FluScrollablePage{
desc:"The latest FluentUI controls and styles for your applications." desc:"The latest FluentUI controls and styles for your applications."
url:"https://github.com/zhuzichu520/FluentUI" url:"https://github.com/zhuzichu520/FluentUI"
} }
} }
Item{ Item{

View File

@ -7,8 +7,9 @@ import "qrc:///example/qml/component"
FluScrollablePage{ FluScrollablePage{
title:"TextBox" pageMode: FluNavigationView.SingleInstance
title:"TextBox"
FluArea{ FluArea{
Layout.fillWidth: true Layout.fillWidth: true
height: 68 height: 68

View File

@ -4,15 +4,13 @@ import QtQuick.Window
import QtQuick.Controls import QtQuick.Controls
import FluentUI import FluentUI
Item { FluPage {
property alias title: text_title.text property alias title: text_title.text
default property alias content: container.data default property alias content: container.data
property int leftPadding: 10 property int leftPadding: 10
property int topPadding: 0 property int topPadding: 0
property int rightPadding: 10 property int rightPadding: 10
property int bottomPadding: 10 property int bottomPadding: 10
property int pageMode: FluNavigationView.SingleTop
property string url: ''
id:control id:control
FluText{ FluText{
id:text_title id:text_title

View File

@ -15,7 +15,8 @@ Item {
enum PageModeFlag{ enum PageModeFlag{
Standard = 0, Standard = 0,
SingleTask = 1, SingleTask = 1,
SingleTop = 2 SingleTop = 2,
SingleInstance = 3
} }
property url logo property url logo
property string title: "" property string title: ""
@ -30,6 +31,7 @@ Item {
id:control id:control
QtObject{ QtObject{
id:d id:d
property var pageMap: ({})
property var stackItems: [] property var stackItems: []
property int displayMode: FluNavigationView.Open property int displayMode: FluNavigationView.Open
property bool enableNavigationPanel: false property bool enableNavigationPanel: false
@ -532,6 +534,20 @@ Item {
layout_footer.currentIndex = item.idx-(nav_list.count-layout_footer.count) layout_footer.currentIndex = item.idx-(nav_list.count-layout_footer.count)
} }
nav_list.currentIndex = item.idx nav_list.currentIndex = item.idx
if(nav_swipe.currentItem.pageMode === FluNavigationView.SingleInstance){
var url = nav_swipe.currentItem.url
var pageIndex = -1
for(var i=0;i<nav_swipe2.children.length;i++){
var obj = nav_swipe2.children[i]
if(obj.url === url){
pageIndex = i
break
}
}
if(pageIndex !== -1){
nav_swipe2.currentIndex = pageIndex
}
}
} }
} }
FluIconButton{ FluIconButton{
@ -630,31 +646,20 @@ Item {
id:nav_swipe id:nav_swipe
anchors.fill: parent anchors.fill: parent
clip: true clip: true
visible: !nav_swipe2.visible
popEnter : Transition{} popEnter : Transition{}
popExit : Transition { popExit : Transition {}
NumberAnimation { pushEnter: Transition {}
properties: "y"
from: 0
to: nav_swipe.height
duration: dontPageAnimation ? 0 : 167
easing.type: Easing.BezierSpline
easing.bezierCurve: [ 1, 0, 0, 0 ]
}
}
pushEnter: Transition {
NumberAnimation {
properties: "y";
from: nav_swipe.height;
to: 0
duration: dontPageAnimation ? 0 : 167
easing.type: Easing.BezierSpline
easing.bezierCurve: [ 0, 0, 0, 1 ]
}
}
pushExit : Transition{} pushExit : Transition{}
replaceEnter : Transition{} replaceEnter : Transition{}
replaceExit : Transition{} replaceExit : Transition{}
} }
StackLayout{
id:nav_swipe2
anchors.fill: nav_swipe
clip: true
visible: nav_swipe.currentItem.pageMode === FluNavigationView.SingleInstance
}
} }
MouseArea{ MouseArea{
anchors.fill: parent anchors.fill: parent
@ -976,6 +981,16 @@ Item {
function getItems(){ function getItems(){
return nav_list.model return nav_list.model
} }
Component{
id:com_placeholder
Item{
property int pageMode: FluNavigationView.SingleInstance
property string url
}
}
function push(url,argument={}){ function push(url,argument={}){
let page = nav_swipe.find(function(item) { let page = nav_swipe.find(function(item) {
return item.url === url; return item.url === url;
@ -999,8 +1014,35 @@ Item {
default: default:
} }
} }
nav_swipe.push(url,Object.assign(argument,{url:url})) var comp = Qt.createComponent(url)
if (comp.status === Component.Ready) {
//nav_swipe2url
var pageIndex = -1
for(var i=0;i<nav_swipe2.children.length;i++){
var item = nav_swipe2.children[i]
if(item.url === url){
pageIndex = i
break
}
}
var options = Object.assign(argument,{url:url})
if(pageIndex!==-1){
nav_swipe2.currentIndex = pageIndex
nav_swipe.push(com_placeholder,options)
}else{
var obj = comp.createObject(nav_swipe,options)
if(obj.pageMode === FluNavigationView.SingleInstance){
nav_swipe.push(com_placeholder,options)
nav_swipe2.children.push(obj)
nav_swipe2.currentIndex = nav_swipe2.count - 1
}else{
nav_swipe.push(obj)
}
}
d.stackItems.push(nav_list.model[nav_list.currentIndex]) d.stackItems.push(nav_list.model[nav_list.currentIndex])
}else{
console.error(comp.errorString())
}
} }
function getCurrentIndex(){ function getCurrentIndex(){
return nav_list.currentIndex return nav_list.currentIndex

View File

@ -0,0 +1,18 @@
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtQuick.Window
import FluentUI
Item {
property int pageMode: FluNavigationView.SingleTop
property string url
id: control
visible: false
opacity: visible
Behavior on opacity {
NumberAnimation{
duration: 83
}
}
}

View File

@ -4,7 +4,7 @@ import QtQuick.Window
import QtQuick.Controls import QtQuick.Controls
import FluentUI import FluentUI
Item { FluPage {
property alias title: text_title.text property alias title: text_title.text
default property alias content: container.data default property alias content: container.data
property int spacing : 0 property int spacing : 0
@ -12,8 +12,6 @@ Item {
property int topPadding: 0 property int topPadding: 0
property int rightPadding: 10 property int rightPadding: 10
property int bottomPadding: 10 property int bottomPadding: 10
property int pageMode: FluNavigationView.SingleTop
property string url: ''
id:control id:control
FluText{ FluText{
id:text_title id:text_title

View File

@ -5,13 +5,10 @@ import QtQuick.Layouts
import Qt.labs.qmlmodels import Qt.labs.qmlmodels
import FluentUI import FluentUI
Rectangle { Rectangle {
id:control
property var columnSource property var columnSource
property var dataSource property var dataSource
id:control
color: FluTheme.dark ? Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(251/255,251/255,253/255,1) color: FluTheme.dark ? Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(251/255,251/255,253/255,1)
onColumnSourceChanged: { onColumnSourceChanged: {
if(columnSource.length!==0){ if(columnSource.length!==0){
@ -26,18 +23,15 @@ Rectangle {
} }
} }
} }
TableModel {
id:table_model
}
onDataSourceChanged: { onDataSourceChanged: {
table_model.clear() table_model.clear()
dataSource.forEach(function(item){ dataSource.forEach(function(item){
table_model.appendRow(item) table_model.appendRow(item)
}) })
} }
TableModel {
id:table_model
}
Component{ Component{
id:com_edit id:com_edit
FluTextBox { FluTextBox {
@ -50,7 +44,6 @@ Rectangle {
} }
} }
} }
ScrollView{ ScrollView{
id:scroll_table id:scroll_table
anchors.left: header_vertical.right anchors.left: header_vertical.right
@ -116,7 +109,6 @@ Rectangle {
} }
} }
} }
Component{ Component{
id:com_handle id:com_handle
FluControl { FluControl {
@ -145,14 +137,11 @@ Rectangle {
} }
} }
} }
SelectionRectangle { SelectionRectangle {
target: table_view target: table_view
bottomRightHandle:com_handle bottomRightHandle:com_handle
topLeftHandle: com_handle topLeftHandle: com_handle
} }
FluHorizontalHeaderView { FluHorizontalHeaderView {
id: header_horizontal id: header_horizontal
textRole: "title" textRole: "title"
@ -163,7 +152,6 @@ Rectangle {
boundsBehavior: Flickable.StopAtBounds boundsBehavior: Flickable.StopAtBounds
clip: true clip: true
} }
FluVerticalHeaderView { FluVerticalHeaderView {
id: header_vertical id: header_vertical
boundsBehavior: Flickable.StopAtBounds boundsBehavior: Flickable.StopAtBounds
@ -172,7 +160,5 @@ Rectangle {
syncView: table_view syncView: table_view
clip: true clip: true
} }
} }