add offline banner, sync status indicators

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-13 21:34:12 +01:00
parent 00b5632f3f
commit deb4c1d15c

View File

@@ -35,12 +35,46 @@ struct ContentView: View {
messages: viewModel.messages
)
}
.safeAreaInset(edge: .bottom) {
statusBanner
}
.task {
await viewModel.syncNow()
viewModel.startPeriodicSync()
}
}
@ViewBuilder
private var statusBanner: some View {
switch viewModel.syncState {
case .error(let message):
HStack {
Image(systemName: "wifi.slash")
Text("Offline — showing cached mail")
Spacer()
Button("Retry") {
Task { await viewModel.syncNow() }
}
.buttonStyle(.borderless)
}
.font(.caption)
.padding(8)
.background(.yellow.opacity(0.2))
case .syncing(let mailbox):
HStack {
ProgressView()
.controlSize(.small)
Text("Syncing\(mailbox.map { " \($0)" } ?? "")")
.font(.caption)
Spacer()
}
.padding(8)
.background(.blue.opacity(0.1))
case .idle:
EmptyView()
}
}
private func connectAccount() {
guard let (config, credentials) = accountSetup.buildConfig() else { return }
do {