Transfer link preview images from other language

This commit is contained in:
Christoph Hagen
2025-01-13 21:54:43 +01:00
parent a5c692cb09
commit 864dc9a544
9 changed files with 68 additions and 11 deletions

View File

@ -7,13 +7,26 @@ struct OptionalImagePropertyView: View {
@Binding
var selectedImage: FileResource?
let transferImage: (language: ContentLanguage, image: FileResource)?
let footer: LocalizedStringKey
@State
private var showSelectionSheet = false
var body: some View {
GenericPropertyView(title: title, footer: footer) {
VStack(alignment: .leading) {
HStack {
Text(title)
.font(.headline)
Spacer()
if let transferImage {
Button("From \(transferImage.language.shortText)") {
selectedImage = transferImage.image
}
}
}
if let image = selectedImage {
image.imageToDisplay
.resizable()
@ -21,6 +34,7 @@ struct OptionalImagePropertyView: View {
.frame(maxHeight: 300)
.cornerRadius(8)
}
HStack {
Text(selectedImage?.id ?? "No file selected")
Spacer()
@ -28,6 +42,9 @@ struct OptionalImagePropertyView: View {
showSelectionSheet = true
}
}
Text(footer)
.foregroundStyle(.secondary)
.padding(.bottom)
}
.sheet(isPresented: $showSelectionSheet) {
FileSelectionView(selectedFile: $selectedImage, allowedType: .image)