45 lines
1.2 KiB
Swift
45 lines
1.2 KiB
Swift
|
|
// 滑动选择标签列表
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct NavBarView: View {
|
|
@Binding var tags: [Tag]
|
|
@Binding var tagActiveIndex: Int
|
|
@Binding var isShowPopup: Bool
|
|
|
|
var body: some View {
|
|
HStack {
|
|
ScrollView(.horizontal, showsIndicators: false) {
|
|
HStack(spacing: 16) {
|
|
ForEach(tags.indices, id: \.self) { index in
|
|
Button {
|
|
tagActiveIndex = index
|
|
} label: {
|
|
Text(tags[index].name)
|
|
.SetTextStyle(size: tagActiveIndex == index ? 15 : 14, color: tagActiveIndex == index ? .black : .gray)
|
|
}
|
|
}
|
|
}
|
|
.font(.system(size: 16))
|
|
}
|
|
|
|
// 右侧下拉按钮
|
|
Button {
|
|
withAnimation {
|
|
isShowPopup = true
|
|
}
|
|
} label: {
|
|
Image(systemName: "chevron.down")
|
|
}
|
|
.foregroundStyle(.black.opacity(0.5))
|
|
}
|
|
.padding(.horizontal, 12)
|
|
.padding(.vertical, 3)
|
|
.background(.white)
|
|
}
|
|
}
|