60 lines
1.5 KiB
Swift
60 lines
1.5 KiB
Swift
import SwiftUI
|
|
|
|
struct ImageDetailsView: View {
|
|
|
|
@Environment(\.language)
|
|
var language
|
|
|
|
let image: ImageResource
|
|
|
|
@State
|
|
private var newId: String
|
|
|
|
init(image: ImageResource) {
|
|
self.image = image
|
|
self.newId = image.id
|
|
}
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading) {
|
|
Text("Unique identifier")
|
|
.font(.headline)
|
|
HStack {
|
|
TextField("", text: $newId)
|
|
Button(action: setNewId) {
|
|
Text("Update")
|
|
}
|
|
}
|
|
Text("Description")
|
|
.font(.headline)
|
|
TextField("", text: image.altText.text(for: language))
|
|
Text("Info")
|
|
.font(.headline)
|
|
HStack(alignment: .top) {
|
|
VStack(alignment: .leading) {
|
|
Text("Original Size")
|
|
Text("Aspect ratio")
|
|
}
|
|
VStack(alignment: .trailing) {
|
|
Text("\(Int(image.size.width)) x \(Int(image.size.height))")
|
|
Text("\(image.aspectRatio)")
|
|
}
|
|
}.padding(.vertical)
|
|
Text("Versions")
|
|
.font(.headline)
|
|
Spacer()
|
|
}
|
|
.padding()
|
|
}
|
|
|
|
private func setNewId() {
|
|
#warning("Check if ID is unique")
|
|
// TODO: Clean id
|
|
image.id = newId
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
ImageDetailsView(image: MockImage.images.first!)
|
|
}
|