Skip to content

Instantly share code, notes, and snippets.

@StewartLynch
Last active October 2, 2024 18:26

Revisions

  1. StewartLynch renamed this gist Oct 2, 2024. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. StewartLynch created this gist Oct 2, 2024.
    25 changes: 25 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    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())
    }