summaryrefslogtreecommitdiff
path: root/Rune/Views/Domains/DomainListView.swift
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-04-11 11:48:40 -0500
committerChristian Cleberg <[email protected]>2026-04-11 11:48:40 -0500
commitfcf864a15b70e4ecb5bd789b1db3116221c34394 (patch)
treef15315324b9f95286b6bf7392dd0ccaee210c2de /Rune/Views/Domains/DomainListView.swift
parentcf587aa0573ac4f34e1effe70108a9eca82093ac (diff)
downloadrune-fcf864a15b70e4ecb5bd789b1db3116221c34394.tar.gz
rune-fcf864a15b70e4ecb5bd789b1db3116221c34394.tar.bz2
rune-fcf864a15b70e4ecb5bd789b1db3116221c34394.zip
add FUNDING.yml
Diffstat (limited to 'Rune/Views/Domains/DomainListView.swift')
-rw-r--r--Rune/Views/Domains/DomainListView.swift71
1 files changed, 43 insertions, 28 deletions
diff --git a/Rune/Views/Domains/DomainListView.swift b/Rune/Views/Domains/DomainListView.swift
index d728bd7..68f2ede 100644
--- a/Rune/Views/Domains/DomainListView.swift
+++ b/Rune/Views/Domains/DomainListView.swift
@@ -15,43 +15,58 @@ struct DomainListView: View {
}
.navigationTitle("Domains")
}
- .alert("API Error", isPresented: errorBinding) {
- Button("OK", role: .cancel) {}
- } message: {
- Text(viewModel.errorMessage ?? "")
- }
}
@ViewBuilder
private func content(client: NjallaClient) -> some View {
- if viewModel.isLoadingDomains && viewModel.domains.isEmpty {
- ProgressView()
- } else if viewModel.domains.isEmpty {
- ContentUnavailableView("No Domains", systemImage: "globe", description: Text("No domains found on this account."))
- } else {
- List(viewModel.domains) { domain in
- NavigationLink {
- DomainDetailView(domainName: domain.name, viewModel: viewModel, client: client)
- } label: {
- DomainRow(domain: domain)
+ List {
+ if let errorMessage = viewModel.domainsErrorMessage {
+ Section {
+ InlineErrorView(message: errorMessage, retryTitle: "Retry Domains") {
+ Task {
+ await viewModel.loadDomains(client: client)
+ }
+ }
+ .listRowInsets(EdgeInsets(top: 8, leading: 16, bottom: 8, trailing: 16))
}
}
- .listStyle(.insetGrouped)
- .refreshable {
- await viewModel.loadDomains(client: client)
- }
- }
- }
- private var errorBinding: Binding<Bool> {
- Binding(
- get: { viewModel.errorMessage != nil },
- set: { newValue in
- if !newValue {
- viewModel.errorMessage = nil
+ if (!viewModel.hasLoadedDomains || viewModel.isLoadingDomains) && viewModel.domains.isEmpty {
+ Section {
+ HStack {
+ Spacer()
+ ProgressView("Loading Domains")
+ Spacer()
+ }
+ }
+ } else if viewModel.domains.isEmpty {
+ Section {
+ ContentUnavailableView(
+ "No Domains",
+ systemImage: "globe",
+ description: Text("No domains found. Pull to refresh after domains are added to this account.")
+ )
+ }
+ } else {
+ ForEach(viewModel.domains) { domain in
+ NavigationLink {
+ DomainDetailView(domainName: domain.name, viewModel: viewModel, client: client)
+ } label: {
+ DomainRow(domain: domain)
+ }
}
}
- )
+ }
+ .listStyle(.insetGrouped)
+ .refreshable {
+ await viewModel.loadDomains(client: client)
+ }
+ .overlay(alignment: .top) {
+ if viewModel.isLoadingDomains && !viewModel.domains.isEmpty {
+ ProgressView()
+ .padding(.top, 8)
+ }
+ }
}
}