56 lines
1.6 KiB
Swift
56 lines
1.6 KiB
Swift
import SwiftUI
|
|
|
|
struct FileDetailView: View {
|
|
|
|
@ObservedObject
|
|
var file: FileResource
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading) {
|
|
DetailTitle(
|
|
title: "File",
|
|
text: "A file that can be used in a post or page")
|
|
|
|
IdPropertyView(
|
|
id: $file.id,
|
|
title: "Name",
|
|
footer: "The unique name of the file, which is also used to reference it in posts and pages.",
|
|
validation: file.isValid,
|
|
update: { file.update(id: $0) })
|
|
|
|
StringPropertyView(
|
|
title: "German Description",
|
|
text: $file.german,
|
|
footer: "The description for the file in German. Descriptions are used for images and to explain the content of a file.")
|
|
|
|
StringPropertyView(
|
|
title: "English Description",
|
|
text: $file.english,
|
|
footer: "The description for the file in English. Descriptions are used for images and to explain the content of a file.")
|
|
|
|
if file.type.isImage {
|
|
Text("Image size")
|
|
.font(.headline)
|
|
Text("\(Int(file.size.width)) x \(Int(file.size.height)) (\(file.aspectRatio))")
|
|
.foregroundStyle(.secondary)
|
|
#warning("Add button to show image versions")
|
|
}
|
|
Spacer()
|
|
}.padding()
|
|
}
|
|
}
|
|
|
|
extension FileDetailView: MainContentView {
|
|
|
|
init(item: FileResource) {
|
|
self.init(file: item)
|
|
}
|
|
|
|
static let itemDescription = "a file"
|
|
}
|
|
|
|
|
|
#Preview {
|
|
FileDetailView(file: .mock)
|
|
}
|