copinism-ios/copinism/Views/Mine/MytargetStatus.swift
2024-06-04 09:41:01 +08:00

91 lines
2.7 KiB
Swift

import SwiftUI
//struct TargetData1: Identifiable{
// let id: UUID
// let title: String
// let progress: Double
// let status_str: String
// let check: Bool
// let image: String
// init(id: UUID = UUID(),title: String, progress: Double, status_str: String, check: Bool, image: String) {
// self.id = id
// self.title = title
// self.progress = progress
// self.status_str = status_str
// self.check = check
// self.image = image
// }
//}
struct ContentView1: View {
@State var items: [TargetData1] = [
// TargetData1(title:"AD",progress: 14.29, status_str:"",check: true, image:"image-5"),
// TargetData1(title:"AD",progress: 14.29, status_str:"", check:true, image:"image-5"),
// TargetData1(title:"",progress: 14.29,status_str: "",check: true, image:"image-5"),
// TargetData1(title:"AD",progress: 14.29, status_str:"",check: true, image:"image-5")
]
@State private var selectedTab = "全部"
var body: some View {
VStack(spacing: 0) {
// Top Tab Bar
HStack {
TabButton(title: "全部", selectedTab: $selectedTab)
TabButton(title: "进行中", selectedTab: $selectedTab)
TabButton(title: "已完成", selectedTab: $selectedTab)
TabButton(title: "已逾期", selectedTab: $selectedTab)
}
.frame(height: 50)
.background(Color.white)
ScrollView(){
ForEach(items){item in
TargetItemSwift(target:item)
}
}
// Item List
// List(items)
}
.background(Color(UIColor.systemGroupedBackground))
}
}
struct TabButton: View {
var title: String
@Binding var selectedTab: String
var body: some View {
Button(action: {
selectedTab = title
}) {
VStack {
Text(title)
.foregroundColor(selectedTab == title ? Color.blue : Color.gray)
if selectedTab == title {
Rectangle()
.frame(height: 2)
.foregroundColor(Color.blue)
} else {
Rectangle()
.frame(height: 2)
.foregroundColor(Color.clear)
}
}
}
.frame(maxWidth: .infinity)
}
}
struct ContentView1_Previews: PreviewProvider {
static var previews: some View {
ContentView1()
}
}