mana-swift-ui/Sources/ManaLLMUI/ManaLLMDownloadPolicySection.swift
Till JS ad9dc1abba v0.8.0 — feat(llm-ui): neues Library-Product ManaLLMUI
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>
2026-05-22 14:19:58 +02:00

35 lines
1.1 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import ManaLLM
import SwiftUI
/// WiFi-only-Default-Toggle für Modell-Downloads. Apps die nur Apple FM
/// und NoOp anbieten brauchen die Section nicht der Toggle hat dann
/// keine Wirkung. `ManaLLMSettingsView` zeigt die Section trotzdem,
/// weil der Default-Pool aller Backends Gemma enthält.
public struct ManaLLMDownloadPolicySection: View {
@Bindable private var state: ManaLLMSettingsState
public init(state: ManaLLMSettingsState) {
self.state = state
}
public var body: some View {
Section {
Toggle("Modelle auch über Mobilfunk laden", isOn: cellularBinding)
} header: {
Text("Modell-Download")
} footer: {
Text(
"Standard: nur über WLAN. Gemma-Modelle sind 1.32.5 GB groß — "
+ "über Mobilfunk verbraucht das spürbar Datenvolumen."
)
.font(.caption2)
}
}
private var cellularBinding: Binding<Bool> {
Binding(
get: { state.allowCellular },
set: { state.setAllowCellular($0) }
)
}
}