feat(podcasts): add a Podcasts tab to list and play on demand
All checks were successful
CI / build-and-deploy (push) Successful in 15s
All checks were successful
CI / build-and-deploy (push) Successful in 15s
Surface every podcast in PodcastIndex as a top-level tab instead of a buried sheet. Repurpose PodcastLibraryView into the tab: play/pause toggle per episode, a now-playing bar that opens the full player, swipe/Edit to delete. Uses the shared podcastPlayer so playback state is consistent across tabs. Removes the redundant Podcasts entry from the bookmarks menu. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -597,12 +597,15 @@ struct MiniPlayerView: View {
|
||||
|
||||
// MARK: - Podcast library
|
||||
|
||||
/// The Podcasts tab: lists every podcast generated in the app (from
|
||||
/// `PodcastIndex`) and plays them on demand through the shared player, with a
|
||||
/// now-playing bar that opens the full player.
|
||||
struct PodcastLibraryView: View {
|
||||
let vm: PodcastPlayerViewModel
|
||||
let claude: ClaudeService
|
||||
|
||||
@State private var entries: [PodcastEntry] = []
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@State private var showFullPlayer = false
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
@@ -611,7 +614,7 @@ struct PodcastLibraryView: View {
|
||||
ContentUnavailableView(
|
||||
"No Podcasts",
|
||||
systemImage: "headphones",
|
||||
description: Text("Podcasts you generate will appear here.")
|
||||
description: Text("Podcasts you generate from bookmarks will appear here.")
|
||||
)
|
||||
} else {
|
||||
List {
|
||||
@@ -627,14 +630,12 @@ struct PodcastLibraryView: View {
|
||||
}
|
||||
Spacer()
|
||||
Button {
|
||||
vm.start(articleUrl: entry.articleUrl,
|
||||
articleTitle: entry.title ?? "",
|
||||
claude: claude)
|
||||
dismiss()
|
||||
play(entry)
|
||||
} label: {
|
||||
Image(systemName: "play.circle.fill")
|
||||
Image(systemName: isCurrent(entry) && vm.isPlaying ? "pause.circle.fill" : "play.circle.fill")
|
||||
.font(.system(size: 36))
|
||||
.foregroundStyle(.blue)
|
||||
.contentTransition(.symbolEffect(.replace))
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
@@ -655,16 +656,45 @@ struct PodcastLibraryView: View {
|
||||
}
|
||||
}
|
||||
.navigationTitle("Podcasts")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .topBarTrailing) {
|
||||
Button("Done") { dismiss() }
|
||||
if !entries.isEmpty {
|
||||
ToolbarItem(placement: .topBarTrailing) { EditButton() }
|
||||
}
|
||||
}
|
||||
.overlay(alignment: .bottom) {
|
||||
if !vm.currentArticleUrl.isEmpty {
|
||||
MiniPlayerView(vm: vm) { showFullPlayer = true }
|
||||
.padding(.horizontal)
|
||||
.padding(.bottom, 8)
|
||||
.transition(.move(edge: .bottom).combined(with: .opacity))
|
||||
}
|
||||
}
|
||||
.animation(.spring(duration: 0.3), value: vm.currentArticleUrl.isEmpty)
|
||||
.sheet(isPresented: $showFullPlayer) {
|
||||
PodcastPlayerView(
|
||||
vm: vm,
|
||||
articleUrl: vm.currentArticleUrl,
|
||||
articleTitle: vm.currentArticleTitle,
|
||||
claude: claude,
|
||||
stopOnDismiss: false
|
||||
)
|
||||
}
|
||||
}
|
||||
.onAppear { entries = PodcastIndex.all() }
|
||||
}
|
||||
|
||||
private func isCurrent(_ entry: PodcastEntry) -> Bool {
|
||||
vm.currentArticleUrl == entry.articleUrl
|
||||
}
|
||||
|
||||
private func play(_ entry: PodcastEntry) {
|
||||
if isCurrent(entry) {
|
||||
vm.togglePlayPause()
|
||||
} else {
|
||||
vm.start(articleUrl: entry.articleUrl, articleTitle: entry.title ?? "", claude: claude)
|
||||
}
|
||||
}
|
||||
|
||||
private func deleteEntry(_ entry: PodcastEntry) {
|
||||
PodcastIndex.remove(articleUrl: entry.articleUrl)
|
||||
entries.removeAll { $0.articleUrl == entry.articleUrl }
|
||||
|
||||
Reference in New Issue
Block a user