From cd9bd975b427b65523777452e9427a997d9ccf17 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sun, 6 Oct 2024 13:35:03 +0200 Subject: [PATCH] Implemented the "samples(in: )" static function for the Repository+Samples extension in the app target. --- Piper.xcodeproj/project.pbxproj | 4 +-- .../Extensions/Repository+Samples.swift | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 Piper/Sources/Previews/Extensions/Repository+Samples.swift diff --git a/Piper.xcodeproj/project.pbxproj b/Piper.xcodeproj/project.pbxproj index e7e90a1..102f43f 100644 --- a/Piper.xcodeproj/project.pbxproj +++ b/Piper.xcodeproj/project.pbxproj @@ -429,7 +429,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_ASSET_PATHS = Piper/Resources/Catalogs/Previews.xcassets; + DEVELOPMENT_ASSET_PATHS = "Piper/Sources/Previews/Extensions/Repository+Samples.swift Piper/Resources/Catalogs/Previews.xcassets"; DEVELOPMENT_TEAM = 7FMNM89WKG; ENABLE_HARDENED_RUNTIME = YES; ENABLE_PREVIEWS = YES; @@ -461,7 +461,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_ASSET_PATHS = Piper/Resources/Catalogs/Previews.xcassets; + DEVELOPMENT_ASSET_PATHS = "Piper/Sources/Previews/Extensions/Repository+Samples.swift Piper/Resources/Catalogs/Previews.xcassets"; DEVELOPMENT_TEAM = 7FMNM89WKG; ENABLE_HARDENED_RUNTIME = YES; ENABLE_PREVIEWS = YES; diff --git a/Piper/Sources/Previews/Extensions/Repository+Samples.swift b/Piper/Sources/Previews/Extensions/Repository+Samples.swift new file mode 100644 index 0000000..9264b5b --- /dev/null +++ b/Piper/Sources/Previews/Extensions/Repository+Samples.swift @@ -0,0 +1,36 @@ +// +// Repository+Samples.swift +// Piper +// +// Created by Javier Cicchelli on 06/10/2024. +// Copyright © 2024 Röck+Cöde. All rights reserved. +// + +import Foundation +import SwiftData + +extension Repository { + + // MARK: Functions + + @MainActor + static func samples(in container: ModelContainer) { + let context = container.mainContext + + context.insert(Repository( + URL(filePath: "/full/path/to/repository/name-0.git"), + sortOrder: 0 + )) + + context.insert(Repository( + URL(filePath: "/full/path/to/repository/name-1.git"), + sortOrder: 1 + )) + + context.insert(Repository( + URL(filePath: "/full/path/to/repository/name-2.git"), + sortOrder: 2 + )) + } + +}