101 lines
3.3 KiB
Swift
101 lines
3.3 KiB
Swift
import SwiftUI
|
|
|
|
struct MacContentView: View {
|
|
@StateObject private var viewModel = MacLibraryViewModel()
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading, spacing: 16) {
|
|
Text("Vorleser (macOS)")
|
|
.font(.title.bold())
|
|
|
|
HStack(spacing: 12) {
|
|
Button("Import EPUB") {
|
|
viewModel.pickEPUB()
|
|
}
|
|
.buttonStyle(.borderedProminent)
|
|
|
|
Button("Load Test Text") {
|
|
viewModel.loadTestText()
|
|
}
|
|
.buttonStyle(.bordered)
|
|
|
|
Button("Load Debug Phonemes") {
|
|
viewModel.loadDebugPhonemes()
|
|
}
|
|
.buttonStyle(.bordered)
|
|
|
|
Button("Verify Bundled Assets") {
|
|
viewModel.updateStatus(AssetVerifier.verify().message)
|
|
}
|
|
.buttonStyle(.bordered)
|
|
|
|
Button("Export Last Audio") {
|
|
viewModel.exportLastAudio()
|
|
}
|
|
.buttonStyle(.bordered)
|
|
|
|
Button("Play") {
|
|
viewModel.playFirstChunk()
|
|
}
|
|
.buttonStyle(.bordered)
|
|
}
|
|
|
|
if let url = viewModel.selectedURL {
|
|
Text("Selected: \(url.lastPathComponent)")
|
|
.font(.callout)
|
|
}
|
|
|
|
if !viewModel.statusMessage.isEmpty {
|
|
Text(viewModel.statusMessage)
|
|
.font(.callout)
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
|
|
Divider()
|
|
|
|
if viewModel.chapters.isEmpty {
|
|
Text("No chapters loaded yet.")
|
|
.foregroundStyle(.secondary)
|
|
} else {
|
|
Picker("Chapter", selection: $viewModel.selectedChapterIndex) {
|
|
ForEach(Array(viewModel.chapters.enumerated()), id: \.offset) { index, chapter in
|
|
Text(chapter.title).tag(index)
|
|
}
|
|
}
|
|
.onChange(of: viewModel.selectedChapterIndex) {
|
|
viewModel.selectChapter(index: viewModel.selectedChapterIndex)
|
|
}
|
|
|
|
List(selection: $viewModel.selectedChunkIndex) {
|
|
ForEach(Array(viewModel.chunks.enumerated()), id: \.offset) { index, chunk in
|
|
HStack(alignment: .top, spacing: 12) {
|
|
VStack(alignment: .leading, spacing: 6) {
|
|
Text("Chunk \(index + 1)")
|
|
.font(.headline)
|
|
Text(chunk.prefix(240))
|
|
.font(.caption)
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
Spacer()
|
|
Button("Play") {
|
|
viewModel.playChunk(at: index)
|
|
}
|
|
.buttonStyle(.bordered)
|
|
}
|
|
.tag(index)
|
|
}
|
|
}
|
|
.listStyle(.plain)
|
|
}
|
|
|
|
Spacer()
|
|
}
|
|
.padding(20)
|
|
.frame(minWidth: 720, minHeight: 520)
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
MacContentView()
|
|
}
|