55 lines
2.0 KiB
Swift
55 lines
2.0 KiB
Swift
import SwiftUI
|
|
|
|
struct IOSProjectDetailView: View {
|
|
let snapshot: ProjectSnapshot
|
|
|
|
private let metrics: [(String, String, String)] = [
|
|
("bugs", "Bugs", "ladybug"),
|
|
("vulnerabilities", "Vulnerabilities", "lock.trianglebadge.exclamationmark"),
|
|
("code_smells", "Code Smells", "exclamationmark.bubble"),
|
|
("coverage", "Coverage", "chart.bar"),
|
|
("duplicated_lines_density", "Duplications", "doc.on.doc")
|
|
]
|
|
|
|
var body: some View {
|
|
List {
|
|
Section("Quality Gate") {
|
|
HStack {
|
|
Label(snapshot.qualityGate.uppercased() == "OK" ? "Passed" : "Failed",
|
|
systemImage: snapshot.qualityGate.uppercased() == "OK" ? "checkmark.circle.fill" : "xmark.octagon.fill")
|
|
.foregroundStyle(snapshot.qualityGate.uppercased() == "OK" ? .green : .red)
|
|
Spacer()
|
|
Text(snapshot.qualityGate)
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
}
|
|
|
|
Section("Metrics") {
|
|
ForEach(metrics, id: \.0) { metric in
|
|
HStack {
|
|
Label(metric.1, systemImage: metric.2)
|
|
Spacer()
|
|
Text(displayValue(metric.0))
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
}
|
|
}
|
|
|
|
Section("Project") {
|
|
LabeledContent("Key", value: snapshot.project.key)
|
|
if let date = snapshot.project.lastAnalysisDate {
|
|
LabeledContent("Last analysis", value: date)
|
|
}
|
|
}
|
|
}
|
|
.navigationTitle(snapshot.project.name)
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
}
|
|
|
|
private func displayValue(_ metric: String) -> String {
|
|
guard let value = snapshot.measures[metric] else { return "—" }
|
|
if metric == "coverage" || metric == "duplicated_lines_density" { return "\(value)%" }
|
|
return value
|
|
}
|
|
}
|