mana-swift-ui/Sources/ManaLLMUI/ManaLLMSettingsScreen.swift
Till JS d2adcb7e5f feat(ManaLLMUI): KI-Einstellungen als geteilte Unterseite (Link + Screen)
ManaLLMSettingsLink (NavigationLink-Zeile) + ManaLLMSettingsScreen
(Form-Unterseite mit generischem extra-Slot) buendeln die vier KI-
Sektionen hinter einer Zeile statt inline. Flottenweites Muster; additiv
zu ManaLLMSettingsView (unveraendert). Default Titel 'Kuenstliche
Intelligenz' + SF-Symbol 'sparkles'.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-05 22:01:19 +02:00

78 lines
2.6 KiB
Swift
Raw Permalink 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
/// Eigenständige Unterseite, die alle KI-Einstellungen einer App bündelt
/// — die geteilten `ManaLLM*`-Sections (via ``ManaLLMSettingsView``) plus
/// optionalen app-eigenen KI-Inhalt im `extra`-Slot.
///
/// Gedacht als Ziel eines ``ManaLLMSettingsLink``: statt die vier KI-
/// Sections inline in den Konto-/Settings-Tab zu kippen, lebt alles
/// hinter **einer** „Künstliche Intelligenz ›"-Zeile auf dieser Seite.
/// So sieht der KI-Bereich in allen nativen Verein-Apps gleich aus.
///
/// **Typische Nutzung** (App ohne Zusatz-Sections):
///
/// ```swift
/// ManaLLMSettingsScreen(context: myContext)
/// ```
///
/// **Mit app-eigener KI-Section** (z.B. memoros Server-LLM-Picker), die
/// auf App-State zugreift:
///
/// ```swift
/// ManaLLMSettingsScreen(context: myContext, showByok: false) {
/// serverLLMSection // app-eigene Section, sieht den App-State
/// }
/// ```
///
/// Der `extra`-Inhalt wird **unter** den geteilten Sections in dieselbe
/// `Form` gehängt; übergib `Section`s, damit sich die Optik einreiht.
public struct ManaLLMSettingsScreen<Extra: View>: View {
private let context: ManaLLMContext
private let showByok: Bool
private let title: String
private let extra: Extra
/// - Parameters:
/// - context: App-spezifische Use-Case-Texte für die Footer.
/// - showByok: Zeigt die BYOK-Schlüssel-Verwaltung. Default `true`.
/// Apps mit On-Device-Datenschutz-Versprechen (z.B. memoro) setzen
/// `false` — dann taucht BYOK gar nicht erst als Quelle auf.
/// - title: Navigations-Titel der Unterseite.
/// - extra: App-eigene KI-Sections (`Section`s), unter den geteilten.
public init(
context: ManaLLMContext = .generic,
showByok: Bool = true,
title: String = "Künstliche Intelligenz",
@ViewBuilder extra: () -> Extra
) {
self.context = context
self.showByok = showByok
self.title = title
self.extra = extra()
}
public var body: some View {
Form {
ManaLLMSettingsView(context: context, showByok: showByok)
extra
}
.navigationTitle(title)
#if os(iOS)
.navigationBarTitleDisplayMode(.inline)
#endif
}
}
public extension ManaLLMSettingsScreen where Extra == EmptyView {
/// Bequemlichkeits-Init ohne app-eigenen Zusatz-Inhalt.
init(
context: ManaLLMContext = .generic,
showByok: Bool = true,
title: String = "Künstliche Intelligenz"
) {
self.init(context: context, showByok: showByok, title: title) {
EmptyView()
}
}
}