From bf7cdc37122080427036ceed1cbf555cf740e369 Mon Sep 17 00:00:00 2001 From: "Thai D. V" <46838577+thai-d-v@users.noreply.github.com> Date: Thu, 18 Jan 2024 12:43:40 +0700 Subject: [PATCH] add scroll bar in `StatusRowMediaPreviewView` for macOS version (#1896) --- .../Row/Subviews/StatusRowMediaPreviewView.swift | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowMediaPreviewView.swift b/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowMediaPreviewView.swift index 20a248c4..42f34383 100644 --- a/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowMediaPreviewView.swift +++ b/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowMediaPreviewView.swift @@ -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() }