Enable mac attachment importers

This commit is contained in:
jack
2025-10-14 22:21:17 +02:00
parent c75f32da2c
commit d8e8703a5f
2 changed files with 10 additions and 10 deletions
+8 -10
View File
@@ -75,9 +75,6 @@ struct ContentView: View {
@State private var selectedPhotoPickerItem: PhotosPickerItem? @State private var selectedPhotoPickerItem: PhotosPickerItem?
#endif #endif
@State private var showAttachmentActions = false @State private var showAttachmentActions = false
#if os(macOS)
@State private var showAttachmentUnavailableAlert = false
#endif
@ScaledMetric(relativeTo: .body) private var headerHeight: CGFloat = 44 @ScaledMetric(relativeTo: .body) private var headerHeight: CGFloat = 44
@ScaledMetric(relativeTo: .subheadline) private var headerPeerIconSize: CGFloat = 11 @ScaledMetric(relativeTo: .subheadline) private var headerPeerIconSize: CGFloat = 11
@ScaledMetric(relativeTo: .subheadline) private var headerPeerCountFontSize: CGFloat = 12 @ScaledMetric(relativeTo: .subheadline) private var headerPeerCountFontSize: CGFloat = 12
@@ -211,11 +208,12 @@ struct ContentView: View {
handleImportResult(result, handler: handleImportedFile) handleImportResult(result, handler: handleImportedFile)
} }
#else #else
.alert("Attachments Unavailable", isPresented: $showAttachmentUnavailableAlert, actions: { .fileImporter(isPresented: $showImageImporter, allowedContentTypes: [.image], allowsMultipleSelection: false) { result in
Button("OK", role: .cancel) {} handleImportResult(result, handler: handleImportedImage)
}, message: { }
Text("File and photo pickers require additional entitlements on macOS preview builds.") .fileImporter(isPresented: $showFileImporter, allowedContentTypes: [.data], allowsMultipleSelection: false) { result in
}) handleImportResult(result, handler: handleImportedFile)
}
#endif #endif
.sheet(isPresented: Binding( .sheet(isPresented: Binding(
get: { imagePreviewURL != nil }, get: { imagePreviewURL != nil },
@@ -234,7 +232,7 @@ struct ContentView: View {
#else #else
Button("Image") { Button("Image") {
showAttachmentActions = false showAttachmentActions = false
showAttachmentUnavailableAlert = true DispatchQueue.main.async { showImageImporter = true }
} }
#endif #endif
Button("File") { Button("File") {
@@ -242,7 +240,7 @@ struct ContentView: View {
#if os(iOS) #if os(iOS)
DispatchQueue.main.async { showFileImporter = true } DispatchQueue.main.async { showFileImporter = true }
#else #else
showAttachmentUnavailableAlert = true DispatchQueue.main.async { showFileImporter = true }
#endif #endif
} }
Button("Cancel", role: .cancel) {} Button("Cancel", role: .cancel) {}
+2
View File
@@ -16,5 +16,7 @@
<true/> <true/>
<key>com.apple.security.network.server</key> <key>com.apple.security.network.server</key>
<true/> <true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict> </dict>
</plist> </plist>