add scroll bar in StatusRowMediaPreviewView for macOS version (#1896)

This commit is contained in:
Thai D. V 2024-01-18 12:43:40 +07:00 committed by GitHub
parent f12d0600f7
commit bf7cdc3712
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -22,6 +22,19 @@ public struct StatusRowMediaPreviewView: View {
@State private var isQuickLookLoading: Bool = false
init(attachments: [MediaAttachment], sensitive: Bool) {
self.attachments = attachments
self.sensitive = sensitive
}
#if targetEnvironment(macCatalyst)
private var showsScrollIndicators: Bool { attachments.count > 1 }
private var scrollBottomPadding: CGFloat?
#else
private var showsScrollIndicators: Bool = false
private var scrollBottomPadding: CGFloat? = 0
#endif
var availableWidth: CGFloat {
#if os(visionOS)
return sceneDelegate.windowWidth * 0.96
@ -78,13 +91,14 @@ public struct StatusRowMediaPreviewView: View {
.accessibilityAddTraits([.isButton, .isImage])
.onTapGesture { tabAction(for: 0) }
} else {
ScrollView(.horizontal, showsIndicators: false) {
ScrollView(.horizontal, showsIndicators: showsScrollIndicators) {
HStack {
makeAttachmentView(for: 0)
makeAttachmentView(for: 1)
makeAttachmentView(for: 2)
makeAttachmentView(for: 3)
}
.padding(.bottom, scrollBottomPadding)
}
.scrollClipDisabled()
}