appSlug "moodlit" existierte schon, wurde aber von manaCore nicht in die DefaultManaAppConfig durchgereicht → ergänzt. + generischer ThemePassStore + Galerie unlocked/onLockedTap. Default twilight (eigene Signatur) bleibt. Build grün. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
44 lines
1.3 KiB
Swift
44 lines
1.3 KiB
Swift
import ManaCore
|
|
import ManaTokens
|
|
import Observation
|
|
import SwiftUI
|
|
|
|
/// Hält den Theme-Pass-Stand (ausprobierte App-Slugs) für die UI und
|
|
/// leitet die freigeschalteten Variants ab. Beim Start markiert es die
|
|
/// eigene App als besucht (Keychain + Server) und holt die
|
|
/// Server↔Keychain-Vereinigungsmenge (``ManaCore/ThemePass``).
|
|
///
|
|
/// Die **eigene** App ist immer sofort enthalten — man ist ja drin, also
|
|
/// ist die Signatur-Variant der App von Anfang an frei (kein Flash).
|
|
@MainActor
|
|
@Observable
|
|
final class ThemePassStore {
|
|
private(set) var triedApps: Set<String>
|
|
private let pass: ThemePass
|
|
private let ownApp: String
|
|
|
|
init(auth: AuthClient, config: ManaAppConfig) {
|
|
ownApp = config.appSlug ?? ""
|
|
triedApps = config.appSlug.map { [$0] } ?? []
|
|
pass = ThemePass(
|
|
auth: auth,
|
|
authBaseURL: config.authBaseURL,
|
|
keychainAccessGroup: config.keychainAccessGroup
|
|
)
|
|
}
|
|
|
|
/// Freigeschaltete Variants — für `ManaThemeGallery(unlocked:)`.
|
|
var unlocked: Set<ManaTheme> {
|
|
Set(ManaTheme.allCases.filter { $0.isUnlocked(triedApps: triedApps) })
|
|
}
|
|
|
|
/// Beim App-Start aufrufen: eigene App besucht-markieren + syncen.
|
|
func bootstrap() async {
|
|
if !ownApp.isEmpty {
|
|
triedApps = await pass.recordVisit(app: ownApp)
|
|
}
|
|
var merged = await pass.sync()
|
|
if !ownApp.isEmpty { merged.insert(ownApp) }
|
|
triedApps = merged
|
|
}
|
|
}
|