From f04f5c701cfeeba61f7bd50866987b287918000d Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Thu, 21 Dec 2023 21:00:44 +0100 Subject: [PATCH] Fix #1767 --- .../StatusEditorAccessoryView.swift | 40 ++++++++++++++----- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/Packages/Status/Sources/Status/Editor/Components/StatusEditorAccessoryView.swift b/Packages/Status/Sources/Status/Editor/Components/StatusEditorAccessoryView.swift index 203f9818..5fb01b38 100644 --- a/Packages/Status/Sources/Status/Editor/Components/StatusEditorAccessoryView.swift +++ b/Packages/Status/Sources/Status/Editor/Components/StatusEditorAccessoryView.swift @@ -137,16 +137,24 @@ struct StatusEditorAccessoryView: View { }) .sheet(isPresented: $isGIFPickerPresented, content: { #if !os(visionOS) - GifPickerView { url in - GPHCache.shared.downloadAssetData(url) { data, _ in - guard let data else { return } - viewModel.processGIFData(data: data) + #if targetEnvironment(macCatalyst) + NavigationStack { + giphyView + .toolbar { + ToolbarItem(placement: .topBarLeading) { + Button { + isGIFPickerPresented = false + } label: { + Image(systemName: "xmark.circle") + } + } + } } - isGIFPickerPresented = false - } onShouldDismissGifPicker: { - isGIFPickerPresented = false - } - .presentationDetents([.medium, .large]) + .presentationDetents([.medium, .large]) + #else + giphyView + .presentationDetents([.medium, .large]) + #endif #else EmptyView() #endif @@ -258,6 +266,20 @@ struct StatusEditorAccessoryView: View { return false } + + @ViewBuilder + private var giphyView: some View { + @Bindable var viewModel = focusedSEVM + GifPickerView { url in + GPHCache.shared.downloadAssetData(url) { data, _ in + guard let data else { return } + viewModel.processGIFData(data: data) + } + isGIFPickerPresented = false + } onShouldDismissGifPicker: { + isGIFPickerPresented = false + } + } private var draftsListView: some View { DraftsListView(selectedDraft: .init(get: {