Add tag overview, improve assets

This commit is contained in:
Christoph Hagen
2024-12-15 21:20:12 +01:00
parent 8a3a0f1797
commit 1e67a99866
59 changed files with 1301 additions and 480 deletions

View File

@ -5,29 +5,24 @@ final class FileResource: Item {
let type: FileType
/// Globally unique id
@Published
var id: String
@Published
var isExternallyStored: Bool
@Published
var germanDescription: String
var german: String
@Published
var englishDescription: String
var english: String
@Published
var size: CGSize = .zero
init(content: Content, id: String, isExternallyStored: Bool, en: String, de: String) {
self.id = id
self.type = FileType(fileExtension: id.fileExtension)
self.englishDescription = en
self.germanDescription = de
self.english = en
self.german = de
self.isExternallyStored = isExternallyStored
super.init(content: content)
super.init(content: content, id: id)
}
/**
@ -35,18 +30,10 @@ final class FileResource: Item {
*/
init(resourceImage: String, type: ImageFileType) {
self.type = .image(type)
self.id = resourceImage
self.englishDescription = "A test image included in the bundle"
self.germanDescription = "Ein Testbild aus dem Bundle"
self.english = "A test image included in the bundle"
self.german = "Ein Testbild aus dem Bundle"
self.isExternallyStored = true
super.init(content: .mock) // TODO: Add images to mock
}
func getDescription(for language: ContentLanguage) -> String {
switch language {
case .english: return englishDescription
case .german: return germanDescription
}
super.init(content: .mock, id: resourceImage) // TODO: Add images to mock
}
// MARK: Text
@ -108,6 +95,11 @@ final class FileResource: Item {
return makeCleanAbsolutePath(path)
}
var assetUrl: String {
let path = content.settings.paths.assetsOutputFolderPath + "/" + id
return makeCleanAbsolutePath(path)
}
private var pathPrefix: String {
switch type {
@ -135,27 +127,6 @@ final class FileResource: Item {
}
}
extension FileResource: Identifiable {
extension FileResource: LocalizedItem {
}
extension FileResource: Equatable {
static func == (lhs: FileResource, rhs: FileResource) -> Bool {
lhs.id == rhs.id
}
}
extension FileResource: Hashable {
func hash(into hasher: inout Hasher) {
hasher.combine(id)
}
}
extension FileResource: Comparable {
static func < (lhs: FileResource, rhs: FileResource) -> Bool {
lhs.id < rhs.id
}
}