add offline banner, sync status indicators
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -35,12 +35,46 @@ struct ContentView: View {
|
|||||||
messages: viewModel.messages
|
messages: viewModel.messages
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
.safeAreaInset(edge: .bottom) {
|
||||||
|
statusBanner
|
||||||
|
}
|
||||||
.task {
|
.task {
|
||||||
await viewModel.syncNow()
|
await viewModel.syncNow()
|
||||||
viewModel.startPeriodicSync()
|
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() {
|
private func connectAccount() {
|
||||||
guard let (config, credentials) = accountSetup.buildConfig() else { return }
|
guard let (config, credentials) = accountSetup.buildConfig() else { return }
|
||||||
do {
|
do {
|
||||||
|
|||||||
Reference in New Issue
Block a user