diff --git a/Sources/StreamChatSwiftUI/ChatChannel/Gallery/VideoPlayerFooterView.swift b/Sources/StreamChatSwiftUI/ChatChannel/Gallery/VideoPlayerFooterView.swift new file mode 100644 index 000000000..49b46bc6c --- /dev/null +++ b/Sources/StreamChatSwiftUI/ChatChannel/Gallery/VideoPlayerFooterView.swift @@ -0,0 +1,25 @@ +// +// Copyright © 2025 Stream.io Inc. All rights reserved. +// + +import StreamChat +import SwiftUI + +/// View used as a video player's footer. +struct VideoPlayerFooterView: View { + + @Injected(\.colors) private var colors + + let attachment: ChatMessageVideoAttachment + @Binding var shown: Bool + + var body: some View { + HStack { + ShareButtonView(content: [attachment.payload.videoURL]) + .standardPadding() + + Spacer() + } + .foregroundColor(Color(colors.text)) + } +} diff --git a/Sources/StreamChatSwiftUI/ChatChannel/Gallery/VideoPlayerView.swift b/Sources/StreamChatSwiftUI/ChatChannel/Gallery/VideoPlayerView.swift index 2e6d35da1..47fbe7731 100644 --- a/Sources/StreamChatSwiftUI/ChatChannel/Gallery/VideoPlayerView.swift +++ b/Sources/StreamChatSwiftUI/ChatChannel/Gallery/VideoPlayerView.swift @@ -49,13 +49,10 @@ public struct VideoPlayerView: View { VideoPlayer(player: avPlayer) } Spacer() - HStack { - ShareButtonView(content: [attachment.payload.videoURL]) - .standardPadding() - - Spacer() - } - .foregroundColor(Color(colors.text)) + viewFactory.makeVideoPlayerFooterView( + attachment: attachment, + shown: $isShown + ) } .onAppear { fileCDN.adjustedURL(for: attachment.payload.videoURL) { result in diff --git a/Sources/StreamChatSwiftUI/DefaultViewFactory.swift b/Sources/StreamChatSwiftUI/DefaultViewFactory.swift index 514f2fa73..b047a22d3 100644 --- a/Sources/StreamChatSwiftUI/DefaultViewFactory.swift +++ b/Sources/StreamChatSwiftUI/DefaultViewFactory.swift @@ -498,6 +498,16 @@ extension ViewFactory { GalleryHeaderView(title: title, subtitle: subtitle, isShown: shown) } + public func makeVideoPlayerFooterView( + attachment: ChatMessageVideoAttachment, + shown: Binding + ) -> some View { + VideoPlayerFooterView( + attachment: attachment, + shown: shown + ) + } + public func makeDeletedMessageView( for message: ChatMessage, isFirst: Bool, diff --git a/Sources/StreamChatSwiftUI/ViewFactory.swift b/Sources/StreamChatSwiftUI/ViewFactory.swift index 0aa9fbebd..3365c2cf3 100644 --- a/Sources/StreamChatSwiftUI/ViewFactory.swift +++ b/Sources/StreamChatSwiftUI/ViewFactory.swift @@ -504,6 +504,17 @@ public protocol ViewFactory: AnyObject { subtitle: String, shown: Binding ) -> VideoPlayerHeaderViewType + + associatedtype VideoPlayerFooterViewType: View + /// Creates the video player footer view presented with a sheet. + /// - Parameters: + /// - attachment: the video attachment that will be displayed. + /// - shown: Binding controlling whether the video player is shown. + /// - Returns: View displayed in the video player footer slot. + func makeVideoPlayerFooterView( + attachment: ChatMessageVideoAttachment, + shown: Binding + ) -> VideoPlayerFooterViewType associatedtype DeletedMessageViewType: View /// Creates the deleted message view. diff --git a/StreamChatSwiftUI.xcodeproj/project.pbxproj b/StreamChatSwiftUI.xcodeproj/project.pbxproj index b7340c313..dbfb175fd 100644 --- a/StreamChatSwiftUI.xcodeproj/project.pbxproj +++ b/StreamChatSwiftUI.xcodeproj/project.pbxproj @@ -539,6 +539,7 @@ ADE442F22CBDAAC40066CDF7 /* ChatThreadListItemView_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADE442F12CBDAAC40066CDF7 /* ChatThreadListItemView_Tests.swift */; }; ADF544382DC93C2A0024A0B3 /* MessageTranslationFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADF544372DC93C0D0024A0B3 /* MessageTranslationFooterView.swift */; }; C14A465B284665B100EF498E /* SDKIdentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = C14A465A284665B100EF498E /* SDKIdentifier.swift */; }; + C52A0B5F2E1557F900176379 /* VideoPlayerFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C52A0B5E2E1557F300176379 /* VideoPlayerFooterView.swift */; }; E3A1C01C282BAC66002D1E26 /* Sentry in Frameworks */ = {isa = PBXBuildFile; productRef = E3A1C01B282BAC66002D1E26 /* Sentry */; }; /* End PBXBuildFile section */ @@ -1146,6 +1147,7 @@ ADE442F12CBDAAC40066CDF7 /* ChatThreadListItemView_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatThreadListItemView_Tests.swift; sourceTree = ""; }; ADF544372DC93C0D0024A0B3 /* MessageTranslationFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageTranslationFooterView.swift; sourceTree = ""; }; C14A465A284665B100EF498E /* SDKIdentifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SDKIdentifier.swift; sourceTree = ""; }; + C52A0B5E2E1557F300176379 /* VideoPlayerFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoPlayerFooterView.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -2261,6 +2263,7 @@ 84F29089276B90610045472D /* GalleryView.swift */, 8434E58027707F19001E1B83 /* GridPhotosView.swift */, 8465FD032746A95600AF091E /* VideoPlayerView.swift */, + C52A0B5E2E1557F300176379 /* VideoPlayerFooterView.swift */, 84F2908B276B91700045472D /* ZoomableScrollView.swift */, 84F2908F276CC1280045472D /* ShareButtonView.swift */, ); @@ -2917,6 +2920,7 @@ AD3AB65C2CB730090014D4D7 /* Shimmer.swift in Sources */, AD3AB6522CB498380014D4D7 /* HideTabBarModifier.swift in Sources */, 8423C33F277C9A5F0092DCF1 /* UnmuteCommandHandler.swift in Sources */, + C52A0B5F2E1557F900176379 /* VideoPlayerFooterView.swift in Sources */, 8421BCEE27A43E14000F977D /* SearchBar.swift in Sources */, 84EADEBB2B28BAE40046B50C /* RecordingWaveform.swift in Sources */, 841B64CA2775BBC10016FF3B /* Errors.swift in Sources */,