- Chapter navigation with auto-scroll to current chapter and end-of-chapter sleep timer - Opt-in listening history (local-only) with XML export and per-item quick menu - Bookmarks with server sync via Audiobookshelf API - Live MB counter during downloads via URLSessionDownloadTask delegate - In-progress downloads shown in "Heruntergeladen" with dimmed cover + ring overlay - Cover image cache (50 MB memory / 500 MB disk URLCache) - German/English localization (de.lproj, en.lproj) - Loading spinner now triggers immediately on view switch instead of waiting for the network Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
98 lines
2.3 KiB
Swift
98 lines
2.3 KiB
Swift
import SwiftUI
|
|
|
|
struct LibraryGridView: View {
|
|
let items: [LibraryItem]
|
|
var onRefresh: (() async -> Void)? = nil
|
|
var dimDownloading: Bool = false
|
|
var onSelect: (LibraryItem) -> Void
|
|
|
|
@AppStorage("libraryCoverSize") private var coverSize: Double = Self.defaultCoverSize
|
|
|
|
var body: some View {
|
|
#if os(macOS)
|
|
VStack(spacing: 0) {
|
|
zoomBar
|
|
gridContent
|
|
}
|
|
#else
|
|
gridContent
|
|
#endif
|
|
}
|
|
|
|
private var gridContent: some View {
|
|
ScrollView {
|
|
LazyVGrid(columns: gridColumns, spacing: gridSpacing) {
|
|
ForEach(items) { item in
|
|
LibraryItemCell(item: item, dimDownloading: dimDownloading)
|
|
.onTapGesture { onSelect(item) }
|
|
}
|
|
}
|
|
#if os(iOS)
|
|
.padding(.horizontal, 8)
|
|
.padding(.vertical, 4)
|
|
#else
|
|
.padding(20)
|
|
#endif
|
|
}
|
|
#if os(iOS)
|
|
.refreshable { await onRefresh?() }
|
|
#endif
|
|
}
|
|
|
|
#if os(macOS)
|
|
private var zoomBar: some View {
|
|
HStack(spacing: 8) {
|
|
Spacer()
|
|
Image(systemName: "rectangle.grid.3x2")
|
|
.font(.caption2)
|
|
.foregroundStyle(.secondary)
|
|
Slider(value: $coverSize, in: Self.minCoverSize...Self.maxCoverSize)
|
|
.frame(maxWidth: 220)
|
|
Image(systemName: "square")
|
|
.font(.caption2)
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
.padding(.horizontal, 12)
|
|
.padding(.vertical, 4)
|
|
}
|
|
#endif
|
|
|
|
private var gridColumns: [GridItem] {
|
|
[GridItem(.adaptive(minimum: CGFloat(coverSize)), spacing: gridSpacing)]
|
|
}
|
|
|
|
private var gridSpacing: CGFloat {
|
|
#if os(iOS)
|
|
return 8
|
|
#else
|
|
return 20
|
|
#endif
|
|
}
|
|
|
|
// MARK: - Cover-Größen-Defaults (plattformabhängig)
|
|
|
|
private static var defaultCoverSize: Double {
|
|
#if os(iOS)
|
|
return 110
|
|
#else
|
|
return 180
|
|
#endif
|
|
}
|
|
|
|
private static var minCoverSize: Double {
|
|
#if os(iOS)
|
|
return 80
|
|
#else
|
|
return 120
|
|
#endif
|
|
}
|
|
|
|
private static var maxCoverSize: Double {
|
|
#if os(iOS)
|
|
return 200
|
|
#else
|
|
return 320
|
|
#endif
|
|
}
|
|
}
|