You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
2.0 KiB

import SwiftUI
struct FileListView: View {
@EnvironmentObject private var coordinator: ConversionCoordinator
var body: some View {
List(coordinator.items) { item in
HStack {
VStack(alignment: .leading, spacing: 2) {
Text(item.fileName)
.lineLimit(1)
.truncationMode(.middle)
statusText(for: item.status)
.font(.caption)
.foregroundStyle(item.status.needsAttention ? Color.orange : .secondary)
}
Spacer()
statusIndicator(for: item.status)
}
.padding(.vertical, 2)
}
}
@ViewBuilder
private func statusText(for status: DropItem.Status) -> some View {
switch status {
case .waiting:
Text("Wartet …")
case .running(let progress):
Text("\(Int(progress * 100)) %")
case .skipped(let reason):
Text(reason.errorDescription ?? "Übersprungen")
case .rejected(let reason):
Text(reason.errorDescription ?? "Abgelehnt")
case .succeeded(let destination):
Text("Fertig — \(destination.lastPathComponent)")
case .failed(let message):
Text(message)
}
}
@ViewBuilder
private func statusIndicator(for status: DropItem.Status) -> some View {
switch status {
case .waiting:
Image(systemName: "clock")
.foregroundStyle(.secondary)
case .running(let progress):
ProgressView(value: progress)
.frame(width: 60)
case .skipped:
Image(systemName: "arrow.uturn.forward.circle")
.foregroundStyle(.secondary)
case .rejected, .failed:
Image(systemName: "exclamationmark.triangle.fill")
.foregroundStyle(.orange)
case .succeeded:
Image(systemName: "checkmark.circle.fill")
.foregroundStyle(.green)
}
}
}

Powered by TurnKey Linux.