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
FluPaneItem{
id:item_home
property int count: 8
title:lang.home
infoBadge:FluBadge{
count: item_home.count
}
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:{
if(navigationView.getCurrentUrl()){
item_home.count = 0
}
navigationView.push("qrc:/example/qml/page/T_Home.qml")
}
}

View File

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

View File

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

View File

@ -440,6 +440,19 @@ Item {
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(){
return nav_list.currentIndex
}
function getCurrentUrl(){
if(nav_swipe.currentItem){
return nav_swipe.currentItem.url
}
return undefined
}
function startPageByItem(data){
var items = getItems()
for(var i=0;i<items.length;i++){

View File

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