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.
69 lines
2.4 KiB
69 lines
2.4 KiB
import SwiftUI
|
|
|
|
struct ContentView: View {
|
|
@EnvironmentObject private var settings: AppSettings
|
|
@StateObject private var coordinator = ConversionCoordinator()
|
|
@State private var showSettings = false
|
|
|
|
var body: some View {
|
|
VStack(spacing: 16) {
|
|
DropZoneView()
|
|
|
|
if !coordinator.items.isEmpty {
|
|
FileListView()
|
|
|
|
if !coordinator.problemItems.isEmpty {
|
|
Text("\(coordinator.problemItems.count) Datei(en) brauchen Aufmerksamkeit.")
|
|
.font(.footnote)
|
|
.foregroundStyle(.orange)
|
|
}
|
|
|
|
HStack {
|
|
ProgressView(value: coordinator.overallProgress)
|
|
Button("Leeren") { coordinator.removeAll() }
|
|
.disabled(coordinator.isRunning)
|
|
}
|
|
}
|
|
|
|
Divider()
|
|
|
|
HStack {
|
|
Button("Einstellungen…") { showSettings = true }
|
|
Spacer()
|
|
Button("Start") {
|
|
guard let target = settings.targetFolder else { return }
|
|
coordinator.start(targetFolder: target)
|
|
}
|
|
.keyboardShortcut(.defaultAction)
|
|
.disabled(coordinator.items.isEmpty || coordinator.isRunning || settings.targetFolder == nil)
|
|
}
|
|
}
|
|
.padding(20)
|
|
.frame(minWidth: 520, minHeight: 460)
|
|
.environmentObject(coordinator)
|
|
.sheet(isPresented: $showSettings) {
|
|
SettingsView()
|
|
}
|
|
.alert(
|
|
"Zieldatei existiert bereits",
|
|
isPresented: Binding(
|
|
get: { !coordinator.pendingConflicts.isEmpty },
|
|
set: { isPresented in
|
|
if !isPresented { coordinator.cancelConflictResolution() }
|
|
}
|
|
)
|
|
) {
|
|
Button("Überspringen") { coordinator.resolveConflicts(overwrite: false) }
|
|
Button("Ersetzen", role: .destructive) { coordinator.resolveConflicts(overwrite: true) }
|
|
Button("Abbrechen", role: .cancel) { coordinator.cancelConflictResolution() }
|
|
} message: {
|
|
Text(conflictMessage)
|
|
}
|
|
}
|
|
|
|
private var conflictMessage: String {
|
|
let names = coordinator.pendingConflicts.map(\.fileName).joined(separator: ", ")
|
|
return "Für folgende Datei(en) existiert die Zieldatei schon: \(names). Ersetzen oder überspringen?"
|
|
}
|
|
}
|