Import old content, load from disk

This commit is contained in:
Christoph Hagen
2024-11-18 20:19:20 +01:00
parent 0989f06d87
commit 943d8d962b
24 changed files with 1326 additions and 210 deletions

View File

@@ -0,0 +1,54 @@
import Foundation
import SwiftUI
final class LocalizedPost: ObservableObject {
@Published
var title: String
@Published
var content: String
@Published
var lastModified: Date?
@Published
var images: [ImageResource]
init(title: String? = nil,
content: String,
lastModified: Date? = nil,
images: [ImageResource] = []) {
self.title = title ?? ""
self.content = content
self.lastModified = lastModified
self.images = images
}
var displayImages: [Image] {
images.map { $0.imageToDisplay }
}
@MainActor
func editableTitle() -> Binding<String> {
Binding(
get: {
self.title
},
set: { newValue in
self.title = newValue
}
)
}
func editableContent() -> Binding<String> {
Binding(
get: {
self.content
},
set: { newValue in
self.content = newValue
}
)
}
}