Implemented the EmptyDataModifier and the SampleDataModifier modifiers in the app target and also, added them as properties for the PreviewTrait+Properties extension.
This commit is contained in:
parent
e72888361a
commit
7889394fab
@ -431,7 +431,7 @@
|
|||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEVELOPMENT_ASSET_PATHS = "Piper/Sources/Previews/Extensions/Repository+Samples.swift Piper/Sources/Previews/Extensions/ModelContainer+Constants.swift Piper/Resources/Catalogs/Previews.xcassets";
|
DEVELOPMENT_ASSET_PATHS = "Piper/Sources/Previews/Extensions/PreviewTrait+Properties.swift Piper/Sources/Previews/Extensions/ModelContainer+Constants.swift Piper/Resources/Catalogs/Previews.xcassets Piper/Sources/Previews/Extensions/Repository+Samples.swift Piper/Sources/Previews/Modifiers/SampleDataModifier.swift Piper/Sources/Previews/Modifiers/EmptyDataModifier.swift";
|
||||||
DEVELOPMENT_TEAM = 7FMNM89WKG;
|
DEVELOPMENT_TEAM = 7FMNM89WKG;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
@ -463,7 +463,7 @@
|
|||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEVELOPMENT_ASSET_PATHS = "Piper/Sources/Previews/Extensions/Repository+Samples.swift Piper/Sources/Previews/Extensions/ModelContainer+Constants.swift Piper/Resources/Catalogs/Previews.xcassets";
|
DEVELOPMENT_ASSET_PATHS = "Piper/Sources/Previews/Extensions/PreviewTrait+Properties.swift Piper/Sources/Previews/Extensions/ModelContainer+Constants.swift Piper/Resources/Catalogs/Previews.xcassets Piper/Sources/Previews/Extensions/Repository+Samples.swift Piper/Sources/Previews/Modifiers/SampleDataModifier.swift Piper/Sources/Previews/Modifiers/EmptyDataModifier.swift";
|
||||||
DEVELOPMENT_TEAM = 7FMNM89WKG;
|
DEVELOPMENT_TEAM = 7FMNM89WKG;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// ModelContainer+Constants.swift
|
// ModelContainer+Constants.swift
|
||||||
// Piper
|
// Piper ~ App
|
||||||
//
|
//
|
||||||
// Created by Javier Cicchelli on 06/10/2024.
|
// Created by Javier Cicchelli on 06/10/2024.
|
||||||
// Copyright © 2024 Röck+Cöde. All rights reserved.
|
// Copyright © 2024 Röck+Cöde. All rights reserved.
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
//
|
||||||
|
// PreviewTrait+Properties.swift
|
||||||
|
// Piper
|
||||||
|
//
|
||||||
|
// Created by Javier Cicchelli on 13/10/2024.
|
||||||
|
// Copyright © 2024 Röck+Cöde. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
@available(macOS 15.0, *)
|
||||||
|
extension PreviewTrait where T == Preview.ViewTraits {
|
||||||
|
|
||||||
|
// MARK: Properties
|
||||||
|
|
||||||
|
@MainActor static var emptyData: PreviewTrait = .modifier(EmptyDataModifier())
|
||||||
|
@MainActor static var sampleData: PreviewTrait = .modifier(SampleDataModifier())
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Repository+Samples.swift
|
// Repository+Samples.swift
|
||||||
// Piper
|
// Piper ~ App
|
||||||
//
|
//
|
||||||
// Created by Javier Cicchelli on 06/10/2024.
|
// Created by Javier Cicchelli on 06/10/2024.
|
||||||
// Copyright © 2024 Röck+Cöde. All rights reserved.
|
// Copyright © 2024 Röck+Cöde. All rights reserved.
|
||||||
|
27
Piper/Sources/Previews/Modifiers/EmptyDataModifier.swift
Normal file
27
Piper/Sources/Previews/Modifiers/EmptyDataModifier.swift
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// EmptyDataModifier.swift
|
||||||
|
// Piper ~ App
|
||||||
|
//
|
||||||
|
// Created by Javier Cicchelli on 13/10/2024.
|
||||||
|
// Copyright © 2024 Röck+Cöde. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftData
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct EmptyDataModifier: PreviewModifier {
|
||||||
|
|
||||||
|
// MARK: Functions
|
||||||
|
|
||||||
|
static func makeSharedContext() async throws -> ModelContainer {
|
||||||
|
ModelContainer.preview
|
||||||
|
}
|
||||||
|
|
||||||
|
func body(
|
||||||
|
content: Content,
|
||||||
|
context: ModelContainer
|
||||||
|
) -> some View {
|
||||||
|
content.modelContainer(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
31
Piper/Sources/Previews/Modifiers/SampleDataModifier.swift
Normal file
31
Piper/Sources/Previews/Modifiers/SampleDataModifier.swift
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
//
|
||||||
|
// SampleDataModifier.swift
|
||||||
|
// Piper ~ App
|
||||||
|
//
|
||||||
|
// Created by Javier Cicchelli on 13/10/2024.
|
||||||
|
// Copyright © 2024 Röck+Cöde. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftData
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct SampleDataModifier: PreviewModifier {
|
||||||
|
|
||||||
|
// MARK: Functions
|
||||||
|
|
||||||
|
static func makeSharedContext() async throws -> ModelContainer {
|
||||||
|
let container = ModelContainer.preview
|
||||||
|
|
||||||
|
Repository.samples(in: container)
|
||||||
|
|
||||||
|
return container
|
||||||
|
}
|
||||||
|
|
||||||
|
func body(
|
||||||
|
content: Content,
|
||||||
|
context: ModelContainer
|
||||||
|
) -> some View {
|
||||||
|
content.modelContainer(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user