From 02e3417c27679836542f5cbecaa824bd023cc7a1 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 7 Jun 2022 09:51:06 -0400 Subject: [PATCH] Full size attachment previews on Compose screen (iOS 16) Closes #110 --- Tusker/Screens/Compose/ComposeAttachmentRow.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Tusker/Screens/Compose/ComposeAttachmentRow.swift b/Tusker/Screens/Compose/ComposeAttachmentRow.swift index 3254b10e..0afbbe7f 100644 --- a/Tusker/Screens/Compose/ComposeAttachmentRow.swift +++ b/Tusker/Screens/Compose/ComposeAttachmentRow.swift @@ -46,6 +46,8 @@ struct ComposeAttachmentRow: View { Label("Delete", systemImage: "trash") } } + } previewIfAvailable: { + ComposeAttachmentImage(attachment: attachment, fullSize: true) } switch mode { @@ -151,6 +153,17 @@ extension ComposeAttachmentRow { } } +private extension View { + @ViewBuilder + func contextMenu(@ViewBuilder menuItems: () -> M, @ViewBuilder previewIfAvailable preview: () -> P) -> some View { + if #available(iOS 16.0, *) { + self.contextMenu(menuItems: menuItems, preview: preview) + } else { + self.contextMenu(menuItems: menuItems) + } + } +} + //struct ComposeAttachmentRow_Previews: PreviewProvider { // static var previews: some View { // ComposeAttachmentRow()