import SwiftUI /// What this instance hosts. `repo search` needs a query; this is the /// listing you read when you do not know a name yet. struct ExploreView: View { @State private var list: PagedListModel init(client: GitbayClient) { _list = State(initialValue: PagedListModel( client: client, argv: ["explore"], emptyMessage: "This instance hosts no public repositories." )) } var body: some View { List { ForEach(list.state.value ?? []) { repo in NavigationLink(value: RepoRoute.repo(repo.path)) { VStack(alignment: .leading, spacing: 4) { HStack(spacing: 6) { Text(repo.owner + "/") .foregroundStyle(.secondary) + Text(repo.name) .fontWeight(.medium) if repo.isArchived { GBChip("archived", .secondary) } } .font(.gbSans(.subheadline)) .lineLimit(1) if let description = repo.description, !description.isEmpty { Text(description) .font(.gbSans(.caption)) .foregroundStyle(.secondary) .lineLimit(2) } if let topics = repo.topics, !topics.isEmpty { ScrollView(.horizontal, showsIndicators: false) { HStack(spacing: 6) { ForEach(topics, id: \.self) { topic in GBChip(topic, .gbAccent) } } } } } .padding(.vertical, 2) } } PageFooter(list: list) } .overlay { LoadStateOverlay(state: list.state) } .navigationTitle("Explore") .toolbar { AccountMenu() } .task { if list.state.value == nil { await list.reload() } } .refreshable { await list.reload() } } }