22 lines
711 B
Swift
22 lines
711 B
Swift
import Foundation
|
|
import SwiftData
|
|
|
|
extension RitualStore {
|
|
static var preview: RitualStore {
|
|
let schema = Schema([Ritual.self, RitualArc.self, ArcHabit.self])
|
|
let configuration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: true)
|
|
let container: ModelContainer
|
|
do {
|
|
container = try ModelContainer(for: schema, configurations: [configuration])
|
|
} catch {
|
|
fatalError("Preview container failed: \(error)")
|
|
}
|
|
return RitualStore(
|
|
modelContext: container.mainContext,
|
|
seedService: RitualSeedService(),
|
|
settingsStore: SettingsStore(),
|
|
isRunningTests: false
|
|
)
|
|
}
|
|
}
|