summaryrefslogtreecommitdiff
path: root/Hutch/Views/Repositories/ArtifactsView.swift
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-03-17 23:19:43 -0500
committerChristian Cleberg <[email protected]>2026-03-17 23:19:43 -0500
commit32ad6cab8d58d99ebd8a28e8fa6e6f4e587cb1e5 (patch)
treeee36d421d704e508d5617d803b4c8cbdb4804fe1 /Hutch/Views/Repositories/ArtifactsView.swift
parent8f2057c53e9009c2529c9c4849c914666c0e4b40 (diff)
downloadhutch-32ad6cab8d58d99ebd8a28e8fa6e6f4e587cb1e5.tar.gz
hutch-32ad6cab8d58d99ebd8a28e8fa6e6f4e587cb1e5.tar.bz2
hutch-32ad6cab8d58d99ebd8a28e8fa6e6f4e587cb1e5.zip
v1.0
Diffstat (limited to 'Hutch/Views/Repositories/ArtifactsView.swift')
-rw-r--r--Hutch/Views/Repositories/ArtifactsView.swift73
1 files changed, 73 insertions, 0 deletions
diff --git a/Hutch/Views/Repositories/ArtifactsView.swift b/Hutch/Views/Repositories/ArtifactsView.swift
new file mode 100644
index 0000000..ef3b972
--- /dev/null
+++ b/Hutch/Views/Repositories/ArtifactsView.swift
@@ -0,0 +1,73 @@
+import SwiftUI
+
+struct ArtifactsView: View {
+ let viewModel: RepositoryDetailViewModel
+ @Environment(\.openURL) private var openURL
+
+ var body: some View {
+ List {
+ ForEach(viewModel.referenceArtifacts) { refArtifacts in
+ Section(refArtifacts.name) {
+ ForEach(refArtifacts.artifacts) { artifact in
+ ArtifactRow(artifact: artifact) {
+ openURL(artifact.url)
+ }
+ }
+ }
+ }
+ }
+ .listStyle(.insetGrouped)
+ .overlay {
+ if viewModel.isLoadingArtifacts, viewModel.referenceArtifacts.isEmpty {
+ SRHTLoadingStateView(message: "Loading artifacts…")
+ } else if let error = viewModel.error, viewModel.referenceArtifacts.isEmpty {
+ SRHTErrorStateView(
+ title: "Couldn't Load Artifacts",
+ message: error,
+ retryAction: { await viewModel.loadArtifacts() }
+ )
+ } else if viewModel.referenceArtifacts.isEmpty {
+ ContentUnavailableView(
+ "No Artifacts",
+ systemImage: "archivebox",
+ description: Text("This repository has no release artifacts.")
+ )
+ }
+ }
+ .task {
+ if viewModel.referenceArtifacts.isEmpty {
+ await viewModel.loadArtifacts()
+ }
+ }
+ .refreshable {
+ await viewModel.loadArtifacts()
+ }
+ }
+}
+
+private struct ArtifactRow: View {
+ let artifact: ArtifactInfo
+ let onDownload: () -> Void
+
+ var body: some View {
+ HStack {
+ VStack(alignment: .leading, spacing: 4) {
+ Text(artifact.filename)
+ .font(.subheadline)
+
+ Text(artifact.size.formattedByteCount)
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ }
+
+ Spacer()
+
+ Button {
+ onDownload()
+ } label: {
+ Image(systemName: "arrow.down.circle")
+ .imageScale(.large)
+ }
+ }
+ }
+}