diff options
| author | Christian Cleberg <[email protected]> | 2026-03-17 23:19:43 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-03-17 23:19:43 -0500 |
| commit | 32ad6cab8d58d99ebd8a28e8fa6e6f4e587cb1e5 (patch) | |
| tree | ee36d421d704e508d5617d803b4c8cbdb4804fe1 /Hutch/Views/Repositories/RepositoryRowView.swift | |
| parent | 8f2057c53e9009c2529c9c4849c914666c0e4b40 (diff) | |
| download | hutch-32ad6cab8d58d99ebd8a28e8fa6e6f4e587cb1e5.tar.gz hutch-32ad6cab8d58d99ebd8a28e8fa6e6f4e587cb1e5.tar.bz2 hutch-32ad6cab8d58d99ebd8a28e8fa6e6f4e587cb1e5.zip | |
v1.0
Diffstat (limited to 'Hutch/Views/Repositories/RepositoryRowView.swift')
| -rw-r--r-- | Hutch/Views/Repositories/RepositoryRowView.swift | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/Hutch/Views/Repositories/RepositoryRowView.swift b/Hutch/Views/Repositories/RepositoryRowView.swift new file mode 100644 index 0000000..9f8cd15 --- /dev/null +++ b/Hutch/Views/Repositories/RepositoryRowView.swift @@ -0,0 +1,85 @@ +import SwiftUI + +struct RepositoryRowView: View { + let repository: RepositorySummary + + var body: some View { + VStack(alignment: .leading, spacing: 4) { + HStack(alignment: .firstTextBaseline) { + Text(repository.name) + .font(.headline) + + Spacer() + + if repository.service == .hg { + Text("HG") + .font(.caption2.weight(.medium)) + .padding(.horizontal, 6) + .padding(.vertical, 2) + .background(Color.cyan.opacity(0.15), in: Capsule()) + .foregroundStyle(.cyan) + } + + VisibilityBadge(visibility: repository.visibility) + } + + Text(repository.owner.canonicalName) + .font(.subheadline) + .foregroundStyle(.secondary) + + if let description = repository.description, + !description.isEmpty { + Text(description) + .font(.subheadline) + .foregroundStyle(.secondary) + .lineLimit(2) + } + + HStack(spacing: 12) { + if let head = repository.head { + Label(head.name, systemImage: "arrow.triangle.branch") + .font(.caption) + .foregroundStyle(.secondary) + } + + Spacer() + + Text(repository.updated.relativeDescription) + .font(.caption) + .foregroundStyle(.tertiary) + } + } + .padding(.vertical, 2) + } +} + +// MARK: - VisibilityBadge + +struct VisibilityBadge: View { + let visibility: Visibility + + var body: some View { + Text(label) + .font(.caption2.weight(.medium)) + .padding(.horizontal, 6) + .padding(.vertical, 2) + .background(color.opacity(0.15), in: Capsule()) + .foregroundStyle(color) + } + + private var label: String { + switch visibility { + case .public: "PUBLIC" + case .unlisted: "UNLISTED" + case .private: "PRIVATE" + } + } + + private var color: Color { + switch visibility { + case .public: .green + case .unlisted: .orange + case .private: .red + } + } +} |
