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
144 lines
5.1 KiB
Swift
144 lines
5.1 KiB
Swift
import SwiftUI
|
|
|
|
struct OnboardingView: View {
|
|
let onConnect: (ServerConfig) -> Void
|
|
|
|
@State private var urlText = ""
|
|
@State private var token = ""
|
|
@State private var isConnecting = false
|
|
@State private var errorMessage: String?
|
|
@FocusState private var focused: Field?
|
|
|
|
enum Field { case url, token }
|
|
|
|
var body: some View {
|
|
VStack(spacing: 0) {
|
|
Spacer()
|
|
|
|
VStack(alignment: .leading, spacing: 8) {
|
|
Text("Marks")
|
|
.font(.system(size: 42, design: .serif))
|
|
.foregroundStyle(Paper.ink)
|
|
Text("Your bookmarks, beautifully.")
|
|
.font(PaperType.body)
|
|
.foregroundStyle(Paper.secondary)
|
|
}
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
.padding(.horizontal, 28)
|
|
.padding(.bottom, 48)
|
|
|
|
VStack(spacing: 14) {
|
|
VStack(alignment: .leading, spacing: 6) {
|
|
Text("Server URL")
|
|
.font(PaperType.stamp)
|
|
.foregroundStyle(Paper.tertiary)
|
|
.padding(.horizontal, 2)
|
|
TextField("https://links.example.com", text: $urlText)
|
|
.textContentType(.URL)
|
|
.keyboardType(.URL)
|
|
.autocorrectionDisabled()
|
|
.textInputAutocapitalization(.never)
|
|
.focused($focused, equals: .url)
|
|
.submitLabel(.next)
|
|
.onSubmit { focused = .token }
|
|
.padding(14)
|
|
.paperField()
|
|
.background(Paper.raised)
|
|
.clipShape(RoundedRectangle(cornerRadius: 12))
|
|
}
|
|
|
|
VStack(alignment: .leading, spacing: 6) {
|
|
Text("API Token")
|
|
.font(PaperType.stamp)
|
|
.foregroundStyle(Paper.tertiary)
|
|
.padding(.horizontal, 2)
|
|
SecureField("Paste your token", text: $token)
|
|
.textContentType(.password)
|
|
.autocorrectionDisabled()
|
|
.textInputAutocapitalization(.never)
|
|
.focused($focused, equals: .token)
|
|
.submitLabel(.done)
|
|
.onSubmit { Task { await connect() } }
|
|
.padding(14)
|
|
.paperField()
|
|
.background(Paper.raised)
|
|
.clipShape(RoundedRectangle(cornerRadius: 12))
|
|
Text("Find your token at Settings → API Token in Linkding.")
|
|
.font(PaperType.micro)
|
|
.foregroundStyle(Paper.tertiary)
|
|
.padding(.horizontal, 2)
|
|
}
|
|
}
|
|
.padding(.horizontal, 24)
|
|
|
|
if let err = errorMessage {
|
|
Text(err)
|
|
.font(PaperType.meta)
|
|
.foregroundStyle(Paper.alarm)
|
|
.padding(.top, 12)
|
|
.padding(.horizontal, 28)
|
|
}
|
|
|
|
Button {
|
|
Task { await connect() }
|
|
} label: {
|
|
Group {
|
|
if isConnecting {
|
|
ProgressView().tint(.white)
|
|
} else {
|
|
Text("Connect")
|
|
.font(PaperType.label)
|
|
}
|
|
}
|
|
.frame(maxWidth: .infinity)
|
|
.frame(height: 52)
|
|
}
|
|
.buttonStyle(.glassProminent)
|
|
.buttonBorderShape(.roundedRectangle(radius: 14))
|
|
.disabled(!canConnect || isConnecting)
|
|
.padding(.horizontal, 24)
|
|
.padding(.top, 24)
|
|
|
|
Spacer()
|
|
}
|
|
}
|
|
|
|
private var canConnect: Bool { !urlText.isEmpty && !token.isEmpty }
|
|
|
|
private func connect() async {
|
|
focused = nil
|
|
isConnecting = true
|
|
errorMessage = nil
|
|
|
|
do {
|
|
let config = try parseConfig()
|
|
let api = LinkdingAPI(config: config)
|
|
try await api.verifyConnection()
|
|
onConnect(config)
|
|
} catch APIError.badStatus(401) {
|
|
errorMessage = "Invalid token. Check your API token in Linkding settings."
|
|
} catch APIError.badStatus(let code) {
|
|
errorMessage = "Server returned \(code). Check the URL."
|
|
} catch {
|
|
errorMessage = "Could not connect. Check the URL and try again."
|
|
}
|
|
|
|
isConnecting = false
|
|
}
|
|
|
|
private func parseConfig() throws -> ServerConfig {
|
|
let raw = urlText.normalizedURL
|
|
guard let comps = URLComponents(string: raw),
|
|
let host = comps.host, !host.isEmpty else {
|
|
throw URLError(.badURL)
|
|
}
|
|
return ServerConfig(
|
|
host: host,
|
|
port: comps.port,
|
|
path: comps.path.hasSuffix("/") ? String(comps.path.dropLast()) : comps.path,
|
|
token: token.trimmingCharacters(in: .whitespacesAndNewlines),
|
|
useHttps: comps.scheme == "https"
|
|
)
|
|
}
|
|
}
|