main
朱子楚\zhuzi 2023-03-11 20:33:29 +08:00
parent eb1744d5f8
commit 5917d23286
3 changed files with 75 additions and 6 deletions

View File

@ -7,6 +7,8 @@ TextField{
property var values:[] property var values:[]
property int fontStyle: FluText.Body property int fontStyle: FluText.Body
property int pixelSize : FluTheme.textSize property int pixelSize : FluTheme.textSize
property int icon: -1
signal itemClicked(string data)
id:input id:input
width: 300 width: 300
@ -24,7 +26,7 @@ TextField{
} }
return FluTheme.isDark ? Qt.rgba(210/255,210/255,210/255,1) : Qt.rgba(96/255,96/255,96/255,1) return FluTheme.isDark ? Qt.rgba(210/255,210/255,210/255,1) : Qt.rgba(96/255,96/255,96/255,1)
} }
rightPadding: 30 rightPadding: icon_right.visible ? 50 : 30
selectByMouse: true selectByMouse: true
font.bold: { font.bold: {
switch (fontStyle) { switch (fontStyle) {
@ -83,12 +85,25 @@ TextField{
anchors{ anchors{
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
right: parent.right right: parent.right
rightMargin: 5 rightMargin: icon_right.visible ? 25 : 5
} }
onClicked:{ onClicked:{
input.text = "" input.text = ""
} }
} }
FluIcon{
id:icon_right
icon: input.icon
iconSize: 15
opacity: 0.5
visible: input.icon != -1
anchors{
verticalCenter: parent.verticalCenter
right: parent.right
rightMargin: 5
}
}
} }
Component.onCompleted: { Component.onCompleted: {
@ -152,6 +167,7 @@ TextField{
hoverEnabled: true hoverEnabled: true
onClicked: { onClicked: {
input_popup.close() input_popup.close()
input.itemClicked(modelData)
input.text = modelData input.text = modelData
} }
} }
@ -175,6 +191,10 @@ TextField{
function searchData(){ function searchData(){
var result = [] var result = []
if(values==null){
list_view.model = result
return
}
values.map(function(item){ values.map(function(item){
if(item.indexOf(input.text)!==-1){ if(item.indexOf(input.text)!==-1){
result.push(item) result.push(item)

View File

@ -3,6 +3,6 @@ import FluentUI 1.0
Rectangle { Rectangle {
color: FluTheme.isDark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(238/255,238/255,238/255,1) color: FluTheme.isDark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(226/255,230/255,234/255,1)
} }

View File

@ -209,8 +209,12 @@ Item {
clip: true clip: true
anchors.margins: 10 anchors.margins: 10
popEnter : Transition{} popEnter : Transition{}
popExit : Transition{} popExit : Transition {
pushEnter : Transition{} NumberAnimation { properties: "y"; from: 0; to: nav_swipe.height; duration: 200 }
}
pushEnter: Transition {
NumberAnimation { properties: "y"; from: nav_swipe.height; to: 0; duration: 200 }
}
pushExit : Transition{} pushExit : Transition{}
replaceEnter : Transition{} replaceEnter : Transition{}
replaceExit : Transition{} replaceExit : Transition{}
@ -257,13 +261,58 @@ Item {
duration: 300 duration: 300
} }
} }
Item{
id:layout_header
width: layout_list.width
height: 50
FluAutoSuggestBox{
width: 280
anchors.centerIn: parent
icon: FluentIcons.Zoom
values: {
var arr = []
if(items==null)
return arr
if(items.children==null)
return arr
for(var i=0;i<items.children.length;i++){
var item = items.children[i]
if(item instanceof FluPaneItem){
arr.push(item.title)
}
}
return arr
}
placeholderText: "查找"
onItemClicked:
(data)=>{
var arr = []
if(items==null)
return arr
if(items.children==null)
return arr
for(var i=0;i<items.children.length;i++){
if(items.children[i].title === data){
if(nav_list.currentIndex === i){
return
}
items.children[i].tap()
nav_list.currentIndex = i
return
}
}
}
}
}
ListView{ ListView{
id:nav_list id:nav_list
property bool enableStack: true property bool enableStack: true
property var stackIndex: [] property var stackIndex: []
clip: true clip: true
anchors{ anchors{
top: parent.top top: layout_header.bottom
left: parent.left left: parent.left
right: parent.right right: parent.right
bottom: layout_footer.top bottom: layout_footer.top