This commit is contained in:
zhuzihcu 2023-06-13 11:48:29 +08:00
parent ac602c5afa
commit fd0ddbf5aa
5 changed files with 64 additions and 22 deletions

View File

@ -8,16 +8,17 @@ FluObject{
property var navigationView property var navigationView
FluPaneItem{ FluPaneItem{
id:item_home
property int count: 8
title:lang.home title:lang.home
infoBadge:FluBadge{
count: item_home.count
}
icon:FluentIcons.Home icon:FluentIcons.Home
// cusIcon: Image{
// anchors.centerIn: parent
// source: FluTheme.dark ? "qrc:/example/res/svg/home_dark.svg" : "qrc:/example/res/svg/home.svg"
// sourceSize: Qt.size(30,30)
// width: 18
// height: 18
// }
onTap:{ onTap:{
if(navigationView.getCurrentUrl()){
item_home.count = 0
}
navigationView.push("qrc:/example/qml/page/T_Home.qml") navigationView.push("qrc:/example/qml/page/T_Home.qml")
} }
} }

View File

@ -33,6 +33,8 @@ FluScrollablePage{
radius: 8 radius: 8
color: Qt.rgba(191/255,191/255,191/255,1) color: Qt.rgba(191/255,191/255,191/255,1)
FluBadge{ FluBadge{
topRight: true
showZero: true
count:0 count:0
} }
} }
@ -43,6 +45,8 @@ FluScrollablePage{
radius: 8 radius: 8
color: Qt.rgba(191/255,191/255,191/255,1) color: Qt.rgba(191/255,191/255,191/255,1)
FluBadge{ FluBadge{
topRight: true
showZero: true
count:5 count:5
} }
} }
@ -52,6 +56,8 @@ FluScrollablePage{
radius: 8 radius: 8
color: Qt.rgba(191/255,191/255,191/255,1) color: Qt.rgba(191/255,191/255,191/255,1)
FluBadge{ FluBadge{
topRight: true
showZero: true
count:50 count:50
} }
} }
@ -61,6 +67,8 @@ FluScrollablePage{
radius: 8 radius: 8
color: Qt.rgba(191/255,191/255,191/255,1) color: Qt.rgba(191/255,191/255,191/255,1)
FluBadge{ FluBadge{
topRight: true
showZero: true
count:100 count:100
} }
} }
@ -70,6 +78,8 @@ FluScrollablePage{
radius: 8 radius: 8
color: Qt.rgba(191/255,191/255,191/255,1) color: Qt.rgba(191/255,191/255,191/255,1)
FluBadge{ FluBadge{
topRight: true
showZero: true
isDot:true isDot:true
} }
} }
@ -79,6 +89,8 @@ FluScrollablePage{
radius: 8 radius: 8
color: Qt.rgba(191/255,191/255,191/255,1) color: Qt.rgba(191/255,191/255,191/255,1)
FluBadge{ FluBadge{
topRight: true
showZero: true
count:99 count:99
color: Qt.rgba(250/255,173/255,20/255,1) color: Qt.rgba(250/255,173/255,20/255,1)
} }
@ -89,6 +101,8 @@ FluScrollablePage{
radius: 8 radius: 8
color: Qt.rgba(191/255,191/255,191/255,1) color: Qt.rgba(191/255,191/255,191/255,1)
FluBadge{ FluBadge{
topRight: true
showZero: true
count:99 count:99
color: Qt.rgba(82/255,196/255,26/255,1) color: Qt.rgba(82/255,196/255,26/255,1)
} }

View File

@ -4,8 +4,9 @@ import FluentUI
Rectangle{ Rectangle{
property bool isDot: false property bool isDot: false
property bool showZero: true property bool showZero: false
property int count: 0 property int count: 0
property bool topRight: false
id:control id:control
color:Qt.rgba(255/255,77/255,79/255,1) color:Qt.rgba(255/255,77/255,79/255,1)
width: { width: {
@ -14,7 +15,7 @@ Rectangle{
if(count<10){ if(count<10){
return 20 return 20
}else if(count<100){ }else if(count<100){
return 30 return 30
} }
return 40 return 40
} }
@ -30,35 +31,41 @@ Rectangle{
} }
border.width: 1 border.width: 1
border.color: Qt.rgba(1,1,1,1) border.color: Qt.rgba(1,1,1,1)
visible: {
if(showZero)
return true
return count!==0
}
anchors{ anchors{
right: { right: {
if(parent) if(parent && topRight)
return parent.right return parent.right
return undefined return undefined
} }
top: { top: {
if(parent) if(parent && topRight)
return parent.top return parent.top
return undefined return undefined
} }
rightMargin: { rightMargin: {
if(isDot){ if(parent && topRight){
return -2.5 if(isDot){
return -2.5
}
return -(control.width/2)
} }
return -(control.width/2) return 0
} }
topMargin: { topMargin: {
if(isDot){ if(parent && topRight){
return -2.5 if(isDot){
return -2.5
}
return -10
} }
return -10 return 0
} }
} }
visible: {
if(showZero)
return true
return count!==0
}
Text{ Text{
anchors.centerIn: parent anchors.centerIn: parent
color: Qt.rgba(1,1,1,1) color: Qt.rgba(1,1,1,1)

View File

@ -440,6 +440,19 @@ Item {
left:item_icon.right left:item_icon.right
} }
} }
Loader{
anchors{
right: parent.right
rightMargin: 10
verticalCenter: parent.verticalCenter
}
sourceComponent: {
if(model.infoBadge){
return model.infoBadge
}
return undefined
}
}
} }
} }
} }
@ -922,6 +935,12 @@ Item {
function getCurrentIndex(){ function getCurrentIndex(){
return nav_list.currentIndex return nav_list.currentIndex
} }
function getCurrentUrl(){
if(nav_swipe.currentItem){
return nav_swipe.currentItem.url
}
return undefined
}
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++){

View File

@ -9,6 +9,7 @@ QtObject {
property int order : 0 property int order : 0
property int icon property int icon
property Component cusIcon property Component cusIcon
property Component infoBadge
property bool recentlyAdded: false property bool recentlyAdded: false
property bool recentlyUpdated: false property bool recentlyUpdated: false
property string desc property string desc