Add participants list and active speaker to the conference call view

This commit is contained in:
Benoit Martins 2024-04-02 17:07:54 +02:00
parent ab3b883442
commit 027cb1ec2d
2 changed files with 88 additions and 26 deletions

View file

@ -402,6 +402,7 @@ struct CallView: View {
}
}
// swiftlint:disable:next cyclomatic_complexity
func simpleCallView(geometry: GeometryProxy) -> some View {
ZStack {
if !callViewModel.isConference {
@ -598,7 +599,7 @@ struct CallView: View {
if viewIsDisplayed && (callViewModel.receiveVideo || telecomManager.remoteConfVideo) {
*/
if (callViewModel.receiveVideo || telecomManager.remoteConfVideo) {
if (callViewModel.receiveVideo || telecomManager.remoteConfVideo) && !telecomManager.outgoingCallStarted {
LinphoneVideoViewHolder { view in
coreContext.doOnCoreQueue { core in
//core.nativeVideoWindow = view
@ -623,13 +624,73 @@ struct CallView: View {
}
}
/*
HStack {
Spacer()
VStack {
Spacer()
LinphoneVideoViewHolder { view in
coreContext.doOnCoreQueue { core in
core.nativePreviewWindow = view
}
}
.frame(width: angleDegree == 0 ? 120*1.2 : 160*1.2, height: angleDegree == 0 ? 160*1.2 : 120*1.2)
.cornerRadius(20)
.padding(10)
.padding(.trailing, abs(angleDegree/2))
}
}
.frame(
maxWidth: fullscreenVideo && !telecomManager.isPausedByRemote ? geometry.size.width : geometry.size.width - 8,
maxHeight: fullscreenVideo && !telecomManager.isPausedByRemote ? geometry.size.height + geometry.safeAreaInsets.top + geometry.safeAreaInsets.bottom : geometry.size.height - (minBottomSheetHeight * geometry.size.height > 80 ? minBottomSheetHeight * geometry.size.height : 78) - 40 - 20 + geometry.safeAreaInsets.bottom
)
*/
}
if !telecomManager.outgoingCallStarted {
HStack {
Spacer()
VStack {
Spacer()
ScrollView(.horizontal) {
HStack {
ForEach(0..<callViewModel.participantList.count - 1, id: \.self) { index in
ZStack {
VStack {
Spacer()
if callViewModel.myParticipantModel != nil {
Avatar(contactAvatarModel: callViewModel.myParticipantModel!.avatarModel, avatarSize: 50)
}
Spacer()
}
VStack(alignment: .leading) {
Spacer()
if callViewModel.myParticipantModel != nil {
Text(callViewModel.myParticipantModel!.name)
.frame(maxWidth: .infinity, alignment: .leading)
.foregroundStyle(Color.white)
.default_text_style_500(styleSize: 14)
.lineLimit(1)
.padding(.horizontal, 10)
.padding(.bottom, 6)
}
}
.frame(maxWidth: .infinity)
LinphoneVideoViewHolder { view in
coreContext.doOnCoreQueue { core in
core.nativePreviewWindow = view
}
}
}
.frame(width: 140, height: 140)
.background(Color.gray600)
.cornerRadius(20)
ForEach(0..<callViewModel.participantList.count, id: \.self) { index in
ZStack {
VStack {
Spacer()
@ -665,27 +726,6 @@ struct CallView: View {
maxHeight: fullscreenVideo && !telecomManager.isPausedByRemote ? geometry.size.height + geometry.safeAreaInsets.top + geometry.safeAreaInsets.bottom : geometry.size.height - (minBottomSheetHeight * geometry.size.height > 80 ? minBottomSheetHeight * geometry.size.height : 78) - 40 - 20 + geometry.safeAreaInsets.bottom
)
.padding(.bottom, 10)
/*
HStack {
Spacer()
VStack {
Spacer()
LinphoneVideoViewHolder { view in
coreContext.doOnCoreQueue { core in
core.nativePreviewWindow = view
}
}
.frame(width: angleDegree == 0 ? 120*1.2 : 160*1.2, height: angleDegree == 0 ? 160*1.2 : 120*1.2)
.cornerRadius(20)
.padding(10)
.padding(.trailing, abs(angleDegree/2))
}
}
.frame(
maxWidth: fullscreenVideo && !telecomManager.isPausedByRemote ? geometry.size.width : geometry.size.width - 8,
maxHeight: fullscreenVideo && !telecomManager.isPausedByRemote ? geometry.size.height + geometry.safeAreaInsets.top + geometry.safeAreaInsets.bottom : geometry.size.height - (minBottomSheetHeight * geometry.size.height > 80 ? minBottomSheetHeight * geometry.size.height : 78) - 40 - 20 + geometry.safeAreaInsets.bottom
)
*/
}
}
@ -711,7 +751,7 @@ struct CallView: View {
)
}
if telecomManager.outgoingCallStarted {
if telecomManager.outgoingCallStarted {
VStack {
ActivityIndicator()
.frame(width: 20, height: 20)

View file

@ -50,6 +50,7 @@ class CallViewModel: ObservableObject {
@Published var receiveVideo: Bool = false
@Published var participantList: [ParticipantModel] = []
@Published var activeSpeakerParticipant: ParticipantModel? = nil
@Published var myParticipantModel: ParticipantModel? = nil
private var mConferenceSuscriptions = Set<AnyCancellable?>()
@ -148,7 +149,13 @@ class CallViewModel: ObservableObject {
self.participantList = []
conf?.participantInfos.forEach({ participantInfo in
if participantInfo.address != nil {
self.participantList.append(ParticipantModel(address: participantInfo.address!))
if participantInfo.address!.equal(address2: (self.currentCall?.callLog?.localAddress!)!) {
self.myParticipantModel = ParticipantModel(address: participantInfo.address!)
} else {
if self.activeSpeakerParticipant != nil && !participantInfo.address!.equal(address2: self.activeSpeakerParticipant!.address) {
self.participantList.append(ParticipantModel(address: participantInfo.address!))
}
}
}
})
self.addConferenceCallBacks()
@ -167,9 +174,24 @@ class CallViewModel: ObservableObject {
self.receiveVideo = direction == MediaDirection.SendRecv || direction == MediaDirection.SendOnly
if cbValue.participantDevice.address != nil {
let activeSpeakerParticipantTmp = self.activeSpeakerParticipant
self.activeSpeakerParticipant = ParticipantModel(address: cbValue.participantDevice.address!)
if self.activeSpeakerParticipant != nil
&& ((activeSpeakerParticipantTmp != nil && !activeSpeakerParticipantTmp!.address.equal(address2: self.activeSpeakerParticipant!.address))
|| ( activeSpeakerParticipantTmp == nil)) {
self.participantList = []
cbValue.conference.participantList.forEach({ participant in
if participant.address != nil && !cbValue.conference.isMe(uri: participant.address!) {
if !cbValue.conference.isMe(uri: participant.address!) && !participant.address!.equal(address2: self.activeSpeakerParticipant!.address) {
self.participantList.append(ParticipantModel(address: participant.address!))
}
}
})
}
}
})
})
}
}