Last active
October 2, 2024 18:26
-
-
Save StewartLynch/4a3fbad288ce6352678fffc3579de073 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftData | |
import SwiftUI | |
struct MockData: PreviewModifier { | |
func body(content: Content, context: ModelContainer) -> some View { | |
content | |
.modelContainer(context) | |
} | |
static func makeSharedContext() async throws -> ModelContainer { | |
let container = try! ModelContainer( | |
for: <#Model#>.self, | |
configurations: ModelConfiguration(isStoredInMemoryOnly: true) | |
) | |
// Insert objects here | |
return container | |
} | |
} | |
extension PreviewTrait where T == Preview.ViewTraits { | |
static var mockData: Self = .modifier(MockData()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment