39 lines
1.0 KiB
Swift
39 lines
1.0 KiB
Swift
import SwiftUI
|
|
|
|
struct FilePropertyView: View {
|
|
|
|
let title: LocalizedStringKey
|
|
|
|
let footer: LocalizedStringKey
|
|
|
|
@Binding
|
|
var selectedFile: FileResource?
|
|
|
|
let allowedType: FileFilterType?
|
|
|
|
init(title: LocalizedStringKey, footer: LocalizedStringKey, selectedFile: Binding<FileResource?>, allowedType: FileFilterType? = nil) {
|
|
self.title = title
|
|
self.footer = footer
|
|
self._selectedFile = selectedFile
|
|
self.allowedType = allowedType
|
|
}
|
|
|
|
@State
|
|
private var showFileSelectionSheet = false
|
|
|
|
var body: some View {
|
|
GenericPropertyView(title: title, footer: footer) {
|
|
HStack {
|
|
Text(selectedFile?.id ?? "No file selected")
|
|
Spacer()
|
|
Button("Select") {
|
|
showFileSelectionSheet = true
|
|
}
|
|
}
|
|
}
|
|
.sheet(isPresented: $showFileSelectionSheet) {
|
|
FileSelectionView(selectedFile: $selectedFile, allowedType: allowedType)
|
|
}
|
|
}
|
|
}
|