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

69 lines
2.1 KiB
Swift

import SwiftUI
import Kingfisher
struct TargetData1: Identifiable {
let id = UUID()
let title: String
let progress: Double
let status_str: String
let check: Bool
let image: URL
init(title: String, progress: Double, status_str: String, check: Bool, image: URL) {
self.title = title
self.progress = progress
self.status_str = status_str
self.check = check
self.image = image
}
}
struct TargetItemSwift: View {
@State var target: TargetData1
var body: some View {
VStack(alignment: .leading, spacing: 10) {
HStack {
KFImage(target.image)
.resizable()
.placeholder {
ProgressView()
}
.frame(width: 50, height: 50)
.cornerRadius(5)
.background(Color.gray)
VStack(alignment: .leading) {
Text(target.title)
.font(.headline)
ProgressView(value: target.progress / 100)
.progressViewStyle(LinearProgressViewStyle(tint: Color.blue))
HStack {
Text("进度: \(Int(target.progress))%")
.font(.subheadline)
Spacer()
if target.check {
Text("已逾期")
.foregroundColor(.red)
.font(.subheadline)
.padding(.horizontal,15)
}
}
Text(target.status_str)
.foregroundColor(.red)
.font(.subheadline)
}
}
Divider()
}
.padding(.vertical, 8)
}
}
//#Preview {
// TargetItemSwift( target: TargetData1(title:"AD",progress: 90.00, status_str:"",check: true, image: URL(string: "")))
//}