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/CommitLogView.swift | |
| parent | 8f2057c53e9009c2529c9c4849c914666c0e4b40 (diff) | |
| download | hutch-32ad6cab8d58d99ebd8a28e8fa6e6f4e587cb1e5.tar.gz hutch-32ad6cab8d58d99ebd8a28e8fa6e6f4e587cb1e5.tar.bz2 hutch-32ad6cab8d58d99ebd8a28e8fa6e6f4e587cb1e5.zip | |
v1.0
Diffstat (limited to 'Hutch/Views/Repositories/CommitLogView.swift')
| -rw-r--r-- | Hutch/Views/Repositories/CommitLogView.swift | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/Hutch/Views/Repositories/CommitLogView.swift b/Hutch/Views/Repositories/CommitLogView.swift new file mode 100644 index 0000000..d63c5eb --- /dev/null +++ b/Hutch/Views/Repositories/CommitLogView.swift @@ -0,0 +1,59 @@ +import SwiftUI + +struct CommitLogView: View { + let viewModel: RepositoryDetailViewModel + + var body: some View { + List { + ForEach(viewModel.commits) { commit in + NavigationLink(value: commit) { + CommitRowView(commit: commit) + } + .task { + await viewModel.loadMoreCommitsIfNeeded(currentItem: commit) + } + } + + if viewModel.isLoadingMoreCommits { + HStack { + Spacer() + ProgressView() + Spacer() + } + .listRowSeparator(.hidden) + } + } + .listStyle(.plain) + .overlay { + if viewModel.isLoadingCommits, viewModel.commits.isEmpty { + SRHTLoadingStateView(message: "Loading commits…") + } else if let error = viewModel.error, viewModel.commits.isEmpty { + SRHTErrorStateView( + title: "Couldn't Load Commits", + message: error, + retryAction: { await viewModel.loadCommits() } + ) + } else if viewModel.commits.isEmpty { + ContentUnavailableView( + "No Commits", + systemImage: "clock.arrow.trianglehead.counterclockwise.rotate.90", + description: Text("This repository has no commit history.") + ) + } + } + .task { + if viewModel.commits.isEmpty { + await viewModel.loadCommits() + } + } + .refreshable { + await viewModel.loadCommits() + } + .navigationDestination(for: CommitSummary.self) { commit in + CommitDetailView( + commitSummary: commit, + repository: viewModel.repository + ) + } + } +} |
