Skip to content

Commit 2152bec

Browse files
AddViewFactory.makeVideoPlayerFooterView to customize video player footer (#879)
* Add a view factory method to customise the footer in VideoPlayerView (#871) * Update CHANGELOG.md --------- Co-authored-by: schornon <45765579+schornon@users.noreply.github.com>
1 parent bdebe87 commit 2152bec

File tree

6 files changed

+55
-7
lines changed

6 files changed

+55
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
55

66
### ✅ Added
77
- Add support for customising the `MessageAvatarView` placeholder [#878](https://github.com/GetStream/stream-chat-swiftui/pull/878)
8+
- Add `ViewFactory.makeVideoPlayerFooterView` to customize video player footer [#879](https://github.com/GetStream/stream-chat-swiftui/pull/879)
89

910
# [4.81.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.81.0)
1011
_July 03, 2025_
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// Copyright © 2025 Stream.io Inc. All rights reserved.
3+
//
4+
5+
import StreamChat
6+
import SwiftUI
7+
8+
/// View used as a video player's footer.
9+
struct VideoPlayerFooterView: View {
10+
11+
@Injected(\.colors) private var colors
12+
13+
let attachment: ChatMessageVideoAttachment
14+
@Binding var shown: Bool
15+
16+
var body: some View {
17+
HStack {
18+
ShareButtonView(content: [attachment.payload.videoURL])
19+
.standardPadding()
20+
21+
Spacer()
22+
}
23+
.foregroundColor(Color(colors.text))
24+
}
25+
}

Sources/StreamChatSwiftUI/ChatChannel/Gallery/VideoPlayerView.swift

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,10 @@ public struct VideoPlayerView<Factory: ViewFactory>: View {
4949
VideoPlayer(player: avPlayer)
5050
}
5151
Spacer()
52-
HStack {
53-
ShareButtonView(content: [attachment.payload.videoURL])
54-
.standardPadding()
55-
56-
Spacer()
57-
}
58-
.foregroundColor(Color(colors.text))
52+
viewFactory.makeVideoPlayerFooterView(
53+
attachment: attachment,
54+
shown: $isShown
55+
)
5956
}
6057
.onAppear {
6158
fileCDN.adjustedURL(for: attachment.payload.videoURL) { result in

Sources/StreamChatSwiftUI/DefaultViewFactory.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,16 @@ extension ViewFactory {
500500
GalleryHeaderView(title: title, subtitle: subtitle, isShown: shown)
501501
}
502502

503+
public func makeVideoPlayerFooterView(
504+
attachment: ChatMessageVideoAttachment,
505+
shown: Binding<Bool>
506+
) -> some View {
507+
VideoPlayerFooterView(
508+
attachment: attachment,
509+
shown: shown
510+
)
511+
}
512+
503513
public func makeDeletedMessageView(
504514
for message: ChatMessage,
505515
isFirst: Bool,

Sources/StreamChatSwiftUI/ViewFactory.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,17 @@ public protocol ViewFactory: AnyObject {
504504
subtitle: String,
505505
shown: Binding<Bool>
506506
) -> VideoPlayerHeaderViewType
507+
508+
associatedtype VideoPlayerFooterViewType: View
509+
/// Creates the video player footer view presented with a sheet.
510+
/// - Parameters:
511+
/// - attachment: the video attachment that will be displayed.
512+
/// - shown: Binding controlling whether the video player is shown.
513+
/// - Returns: View displayed in the video player footer slot.
514+
func makeVideoPlayerFooterView(
515+
attachment: ChatMessageVideoAttachment,
516+
shown: Binding<Bool>
517+
) -> VideoPlayerFooterViewType
507518

508519
associatedtype DeletedMessageViewType: View
509520
/// Creates the deleted message view.

StreamChatSwiftUI.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@
539539
ADE442F22CBDAAC40066CDF7 /* ChatThreadListItemView_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADE442F12CBDAAC40066CDF7 /* ChatThreadListItemView_Tests.swift */; };
540540
ADF544382DC93C2A0024A0B3 /* MessageTranslationFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADF544372DC93C0D0024A0B3 /* MessageTranslationFooterView.swift */; };
541541
C14A465B284665B100EF498E /* SDKIdentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = C14A465A284665B100EF498E /* SDKIdentifier.swift */; };
542+
C52A0B5F2E1557F900176379 /* VideoPlayerFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C52A0B5E2E1557F300176379 /* VideoPlayerFooterView.swift */; };
542543
E3A1C01C282BAC66002D1E26 /* Sentry in Frameworks */ = {isa = PBXBuildFile; productRef = E3A1C01B282BAC66002D1E26 /* Sentry */; };
543544
/* End PBXBuildFile section */
544545

@@ -1146,6 +1147,7 @@
11461147
ADE442F12CBDAAC40066CDF7 /* ChatThreadListItemView_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatThreadListItemView_Tests.swift; sourceTree = "<group>"; };
11471148
ADF544372DC93C0D0024A0B3 /* MessageTranslationFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageTranslationFooterView.swift; sourceTree = "<group>"; };
11481149
C14A465A284665B100EF498E /* SDKIdentifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SDKIdentifier.swift; sourceTree = "<group>"; };
1150+
C52A0B5E2E1557F300176379 /* VideoPlayerFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoPlayerFooterView.swift; sourceTree = "<group>"; };
11491151
/* End PBXFileReference section */
11501152

11511153
/* Begin PBXFrameworksBuildPhase section */
@@ -2261,6 +2263,7 @@
22612263
84F29089276B90610045472D /* GalleryView.swift */,
22622264
8434E58027707F19001E1B83 /* GridPhotosView.swift */,
22632265
8465FD032746A95600AF091E /* VideoPlayerView.swift */,
2266+
C52A0B5E2E1557F300176379 /* VideoPlayerFooterView.swift */,
22642267
84F2908B276B91700045472D /* ZoomableScrollView.swift */,
22652268
84F2908F276CC1280045472D /* ShareButtonView.swift */,
22662269
);
@@ -2916,6 +2919,7 @@
29162919
AD3AB65C2CB730090014D4D7 /* Shimmer.swift in Sources */,
29172920
AD3AB6522CB498380014D4D7 /* HideTabBarModifier.swift in Sources */,
29182921
8423C33F277C9A5F0092DCF1 /* UnmuteCommandHandler.swift in Sources */,
2922+
C52A0B5F2E1557F900176379 /* VideoPlayerFooterView.swift in Sources */,
29192923
8421BCEE27A43E14000F977D /* SearchBar.swift in Sources */,
29202924
84EADEBB2B28BAE40046B50C /* RecordingWaveform.swift in Sources */,
29212925
841B64CA2775BBC10016FF3B /* Errors.swift in Sources */,

0 commit comments

Comments
 (0)