Unified detail views, model
This commit is contained in:
@ -0,0 +1,36 @@
|
||||
import SwiftUI
|
||||
|
||||
struct OptionalImagePropertyView: View {
|
||||
|
||||
let title: LocalizedStringKey
|
||||
|
||||
@Binding
|
||||
var selectedImage: FileResource?
|
||||
|
||||
let footer: LocalizedStringKey
|
||||
|
||||
@State
|
||||
private var showSelectionSheet = false
|
||||
|
||||
var body: some View {
|
||||
GenericPropertyView(title: title, footer: footer) {
|
||||
if let image = selectedImage {
|
||||
image.imageToDisplay
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(maxHeight: 300)
|
||||
.cornerRadius(8)
|
||||
}
|
||||
HStack {
|
||||
Text(selectedImage?.id ?? "No file selected")
|
||||
Spacer()
|
||||
Button("Select") {
|
||||
showSelectionSheet = true
|
||||
}
|
||||
}
|
||||
}
|
||||
.sheet(isPresented: $showSelectionSheet) {
|
||||
FileSelectionView(selectedFile: $selectedImage, allowedType: .images)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user