Every screen now speaks the paper vocabulary rather than only the bookmarks screen: Search, Sources, Podcasts and the player, Settings, Add/Edit, Smart Collections, Ask, Onboarding, the browser toolbar, the Siri snippets, and the share extension's save card. The change is mostly a design system rather than per-screen tweaks. LibraryKit gains: - Semantic colors — secondary/tertiary/faint text, `raised` surfaces, and accent/alarm/affirm, so screens stop reaching for .secondary, systemGray, .blue, .red and .green. The three status colors come out of the palette (the swatch blue, vermilion and forest) rather than from the system set, so the design keeps spending one set of inks. - PaperType — the two voices made explicit. Prose (titles, summaries, anything a person wrote) is serif; anything the machine contributes (domains, dates, counts, tags, labels, buttons) is monospaced. Keeping that split strict is what makes the design read as archival rather than as decoration. - paperSurface() / paperField() / paperCard() for grounds, inputs and raised blocks. - PaperEmptyState, because ContentUnavailableView can't be restyled — it draws its own bold system type and grey, which was the loudest remaining system voice once the screens moved onto the sheet. All nine usages are converted. The app also sets one accent for the system chrome it doesn't draw — tab bar, search fields, switches, swipe actions — which otherwise stayed system blue around paper screens. BookmarkRow is deleted. Once Search moved to the library row and TagBookmarksView was gone, nothing passed .classic, so the style fork in BookmarkListRow went with it. There is one bookmark row now. The share extension compiles LibraryKit directly, since its save card is a user-facing surface and should not be the one place still using system styling. Verified on device in both color schemes; screens toured with a temporary UI test harness (removed). Suite passes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JgLHztZGaEHvS3KNeGQmRM
104 lines
4.0 KiB
Swift
104 lines
4.0 KiB
Swift
import SwiftUI
|
|
|
|
struct SearchView: View {
|
|
@Bindable var viewModel: BookmarksViewModel
|
|
|
|
@State private var searchText = ""
|
|
@State private var useSemanticSearch = false
|
|
@State private var semanticResults: [Bookmark]? = nil
|
|
@State private var searchTask: Task<Void, Never>?
|
|
@State private var browsingBookmark: Bookmark?
|
|
|
|
var body: some View {
|
|
NavigationStack {
|
|
List {
|
|
ForEach(results) { bookmark in
|
|
BookmarkListRow(
|
|
bookmark: bookmark,
|
|
viewModel: viewModel,
|
|
onOpen: { browsingBookmark = bookmark }
|
|
)
|
|
}
|
|
}
|
|
.listStyle(.plain)
|
|
.paperSurface()
|
|
.navigationTitle("Search")
|
|
.toolbar {
|
|
ToolbarItem(placement: .topBarTrailing) {
|
|
Toggle(isOn: $useSemanticSearch) {
|
|
Label("Semantic", systemImage: "sparkles")
|
|
}
|
|
.toggleStyle(.button)
|
|
.onChange(of: useSemanticSearch) { _, _ in scheduleSearch() }
|
|
}
|
|
}
|
|
.overlay {
|
|
if searchText.isEmpty {
|
|
PaperEmptyState(title: "Search Bookmarks", systemImage: "magnifyingglass", message: "Search by title, URL, or tag.")
|
|
} else if results.isEmpty && !viewModel.isLoading {
|
|
PaperEmptyState(title: "No Results", systemImage: "magnifyingglass", message: "Nothing matches \u{201C}\(searchText)\u{201D}.")
|
|
}
|
|
if viewModel.isLoading {
|
|
ProgressView()
|
|
}
|
|
}
|
|
.sensoryFeedback(.selection, trigger: browsingBookmark?.id)
|
|
.sheet(item: $browsingBookmark) { bookmark in
|
|
if let url = URL(string: bookmark.url) {
|
|
BrowserView(
|
|
url: url,
|
|
title: bookmark.displayTitle,
|
|
claude: viewModel.claude,
|
|
podcastPlayer: viewModel.podcastPlayer,
|
|
podcastGenerator: viewModel.podcastGenerator
|
|
) {
|
|
await viewModel.archive(bookmark)
|
|
}
|
|
.bookmarkOnscreen(bookmark)
|
|
}
|
|
}
|
|
}
|
|
.searchable(text: $searchText, prompt: "Titles, URLs, tags…")
|
|
.onChange(of: searchText) { _, _ in scheduleSearch() }
|
|
.onAppear { consumeIntentSearch() }
|
|
.onChange(of: IntentRouter.shared.searchRequest) { _, _ in consumeIntentSearch() }
|
|
}
|
|
|
|
/// Pulls a query handed over by `SearchMarksIntent` into the search field.
|
|
private func consumeIntentSearch() {
|
|
guard let query = IntentRouter.shared.searchRequest else { return }
|
|
searchText = query
|
|
IntentRouter.shared.searchRequest = nil
|
|
}
|
|
|
|
private var results: [Bookmark] {
|
|
if let semantic = semanticResults { return semantic }
|
|
guard !searchText.isEmpty else { return [] }
|
|
let q = searchText.lowercased()
|
|
return viewModel.bookmarks.filter { b in
|
|
b.displayTitle.lowercased().contains(q) ||
|
|
b.url.lowercased().contains(q) ||
|
|
b.tagNames.contains { $0.lowercased().contains(q) } ||
|
|
(b.aiTags ?? []).contains { $0.lowercased().contains(q) } ||
|
|
(b.aiSummary ?? "").lowercased().contains(q)
|
|
}
|
|
}
|
|
|
|
private func scheduleSearch() {
|
|
semanticResults = nil
|
|
searchTask?.cancel()
|
|
guard !searchText.isEmpty, useSemanticSearch else { return }
|
|
let claude = viewModel.claude
|
|
searchTask = Task {
|
|
try? await Task.sleep(for: .milliseconds(500))
|
|
guard !Task.isCancelled else { return }
|
|
let q = searchText
|
|
let all = viewModel.bookmarks
|
|
do {
|
|
let ranked = try await claude.semanticSearch(query: q, in: all)
|
|
await MainActor.run { semanticResults = ranked }
|
|
} catch {}
|
|
}
|
|
}
|
|
}
|