phase two
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import SwiftUI
|
||||
|
||||
struct IOSProjectsView: View {
|
||||
@EnvironmentObject private var appState: AppState
|
||||
@State private var searchText = ""
|
||||
|
||||
private var filtered: [ProjectSnapshot] {
|
||||
guard !searchText.isEmpty else { return appState.projects }
|
||||
return appState.projects.filter {
|
||||
$0.project.name.localizedCaseInsensitiveContains(searchText) ||
|
||||
$0.project.key.localizedCaseInsensitiveContains(searchText)
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
List(filtered) { snapshot in
|
||||
NavigationLink {
|
||||
IOSProjectDetailView(snapshot: snapshot)
|
||||
} label: {
|
||||
HStack(spacing: 12) {
|
||||
Image(systemName: snapshot.qualityGate.uppercased() == "OK" ? "checkmark.circle.fill" : "xmark.octagon.fill")
|
||||
.foregroundStyle(snapshot.qualityGate.uppercased() == "OK" ? .green : .red)
|
||||
VStack(alignment: .leading, spacing: 3) {
|
||||
Text(snapshot.project.name).fontWeight(.semibold)
|
||||
Text(snapshot.project.key).font(.caption).foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationTitle("Projects")
|
||||
.searchable(text: $searchText, prompt: "Search projects")
|
||||
.refreshable { await appState.refresh() }
|
||||
.overlay {
|
||||
if appState.projects.isEmpty && !appState.isLoading {
|
||||
ContentUnavailableView("No Projects", systemImage: "square.stack.3d.up", description: Text(appState.errorMessage ?? "No SonarQube projects are available."))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user