Complete ground-up rewrite in SwiftUI targeting iOS 26. Drops the Flutter/Dart codebase entirely in favour of a lean native app with no third-party dependencies. Features shipped: - Bookmark list with pagination, pull-to-refresh, swipe delete/archive - Add bookmark form + iOS share extension (zero-tap save from any app) - Tags tab — all tags sorted by count, tap to browse filtered bookmarks - Native search tab (Tab role: .search) with instant client-side filtering - AI enrichment via OpenRouter (google/gemini-2.0-flash-lite-001): auto-summary and tag generation, semantic search, smart collections - Settings: linkding server config, OpenRouter API key - App Groups for credential sharing between main app and share extension - Swift 6 strict concurrency throughout (@Observable, @MainActor) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
89 lines
2.9 KiB
Swift
89 lines
2.9 KiB
Swift
import SwiftUI
|
|
|
|
struct AddBookmarkView: View {
|
|
@Bindable var viewModel: BookmarksViewModel
|
|
@Environment(\.dismiss) private var dismiss
|
|
|
|
@State private var url = ""
|
|
@State private var title = ""
|
|
@State private var tagsText = ""
|
|
@State private var isSaving = false
|
|
@State private var error: String?
|
|
|
|
var body: some View {
|
|
NavigationStack {
|
|
Form {
|
|
Section {
|
|
TextField("https://", text: $url)
|
|
.keyboardType(.URL)
|
|
.textInputAutocapitalization(.never)
|
|
.autocorrectionDisabled()
|
|
} header: {
|
|
Text("URL")
|
|
}
|
|
|
|
Section {
|
|
TextField("Optional", text: $title)
|
|
} header: {
|
|
Text("Title")
|
|
}
|
|
|
|
Section {
|
|
TextField("comma separated", text: $tagsText)
|
|
.textInputAutocapitalization(.never)
|
|
.autocorrectionDisabled()
|
|
} header: {
|
|
Text("Tags")
|
|
} footer: {
|
|
Text("Separate tags with commas")
|
|
}
|
|
|
|
if let error {
|
|
Section {
|
|
Text(error)
|
|
.foregroundStyle(.red)
|
|
.font(.footnote)
|
|
}
|
|
}
|
|
}
|
|
.navigationTitle("Add Bookmark")
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
.toolbar {
|
|
ToolbarItem(placement: .cancellationAction) {
|
|
Button("Cancel") { dismiss() }
|
|
}
|
|
ToolbarItem(placement: .confirmationAction) {
|
|
Button("Save") { save() }
|
|
.disabled(url.trimmingCharacters(in: .whitespaces).isEmpty || isSaving)
|
|
.overlay {
|
|
if isSaving { ProgressView().scaleEffect(0.7) }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private func save() {
|
|
var urlString = url.trimmingCharacters(in: .whitespaces)
|
|
if !urlString.hasPrefix("http://") && !urlString.hasPrefix("https://") {
|
|
urlString = "https://" + urlString
|
|
}
|
|
guard URL(string: urlString) != nil else {
|
|
error = "Invalid URL"
|
|
return
|
|
}
|
|
let tags = tagsText.split(separator: ",").map { $0.trimmingCharacters(in: .whitespaces) }.filter { !$0.isEmpty }
|
|
isSaving = true
|
|
error = nil
|
|
Task {
|
|
do {
|
|
try await viewModel.addBookmark(url: urlString, title: title.trimmingCharacters(in: .whitespaces), tags: tags)
|
|
dismiss()
|
|
} catch {
|
|
self.error = error.localizedDescription
|
|
isSaving = false
|
|
}
|
|
}
|
|
}
|
|
}
|