Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### ✅ Added
- When the user is missing a permission, the SDK will prompt them to accept any missing permission. [#915](https://github.com/GetStream/stream-video-swift/pull/915)
- You can now set the `ViewFactory` instance to be used from Picture-in-Picture. [#934](https://github.com/GetStream/stream-video-swift/pull/934)

### 🔄 Changed
- Improved the LastParticipantLeavePolicy to be more robust. [#925](https://github.com/GetStream/stream-video-swift/pull/925)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import SwiftUI
/// ensures thread safety with `@unchecked Sendable` conformance.
final class PictureInPictureViewFactory: @unchecked Sendable {

let source: any ViewFactory

private let _makeParticipantImageView: (CallParticipant) -> AnyView

/// Creates a new instance of `PictureInPictureViewFactory`.
Expand All @@ -22,6 +24,7 @@ final class PictureInPictureViewFactory: @unchecked Sendable {
/// protocol, used to create the participant image views.
@MainActor
init<Factory: ViewFactory>(_ viewFactory: Factory) {
source = viewFactory
_makeParticipantImageView = {
AnyView(
CallParticipantImageView(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ public final class StreamPictureInPictureAdapter: @unchecked Sendable {
.store(in: disposableBag)
}
}

// MARK: - State updaters

/// Updates the ViewFactory instance the will be used by Picture-in-Picture to create UI components.
@MainActor
public func setViewFactory<V: ViewFactory>(_ viewFactory: V) {
guard let store else {
return
}
store.dispatch(.setViewFactory(.init(viewFactory)))
}
}

/// Provides the default value for the Picture-in-Picture adapter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,18 @@ final class StreamPictureInPictureAdapterTests: XCTestCase, @unchecked Sendable

await fulfilmentInMainActor { self.subject.store?.state.sourceView === view }
}

// MARK: - ViewFactory updated

@MainActor
func test_setViewFactory_storeWasUpdated() async {
final class CustomViewFactory: ViewFactory {}
_ = subject
await fulfillment { self.subject.store != nil }
let viewFactory = CustomViewFactory()

subject.setViewFactory(viewFactory)

await fulfillment { self.subject.store?.state.viewFactory.source === viewFactory }
}
}
Loading