Some checks failed
CI / build-and-deploy (push) Failing after 7s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
53 lines
1.5 KiB
Swift
53 lines
1.5 KiB
Swift
import SwiftUI
|
|
|
|
private let defaultConfig = ServerConfig(
|
|
host: "linkding-production-f7e0.up.railway.app",
|
|
port: nil,
|
|
path: "",
|
|
token: "RuK48O4LSD6AIKA4SlXYqxU3Ig71slvJGFbk6EanVeT9dlXA#ojHSAFWIq_B3MOBGkoARE5VnGnqeg2ehKddeEQlyvMI",
|
|
useHttps: true
|
|
)
|
|
|
|
@main
|
|
struct MarksApp: App {
|
|
@State private var serverConfig: ServerConfig = ServerConfig.load() ?? defaultConfig
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
MainContainer(config: serverConfig) {
|
|
defaultConfig.save()
|
|
serverConfig = defaultConfig
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Holds the API + ViewModel so they survive re-renders
|
|
struct MainContainer: View {
|
|
let config: ServerConfig
|
|
let onDisconnect: () -> Void
|
|
|
|
@State private var viewModel: BookmarksViewModel
|
|
|
|
init(config: ServerConfig, onDisconnect: @escaping () -> Void) {
|
|
self.config = config
|
|
self.onDisconnect = onDisconnect
|
|
let api = LinkdingAPI(config: config)
|
|
_viewModel = State(wrappedValue: BookmarksViewModel(api: api, cacheKey: config.host))
|
|
}
|
|
|
|
var body: some View {
|
|
TabView {
|
|
Tab("Bookmarks", systemImage: "bookmark") {
|
|
BookmarksView(viewModel: viewModel, onDisconnect: onDisconnect)
|
|
}
|
|
Tab("Tags", systemImage: "tag") {
|
|
TagsView(viewModel: viewModel)
|
|
}
|
|
Tab(role: .search) {
|
|
SearchView(viewModel: viewModel)
|
|
}
|
|
}
|
|
}
|
|
}
|