Two changes. Tapping a card did nothing. LibraryCard carried its own press-scale effect via onLongPressGesture(minimumDuration: 0), and a zero-duration long press fires immediately and swallows the tap the host attaches. It was invisible in the prototype because nothing was listening for taps there. LibraryCard is now purely presentational and the grid wraps it in a Button with the existing RowPressStyle, which gets the same scale without competing for the gesture. The list now speaks the same design as the cards: paper ground, the color chip where the favicon was, serif quoted title, monospaced domain/date, serif-italic AI summary, monospaced tag chips. Everything the old row carried is still there — unread state, excerpt, tags, podcast affordance, reading progress — along with all swipe actions, since it is still a List. BookmarkListRow takes a style rather than being rewritten, because the Tags and Search screens use the same row and should not be silently restyled by a change aimed at the bookmarks screen. The tag filter strip moved up to BookmarksView. Both layouts speak the same language now, so the strip belongs to the screen rather than to one mode — which also retires the rule that leaving cards mode had to clear the tag filter to stop it becoming invisible. The tag chip strip fades at its trailing edge; without it a tag clipped mid-word reads as broken text rather than as something scrollable. Verified in both layouts and both color schemes against the live server. Full suite passes (16 tests). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JgLHztZGaEHvS3KNeGQmRM
83 lines
2.8 KiB
Swift
83 lines
2.8 KiB
Swift
import SwiftUI
|
|
|
|
/// The library's card presentation of `viewModel.bookmarks`. Drops into
|
|
/// BookmarksView's content area in place of the List and carries the same
|
|
/// actions — tap to open, long press for the full menu. The filter strip above
|
|
/// it belongs to BookmarksView, since both layouts share it.
|
|
struct LibraryGridView: View {
|
|
@Bindable var viewModel: BookmarksViewModel
|
|
let onOpen: (Bookmark) -> Void
|
|
let onEdit: (Bookmark) -> Void
|
|
|
|
@Environment(\.openURL) private var openURL
|
|
@State private var showFullPlayer = false
|
|
@State private var episodePicker: Bookmark?
|
|
|
|
private var items: [LibraryItem] {
|
|
viewModel.bookmarks.map(LibraryItem.init(bookmark:))
|
|
}
|
|
|
|
var body: some View {
|
|
ScrollView {
|
|
LazyVGrid(
|
|
columns: Array(repeating: GridItem(.flexible(), spacing: 8), count: 3),
|
|
spacing: 8
|
|
) {
|
|
ForEach(items) { item in
|
|
card(item)
|
|
}
|
|
}
|
|
.padding(.horizontal, 18)
|
|
.padding(.top, 16)
|
|
.padding(.bottom, 40)
|
|
|
|
if viewModel.isLoadingMore {
|
|
ProgressView().padding(.bottom, 28)
|
|
}
|
|
}
|
|
.scrollBounceBehavior(.basedOnSize)
|
|
.background(Paper.sheet)
|
|
.podcastSheets(
|
|
viewModel: viewModel,
|
|
showFullPlayer: $showFullPlayer,
|
|
episodePicker: $episodePicker
|
|
)
|
|
}
|
|
|
|
@ViewBuilder
|
|
private func card(_ item: LibraryItem) -> some View {
|
|
// The grid renders LibraryItems, but every action needs the Bookmark it
|
|
// came from. Ids are linkding's, so this is a direct lookup.
|
|
if let bookmark = viewModel.bookmarks.first(where: { $0.id == item.id }) {
|
|
Button { onOpen(bookmark) } label: {
|
|
LibraryCard(item: item)
|
|
}
|
|
.buttonStyle(RowPressStyle())
|
|
.contextMenu {
|
|
bookmarkMenuItems(
|
|
bookmark: bookmark,
|
|
viewModel: viewModel,
|
|
openURL: openURL,
|
|
onOpen: { onOpen(bookmark) },
|
|
onEdit: { onEdit(bookmark) },
|
|
onPodcast: {
|
|
launchPodcast(
|
|
for: bookmark,
|
|
viewModel: viewModel,
|
|
showFullPlayer: $showFullPlayer,
|
|
episodePicker: $episodePicker
|
|
)
|
|
}
|
|
)
|
|
}
|
|
.onAppear { maybeLoadMore(bookmark) }
|
|
}
|
|
}
|
|
|
|
private func maybeLoadMore(_ bookmark: Bookmark) {
|
|
guard let last = viewModel.bookmarks.last, last.id == bookmark.id,
|
|
viewModel.nextPageUrl != nil, !viewModel.isLoadingMore else { return }
|
|
Task { await viewModel.loadMore() }
|
|
}
|
|
}
|