Fix preview crash
This commit is contained in:
parent
5fb689ac7c
commit
42a5d01480
@ -35,8 +35,8 @@ final class ImageResource: ObservableObject {
|
|||||||
self.germanDescription = de
|
self.germanDescription = de
|
||||||
}
|
}
|
||||||
|
|
||||||
init(resourceName: String) {
|
init(resourceName: String, type: ImageType) {
|
||||||
self.type = ImageType(fileExtension: resourceName.fileExtension!)!
|
self.type = type
|
||||||
self.id = resourceName
|
self.id = resourceName
|
||||||
self.source = .resource(resourceName)
|
self.source = .resource(resourceName)
|
||||||
self.englishDescription = "A test image included in the bundle"
|
self.englishDescription = "A test image included in the bundle"
|
||||||
|
@ -7,7 +7,7 @@ struct MockImage {
|
|||||||
|
|
||||||
static var images: [ImageResource] {
|
static var images: [ImageResource] {
|
||||||
["image1", "image2", "image3", "image4"]
|
["image1", "image2", "image3", "image4"]
|
||||||
.map(ImageResource.init)
|
.map { ImageResource(resourceName: $0, type: .jpg) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ extension LocalizedTag {
|
|||||||
name: "Electronics",
|
name: "Electronics",
|
||||||
subtitle: "Projects with electronics",
|
subtitle: "Projects with electronics",
|
||||||
description: "Some description of the tag",
|
description: "Some description of the tag",
|
||||||
thumbnail: ImageResource(resourceName: "image1"),
|
thumbnail: ImageResource(resourceName: "image1", type: .jpg),
|
||||||
originalUrl: "projects/electronics")
|
originalUrl: "projects/electronics")
|
||||||
|
|
||||||
static let german = LocalizedTag(
|
static let german = LocalizedTag(
|
||||||
@ -42,6 +42,6 @@ extension LocalizedTag {
|
|||||||
name: "Elektronik",
|
name: "Elektronik",
|
||||||
subtitle: "Projekte mit Elektronik",
|
subtitle: "Projekte mit Elektronik",
|
||||||
description: "Eine Beschreibung des Tags",
|
description: "Eine Beschreibung des Tags",
|
||||||
thumbnail: ImageResource(resourceName: "image2"),
|
thumbnail: ImageResource(resourceName: "image2", type: .jpg),
|
||||||
originalUrl: "projects/electronics")
|
originalUrl: "projects/electronics")
|
||||||
}
|
}
|
||||||
|
@ -13,5 +13,5 @@ struct ImagesContentView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#Preview {
|
#Preview {
|
||||||
ImagesContentView(image: .init(resourceName: "image1"))
|
ImagesContentView(image: .init(resourceName: "image1", type: .jpg))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user