Import old content, load from disk
This commit is contained in:
@ -55,17 +55,15 @@ struct PostList: View {
|
||||
}
|
||||
|
||||
private func addNewPost() {
|
||||
let largestId = posts.map { $0.id }.max() ?? 0
|
||||
|
||||
let post = Post(
|
||||
id: largestId + 1,
|
||||
id: "new",
|
||||
isDraft: true,
|
||||
createdDate: .now,
|
||||
startDate: .now,
|
||||
endDate: nil,
|
||||
title: .init(en: "Title", de: "Titel"),
|
||||
text: .init(en: "Text", de: "Text"),
|
||||
tags: [],
|
||||
images: [])
|
||||
german: .init(title: "Titel", content: "Text"),
|
||||
english: .init(title: "Title", content: "Text"))
|
||||
posts.insert(post, at: 0)
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ struct PostView: View {
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .center) {
|
||||
if !post.images.isEmpty {
|
||||
PostImageGalleryView(images: post.displayImages)
|
||||
if !post.localized(in: language).images.isEmpty {
|
||||
PostImageGalleryView(images: post.localized(in: language).displayImages)
|
||||
.aspectRatio(1.33, contentMode: .fill)
|
||||
}
|
||||
VStack(alignment: .leading) {
|
||||
@ -26,17 +26,20 @@ struct PostView: View {
|
||||
Toggle("Draft", isOn: $post.isDraft)
|
||||
}
|
||||
.foregroundStyle(Color(r: 96, g: 186, b: 255))
|
||||
TextField("", text: post.title.text(for: language))
|
||||
TextField("", text: post.localized(in: language).editableTitle())
|
||||
.font(.system(size: 24, weight: .bold))
|
||||
.foregroundStyle(Color.white)
|
||||
.textFieldStyle(.plain)
|
||||
.lineLimit(2)
|
||||
FlowHStack {
|
||||
ForEach(post.tags, id: \.id) { tag in
|
||||
TagView(tag: tag.name)
|
||||
.onTapGesture {
|
||||
remove(tag: tag)
|
||||
}
|
||||
TagView(tag: .init(
|
||||
en: tag.english.name,
|
||||
de: tag.german.name)
|
||||
)
|
||||
.onTapGesture {
|
||||
remove(tag: tag)
|
||||
}
|
||||
}
|
||||
Button(action: showTagList) {
|
||||
SwiftUI.Image(systemSymbol: .plusCircleFill)
|
||||
@ -49,7 +52,7 @@ struct PostView: View {
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
TextEditor(text: post.text.text(for: language))
|
||||
TextEditor(text: post.localized(in: language).editableContent())
|
||||
.font(.body)
|
||||
.foregroundStyle(Color(r: 221, g: 221, b: 221))
|
||||
.textEditorStyle(.plain)
|
||||
|
Reference in New Issue
Block a user