main
zhuzihcu 2023-06-08 17:00:43 +08:00
parent 609df92f8c
commit 2c7d556042
5 changed files with 32 additions and 54 deletions

View File

@ -117,7 +117,7 @@ CustomWindow {
Component.onCompleted: { Component.onCompleted: {
ItemsOriginal.navigationView = nav_view ItemsOriginal.navigationView = nav_view
ItemsFooter.navigationView = nav_view ItemsFooter.navigationView = nav_view
nav_view.setCurrentIndex(0) setCurrentIndex(0)
} }
} }
} }

View File

@ -27,7 +27,6 @@ class FluApp : public QObject
*/ */
Q_PROPERTY_AUTO(QJsonObject,routes); Q_PROPERTY_AUTO(QJsonObject,routes);
QML_FOREIGN(FluApp)
QML_NAMED_ELEMENT(FluApp) QML_NAMED_ELEMENT(FluApp)
QML_SINGLETON QML_SINGLETON
private: private:

View File

@ -11,7 +11,7 @@ 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.Standard property int pageMode: FluNavigationView.SingleTask
property string url: '' property string url: ''
id:control id:control
FluText{ FluText{

View File

@ -12,6 +12,10 @@ Item {
Minimal, Minimal,
Auto Auto
} }
enum PageModeFlag{
Standard = 0,
SingleTask = 1
}
property url logo property url logo
property string title: "" property string title: ""
property FluObject items property FluObject items
@ -21,15 +25,10 @@ Item {
property Component autoSuggestBox property Component autoSuggestBox
property Component actionItem property Component actionItem
property int topPadding: 0 property int topPadding: 0
enum PageModeFlag{
Standard = 0,
SingleTop = 1,
SingleTask = 2
}
id:control id:control
QtObject{ QtObject{
id:d id:d
property bool enableStack: true property var stackItems: []
property int displayMode: { property int displayMode: {
if(control.displayMode !==FluNavigationView.Auto){ if(control.displayMode !==FluNavigationView.Auto){
return control.displayMode return control.displayMode
@ -42,7 +41,6 @@ Item {
return FluNavigationView.Open return FluNavigationView.Open
} }
} }
property var stackItems: []
property bool enableNavigationPanel: false property bool enableNavigationPanel: false
property bool isCompact: d.displayMode === FluNavigationView.Compact property bool isCompact: d.displayMode === FluNavigationView.Compact
property bool isMinimal: d.displayMode === FluNavigationView.Minimal property bool isMinimal: d.displayMode === FluNavigationView.Minimal
@ -345,6 +343,7 @@ Item {
}else{ }else{
nav_list.currentIndex = idx nav_list.currentIndex = idx
layout_footer.currentIndex = -1 layout_footer.currentIndex = -1
model.tap()
if(d.isMinimal || d.isCompact){ if(d.isMinimal || d.isCompact){
d.enableNavigationPanel = false d.enableNavigationPanel = false
} }
@ -355,6 +354,7 @@ Item {
}else{ }else{
nav_list.currentIndex = nav_list.count-layout_footer.count+idx nav_list.currentIndex = nav_list.count-layout_footer.count+idx
layout_footer.currentIndex = idx layout_footer.currentIndex = idx
model.tap()
if(d.isMinimal || d.isCompact){ if(d.isMinimal || d.isCompact){
d.enableNavigationPanel = false d.enableNavigationPanel = false
} }
@ -475,20 +475,18 @@ Item {
Layout.preferredWidth: 30 Layout.preferredWidth: 30
Layout.preferredHeight: 30 Layout.preferredHeight: 30
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
disabled: nav_swipe.depth === 1 disabled: nav_swipe.depth <= 1
iconSize: 13 iconSize: 13
onClicked: { onClicked: {
nav_swipe.pop() nav_swipe.pop()
d.stackItems.pop() d.stackItems.pop()
var item = d.stackItems[d.stackItems.length-1] var item = d.stackItems[d.stackItems.length-1]
d.enableStack = false
if(item.idx<(nav_list.count - layout_footer.count)){ if(item.idx<(nav_list.count - layout_footer.count)){
layout_footer.currentIndex = -1 layout_footer.currentIndex = -1
}else{ }else{
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
d.enableStack = true
} }
} }
FluIconButton{ FluIconButton{
@ -718,15 +716,6 @@ Item {
} }
} }
} }
onCurrentIndexChanged: {
if(d.enableStack){
var item = model[currentIndex]
if(item instanceof FluPaneItem){
item.tap()
d.stackItems.push(item)
}
}
}
currentIndex: -1 currentIndex: -1
anchors{ anchors{
top: layout_header.bottom top: layout_header.bottom
@ -771,15 +760,6 @@ Item {
return footerItems.children return footerItems.children
} }
} }
onCurrentIndexChanged: {
if(d.enableStack){
var item = model[currentIndex]
if(item instanceof FluPaneItem){
item.tap()
d.stackItems.push(item)
}
}
}
highlightMoveDuration: 150 highlightMoveDuration: 150
highlight: Item{ highlight: Item{
clip: true clip: true
@ -906,19 +886,22 @@ Item {
} }
function setCurrentIndex(index){ function setCurrentIndex(index){
nav_list.currentIndex = index nav_list.currentIndex = index
var item = nav_list.model[index]
if(item instanceof FluPaneItem){
item.tap()
}
} }
function getItems(){ function getItems(){
return nav_list.model return nav_list.model
} }
function push(url,argument={}){ function push(url,argument={}){
if (nav_swipe.depth>0) if(nav_swipe.currentItem && nav_swipe.currentItem.url === url){
{ return
}
let page = nav_swipe.find(function(item) { let page = nav_swipe.find(function(item) {
return item.url === url; return item.url === url;
}) })
if (page) if(page){
{
switch(page.pageMode) switch(page.pageMode)
{ {
case FluNavigationView.SingleTask: case FluNavigationView.SingleTask:
@ -928,22 +911,18 @@ Item {
d.stackItems.pop() d.stackItems.pop()
} }
return return
case FluNavigationView.SingleTop:
if (nav_swipe.currentItem.url === url)
return
break
case FluNavigationView.Standard: case FluNavigationView.Standard:
default: default:
} }
} }
}
nav_swipe.push(url,Object.assign(argument,{url:url})) nav_swipe.push(url,Object.assign(argument,{url:url}))
d.stackItems.push(nav_list.model[nav_list.currentIndex])
} }
function getCurrentIndex(){ function getCurrentIndex(){
return nav_list.currentIndex return nav_list.currentIndex
} }
function startPageByItem(data){ function startPageByItem(data){
var items = getItems(); var items = getItems()
for(var i=0;i<items.length;i++){ for(var i=0;i<items.length;i++){
var item = items[i] var item = items[i]
if(item.key === data.key){ if(item.key === data.key){

View File

@ -12,7 +12,7 @@ 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.Standard property int pageMode: FluNavigationView.SingleTask
property string url: '' property string url: ''
id:control id:control
FluText{ FluText{