This commit is contained in:
Thomas Ricouard 2023-12-21 21:00:44 +01:00
parent 3eb373550e
commit f04f5c701c

View File

@ -137,16 +137,24 @@ struct StatusEditorAccessoryView: View {
}) })
.sheet(isPresented: $isGIFPickerPresented, content: { .sheet(isPresented: $isGIFPickerPresented, content: {
#if !os(visionOS) #if !os(visionOS)
GifPickerView { url in #if targetEnvironment(macCatalyst)
GPHCache.shared.downloadAssetData(url) { data, _ in NavigationStack {
guard let data else { return } giphyView
viewModel.processGIFData(data: data) .toolbar {
ToolbarItem(placement: .topBarLeading) {
Button {
isGIFPickerPresented = false
} label: {
Image(systemName: "xmark.circle")
}
}
}
} }
isGIFPickerPresented = false .presentationDetents([.medium, .large])
} onShouldDismissGifPicker: { #else
isGIFPickerPresented = false giphyView
} .presentationDetents([.medium, .large])
.presentationDetents([.medium, .large]) #endif
#else #else
EmptyView() EmptyView()
#endif #endif
@ -258,6 +266,20 @@ struct StatusEditorAccessoryView: View {
return false 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 { private var draftsListView: some View {
DraftsListView(selectedDraft: .init(get: { DraftsListView(selectedDraft: .init(get: {