Skip to content

Instantly share code, notes, and snippets.

@amosgyamfi
Created September 26, 2023 11:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amosgyamfi/b6c562e6eac2a4263c646d9aecbdcc11 to your computer and use it in GitHub Desktop.
Save amosgyamfi/b6c562e6eac2a4263c646d9aecbdcc11 to your computer and use it in GitHub Desktop.
//
// ParticipantsView.swift
// VideoConferencingSwiftUI
//
// Created by amos.gyamfi@getstream.io on 18.9.2023.
//
import SwiftUI
import StreamVideo
import StreamVideoSwiftUI
struct ParticipantsView: View {
var call: Call
var participants: [CallParticipant]
var onChangeTrackVisibility: (CallParticipant?, Bool) -> Void
var body: some View {
GeometryReader { proxy in
if !participants.isEmpty {
ScrollView {
LazyVStack {
if participants.count == 1, let participant = participants.first {
makeCallParticipantView(participant, size: proxy.size)
.frame(width: proxy.size.width, height: proxy.size.height)
} else {
ForEach(participants) { participant in
makeCallParticipantView(participant, size: proxy.size)
.frame(width: proxy.size.width, height: proxy.size.height / 2)
}
}
}
}
} else {
Color.black
}
}
.edgesIgnoringSafeArea(.all)
}
@ViewBuilder
private func makeCallParticipantView(_ participant: CallParticipant, size: CGSize) -> some View {
VideoCallParticipantView(
participant: participant,
availableSize: size,
contentMode: .scaleAspectFit,
customData: [:],
call: call
)
.onAppear { onChangeTrackVisibility(participant, true) }
.onDisappear{ onChangeTrackVisibility(participant, false) }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment