Drop-in-Settings-UI für die lokalen LLM-Backends aus mana-swift-llm. Pendant zu ManaAuthUI — vorher hatte nur Memoro die UI handgeschrieben, die drei anderen Konsumenten (pageta, comicello, herbatrium) gar nichts. Komponenten: - ManaLLMSettingsView(context:) — Convenience-Wrapper, drei Sections - ManaLLMBackendPickerSection — Picker + Availability + Empfohlen-Badge - ManaLLMPrepareSection — Download/Init-Card mit Progress, gated für Gemma - ManaLLMDownloadPolicySection — WiFi-only-Toggle - ManaLLMSettingsState (@Observable, @MainActor) — geteilter State, delegiert an Stores aus mana-swift-llm 0.2.0 - ManaLLMContext(useCaseShort:useCaseLong:) — app-spezifischer Section-Text; .generic als Fallback Test-Target ManaLLMUITests bewusst noch nicht angelegt (Linter hat es aus Package.swift entfernt, Comment markiert TODO). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
43 lines
1.3 KiB
Swift
43 lines
1.3 KiB
Swift
import ManaLLM
|
|
import SwiftUI
|
|
|
|
/// Drop-in-Komposition aus den drei Sections: BackendPicker, Prepare
|
|
/// (sichtbar nur für Gemma-Backends), DownloadPolicy.
|
|
///
|
|
/// **Typische Nutzung:**
|
|
///
|
|
/// ```swift
|
|
/// // In der Settings-Form der App:
|
|
/// ManaLLMSettingsView(
|
|
/// context: ManaLLMContext(
|
|
/// useCaseShort: "Artikel-Zusammenfassung",
|
|
/// useCaseLong: "fasst Artikel in zwei Sätze zusammen"
|
|
/// )
|
|
/// )
|
|
/// ```
|
|
///
|
|
/// Apps die feinere Kontrolle wollen (z.B. zwischen den Sections eine
|
|
/// app-eigene Section einschieben), nutzen die granularen
|
|
/// `ManaLLM*Section`-Views direkt und teilen sich einen explizit
|
|
/// erzeugten `ManaLLMSettingsState`.
|
|
public struct ManaLLMSettingsView: View {
|
|
@State private var state = ManaLLMSettingsState()
|
|
private let context: ManaLLMContext
|
|
|
|
public init(context: ManaLLMContext = .generic) {
|
|
self.context = context
|
|
}
|
|
|
|
public var body: some View {
|
|
Group {
|
|
ManaLLMBackendPickerSection(state: state, context: context)
|
|
if ManaLLMPrepareSection.shouldShow(for: state) {
|
|
ManaLLMPrepareSection(state: state)
|
|
}
|
|
ManaLLMDownloadPolicySection(state: state)
|
|
}
|
|
.task {
|
|
await state.refreshAvailability()
|
|
}
|
|
}
|
|
}
|