From 5a5364ad3b32851596e2601338037e17744ef0ee Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 9 Jul 2022 11:02:01 -0400 Subject: [PATCH] Use iOS 16 API for disabling compose attachment list scrolling --- Tusker/Screens/Compose/ComposeAttachmentsList.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Tusker/Screens/Compose/ComposeAttachmentsList.swift b/Tusker/Screens/Compose/ComposeAttachmentsList.swift index 0d2f30f5..063ca36f 100644 --- a/Tusker/Screens/Compose/ComposeAttachmentsList.swift +++ b/Tusker/Screens/Compose/ComposeAttachmentsList.swift @@ -70,7 +70,9 @@ struct ComposeAttachmentsList: View { .listRowInsets(EdgeInsets(top: cellPadding / 2, leading: cellPadding / 2, bottom: cellPadding / 2, trailing: cellPadding / 2)) } .listStyle(PlainListStyle()) + // todo: scrollDisabled doesn't remove the need for manually calculating the frame height .frame(height: totalListHeight) + .scrollDisabledIfAvailable(totalHeight: totalListHeight) .onAppear(perform: self.didAppear) .onReceive(draft.$attachments, perform: self.attachmentsChanged) } @@ -212,6 +214,16 @@ fileprivate extension View { self } } + + @available(iOS, obsoleted: 16.0) + @ViewBuilder + func scrollDisabledIfAvailable(totalHeight: CGFloat) -> some View { + if #available(iOS 16.0, *) { + self.scrollDisabled(true) + } else { + self.frame(height: totalHeight) + } + } } @available(iOS 16.0, *)