Import old content, load from disk
This commit is contained in:
54
CHDataManagement/Model/LocalizedPost.swift
Normal file
54
CHDataManagement/Model/LocalizedPost.swift
Normal 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
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user