mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 03:25:19 +00:00
Add proper availability checks for PhotosPickerItem
PhotosPickerItem requires iOS 16+ / macOS 13+ but canImport(PhotosUI) succeeds on older macOS versions. Add compiler version check to ensure PhotosPicker code only compiles when actually available. This fixes CI build failures on older macOS environments.
This commit is contained in:
@@ -73,7 +73,7 @@ struct ContentView: View {
|
|||||||
@State private var recordingTimer: Timer?
|
@State private var recordingTimer: Timer?
|
||||||
@State private var recordingStartDate: Date?
|
@State private var recordingStartDate: Date?
|
||||||
@State private var showFileImporter = false
|
@State private var showFileImporter = false
|
||||||
#if canImport(PhotosUI)
|
#if canImport(PhotosUI) && ((os(iOS) && compiler(>=5.7)) || (os(macOS) && compiler(>=5.7)))
|
||||||
@State private var showPhotoPicker = false
|
@State private var showPhotoPicker = false
|
||||||
@State private var selectedPhotoPickerItem: PhotosPickerItem?
|
@State private var selectedPhotoPickerItem: PhotosPickerItem?
|
||||||
#endif
|
#endif
|
||||||
@@ -210,7 +210,7 @@ struct ContentView: View {
|
|||||||
FingerprintView(viewModel: viewModel, peerID: peerID)
|
FingerprintView(viewModel: viewModel, peerID: peerID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if canImport(PhotosUI)
|
#if canImport(PhotosUI) && ((os(iOS) && compiler(>=5.7)) || (os(macOS) && compiler(>=5.7)))
|
||||||
.photosPicker(isPresented: $showPhotoPicker, selection: $selectedPhotoPickerItem, matching: .images)
|
.photosPicker(isPresented: $showPhotoPicker, selection: $selectedPhotoPickerItem, matching: .images)
|
||||||
.onChange(of: selectedPhotoPickerItem) { newItem in
|
.onChange(of: selectedPhotoPickerItem) { newItem in
|
||||||
guard let item = newItem else { return }
|
guard let item = newItem else { return }
|
||||||
@@ -229,7 +229,7 @@ struct ContentView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.confirmationDialog("Attach", isPresented: $showAttachmentActions, titleVisibility: .visible) {
|
.confirmationDialog("Attach", isPresented: $showAttachmentActions, titleVisibility: .visible) {
|
||||||
#if canImport(PhotosUI)
|
#if canImport(PhotosUI) && ((os(iOS) && compiler(>=5.7)) || (os(macOS) && compiler(>=5.7)))
|
||||||
Button("Image") {
|
Button("Image") {
|
||||||
showAttachmentActions = false
|
showAttachmentActions = false
|
||||||
DispatchQueue.main.async { showPhotoPicker = true }
|
DispatchQueue.main.async { showPhotoPicker = true }
|
||||||
@@ -1982,7 +1982,7 @@ private extension ContentView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if canImport(PhotosUI)
|
#if canImport(PhotosUI) && ((os(iOS) && compiler(>=5.7)) || (os(macOS) && compiler(>=5.7)))
|
||||||
func handlePhotoSelection(_ item: PhotosPickerItem) async {
|
func handlePhotoSelection(_ item: PhotosPickerItem) async {
|
||||||
defer { Task { @MainActor in selectedPhotoPickerItem = nil } }
|
defer { Task { @MainActor in selectedPhotoPickerItem = nil } }
|
||||||
do {
|
do {
|
||||||
|
|||||||
Reference in New Issue
Block a user