Created
July 25, 2024 10:29
-
-
Save benigumocom/eeb467e92f65d8509041152227b1606c 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 SwiftUI | |
import SwiftData | |
struct PreviewOneModelView<Model: PersistentModel, Content: View>: View { | |
var content: (Model) -> Content | |
var body: some View { | |
PreviewOneModelContent(content: content) | |
.modelContainer(for: Item.self) | |
//.modelContainer(for: [Item.self], inMemory: false) // OK | |
} | |
} | |
struct PreviewOneModelContent<Model: PersistentModel, Content: View>: View { | |
var content: (Model) -> Content | |
@Query private var models: [Model] | |
var body: some View { | |
content(models.first!) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment