mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 19:05:20 +00:00
Gracefully disable mac attachment pickers in sandbox
This commit is contained in:
@@ -75,6 +75,9 @@ 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
|
||||||
@@ -205,13 +208,12 @@ struct ContentView: View {
|
|||||||
Task { await handlePhotoSelection(item) }
|
Task { await handlePhotoSelection(item) }
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
.fileImporter(isPresented: $showImageImporter, allowedContentTypes: [.image], allowsMultipleSelection: false) { result in
|
.alert("Attachments Unavailable", isPresented: $showAttachmentUnavailableAlert, actions: {
|
||||||
handleImportResult(result, handler: handleImportedImage)
|
Button("OK", role: .cancel) {}
|
||||||
}
|
}, message: {
|
||||||
|
Text("File and photo pickers require additional entitlements on macOS preview builds.")
|
||||||
|
})
|
||||||
#endif
|
#endif
|
||||||
.fileImporter(isPresented: $showFileImporter, allowedContentTypes: [.data], allowsMultipleSelection: false) { result in
|
|
||||||
handleImportResult(result, handler: handleImportedFile)
|
|
||||||
}
|
|
||||||
.sheet(isPresented: Binding(
|
.sheet(isPresented: Binding(
|
||||||
get: { imagePreviewURL != nil },
|
get: { imagePreviewURL != nil },
|
||||||
set: { presenting in if !presenting { imagePreviewURL = nil } }
|
set: { presenting in if !presenting { imagePreviewURL = nil } }
|
||||||
@@ -229,12 +231,16 @@ struct ContentView: View {
|
|||||||
#else
|
#else
|
||||||
Button("Image") {
|
Button("Image") {
|
||||||
showAttachmentActions = false
|
showAttachmentActions = false
|
||||||
DispatchQueue.main.async { showImageImporter = true }
|
showAttachmentUnavailableAlert = true
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
Button("File") {
|
Button("File") {
|
||||||
showAttachmentActions = false
|
showAttachmentActions = false
|
||||||
|
#if os(iOS)
|
||||||
DispatchQueue.main.async { showFileImporter = true }
|
DispatchQueue.main.async { showFileImporter = true }
|
||||||
|
#else
|
||||||
|
showAttachmentUnavailableAlert = true
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
Button("Cancel", role: .cancel) {}
|
Button("Cancel", role: .cancel) {}
|
||||||
}
|
}
|
||||||
@@ -1903,24 +1909,6 @@ private extension ContentView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var attachmentButton: some View {
|
var attachmentButton: some View {
|
||||||
#if os(macOS)
|
|
||||||
Menu {
|
|
||||||
Button("Image") {
|
|
||||||
showImageImporter = false
|
|
||||||
DispatchQueue.main.async { showImageImporter = true }
|
|
||||||
}
|
|
||||||
Button("File") {
|
|
||||||
showFileImporter = false
|
|
||||||
DispatchQueue.main.async { showFileImporter = true }
|
|
||||||
}
|
|
||||||
} label: {
|
|
||||||
Image(systemName: "paperclip.circle.fill")
|
|
||||||
.font(.bitchatSystem(size: 24))
|
|
||||||
.foregroundColor(composerAccentColor)
|
|
||||||
.frame(width: 36, height: 36)
|
|
||||||
}
|
|
||||||
.menuStyle(.borderlessButton)
|
|
||||||
#else
|
|
||||||
Button(action: { showAttachmentActions = true }) {
|
Button(action: { showAttachmentActions = true }) {
|
||||||
Image(systemName: "paperclip.circle.fill")
|
Image(systemName: "paperclip.circle.fill")
|
||||||
.font(.bitchatSystem(size: 24))
|
.font(.bitchatSystem(size: 24))
|
||||||
@@ -1928,7 +1916,6 @@ private extension ContentView {
|
|||||||
.frame(width: 36, height: 36)
|
.frame(width: 36, height: 36)
|
||||||
}
|
}
|
||||||
.buttonStyle(.plain)
|
.buttonStyle(.plain)
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var sendOrMicButton: some View {
|
var sendOrMicButton: some View {
|
||||||
|
|||||||
Reference in New Issue
Block a user