experiment(PodcastPlayerView): add swipe-to-delete in PodcastLibraryView, stops player if active
This commit is contained in:
@@ -589,30 +589,42 @@ struct PodcastLibraryView: View {
|
|||||||
description: Text("Podcasts you generate will appear here.")
|
description: Text("Podcasts you generate will appear here.")
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
List(entries) { entry in
|
List {
|
||||||
HStack(spacing: 12) {
|
ForEach(entries) { entry in
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
HStack(spacing: 12) {
|
||||||
Text(entry.title ?? entry.articleUrl)
|
VStack(alignment: .leading, spacing: 4) {
|
||||||
.font(.system(size: 15, weight: .medium))
|
Text(entry.title ?? entry.articleUrl)
|
||||||
.lineLimit(2)
|
.font(.system(size: 15, weight: .medium))
|
||||||
Text(entry.createdAt.formatted(date: .abbreviated, time: .omitted))
|
.lineLimit(2)
|
||||||
.font(.system(size: 12))
|
Text(entry.createdAt.formatted(date: .abbreviated, time: .omitted))
|
||||||
.foregroundStyle(.secondary)
|
.font(.system(size: 12))
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
}
|
||||||
|
Spacer()
|
||||||
|
Button {
|
||||||
|
vm.start(articleUrl: entry.articleUrl,
|
||||||
|
articleTitle: entry.title ?? "",
|
||||||
|
claude: claude)
|
||||||
|
dismiss()
|
||||||
|
} label: {
|
||||||
|
Image(systemName: "play.circle.fill")
|
||||||
|
.font(.system(size: 36))
|
||||||
|
.foregroundStyle(.blue)
|
||||||
|
}
|
||||||
|
.buttonStyle(.plain)
|
||||||
}
|
}
|
||||||
Spacer()
|
.padding(.vertical, 6)
|
||||||
Button {
|
.swipeActions(edge: .trailing, allowsFullSwipe: true) {
|
||||||
vm.start(articleUrl: entry.articleUrl,
|
Button(role: .destructive) {
|
||||||
articleTitle: entry.title ?? "",
|
deleteEntry(entry)
|
||||||
claude: claude)
|
} label: {
|
||||||
dismiss()
|
Label("Delete", systemImage: "trash")
|
||||||
} label: {
|
}
|
||||||
Image(systemName: "play.circle.fill")
|
|
||||||
.font(.system(size: 36))
|
|
||||||
.foregroundStyle(.blue)
|
|
||||||
}
|
}
|
||||||
.buttonStyle(.plain)
|
|
||||||
}
|
}
|
||||||
.padding(.vertical, 6)
|
.onDelete { indexSet in
|
||||||
|
indexSet.forEach { deleteEntry(entries[$0]) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.listStyle(.plain)
|
.listStyle(.plain)
|
||||||
}
|
}
|
||||||
@@ -627,4 +639,10 @@ struct PodcastLibraryView: View {
|
|||||||
}
|
}
|
||||||
.onAppear { entries = PodcastIndex.all() }
|
.onAppear { entries = PodcastIndex.all() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func deleteEntry(_ entry: PodcastEntry) {
|
||||||
|
PodcastIndex.remove(articleUrl: entry.articleUrl)
|
||||||
|
entries.removeAll { $0.articleUrl == entry.articleUrl }
|
||||||
|
if vm.currentArticleUrl == entry.articleUrl { vm.stop() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user