From 7b2ee7ac110eb07e4f7fd2732ee5bcf9e648c44a Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Thu, 27 May 2021 12:29:02 +0400 Subject: [PATCH] Video Chat Improvements --- .../Sources/PeerInfoAvatarListNode.swift | 4 ++-- .../VoiceChatCameraPreviewController.swift | 2 +- .../VoiceChatFullscreenParticipantItem.swift | 7 +++++-- .../Sources/VoiceChatMainStageNode.swift | 15 +++++++++++---- .../Sources/VoiceChatTileItemNode.swift | 16 ++++++---------- submodules/TgVoipWebrtc/tgcalls | 2 +- 6 files changed, 26 insertions(+), 20 deletions(-) diff --git a/submodules/PeerInfoAvatarListNode/Sources/PeerInfoAvatarListNode.swift b/submodules/PeerInfoAvatarListNode/Sources/PeerInfoAvatarListNode.swift index 79fea03e4c..ffde241af1 100644 --- a/submodules/PeerInfoAvatarListNode/Sources/PeerInfoAvatarListNode.swift +++ b/submodules/PeerInfoAvatarListNode/Sources/PeerInfoAvatarListNode.swift @@ -1076,9 +1076,9 @@ public final class PeerInfoAvatarListContainerNode: ASDisplayNode { } let stripInset: CGFloat = 8.0 let stripSpacing: CGFloat = 4.0 - let stripWidth: CGFloat = max(5.0, floor((size.width - stripInset * 2.0 - stripSpacing * CGFloat(self.stripNodes.count - 1)) / CGFloat(self.stripNodes.count))) + let stripWidth: CGFloat = max(5.0, floorToScreenPixels((size.width - stripInset * 2.0 - stripSpacing * CGFloat(self.stripNodes.count - 1)) / CGFloat(self.stripNodes.count))) let currentStripMinX = stripInset + CGFloat(self.currentIndex) * (stripWidth + stripSpacing) - let currentStripMidX = floor(currentStripMinX + stripWidth / 2.0) + let currentStripMidX = floorToScreenPixels(currentStripMinX + stripWidth / 2.0) let lastStripMaxX = stripInset + CGFloat(self.stripNodes.count - 1) * (stripWidth + stripSpacing) + stripWidth let stripOffset: CGFloat = min(0.0, max(size.width - stripInset - lastStripMaxX, size.width / 2.0 - currentStripMidX)) for i in 0 ..< self.stripNodes.count { diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatCameraPreviewController.swift b/submodules/TelegramCallsUI/Sources/VoiceChatCameraPreviewController.swift index 4b246cc9c2..970be25abe 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatCameraPreviewController.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatCameraPreviewController.swift @@ -301,7 +301,7 @@ private class VoiceChatCameraPreviewControllerNode: ViewControllerTracingNode, U } self.readyDisposable.set(self.cameraNode.ready.start(next: { [weak self] ready in - if let strongSelf = self { + if let strongSelf = self, ready { Queue.mainQueue().after(0.07) { strongSelf.shimmerNode.alpha = 0.0 strongSelf.shimmerNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3) diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatFullscreenParticipantItem.swift b/submodules/TelegramCallsUI/Sources/VoiceChatFullscreenParticipantItem.swift index d90867bc19..f52b2ec39d 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatFullscreenParticipantItem.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatFullscreenParticipantItem.swift @@ -494,9 +494,13 @@ class VoiceChatFullscreenParticipantItemNode: ItemListRevealOptionsItemNode { switch item.color { case .accent: wavesColor = accentColor + if case .wantsToSpeak = item.icon { + gradient = .muted + } case .constructive: gradient = .speaking case .destructive: + gradient = .mutedForYou wavesColor = destructiveColor default: break @@ -629,7 +633,6 @@ class VoiceChatFullscreenParticipantItemNode: ItemListRevealOptionsItemNode { transition = .immediate } - if titleUpdated, let snapshotView = strongSelf.titleNode.view.snapshotContentTree() { strongSelf.titleNode.view.superview?.addSubview(snapshotView) snapshotView.frame = strongSelf.titleNode.view.frame @@ -773,7 +776,7 @@ class VoiceChatFullscreenParticipantItemNode: ItemListRevealOptionsItemNode { nodeToAnimateIn = animationNode } var color = color - if hasVideo || color.rgb == 0x979797 { + if (hasVideo && !item.active) || color.rgb == 0x979797 { color = UIColor(rgb: 0xffffff) } animationNode.update(state: VoiceChatMicrophoneNode.State(muted: muted, filled: true, color: color), animated: true) diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatMainStageNode.swift b/submodules/TelegramCallsUI/Sources/VoiceChatMainStageNode.swift index e28adaee3f..a6484ee0b1 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatMainStageNode.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatMainStageNode.swift @@ -525,17 +525,21 @@ final class VoiceChatMainStageNode: ASDisplayNode { var mutedForYou = false switch state { case .listening: - if let muteState = peerEntry.muteState, muteState.mutedByYou { - gradient = .muted + if let muteState = peerEntry.muteState { muted = true - mutedForYou = true + if muteState.mutedByYou { + gradient = .mutedForYou + mutedForYou = true + } else if !muteState.canUnmute { + gradient = .muted + } } else { gradient = .active muted = peerEntry.muteState != nil } case .speaking: if let muteState = peerEntry.muteState, muteState.mutedByYou { - gradient = .muted + gradient = .mutedForYou muted = true mutedForYou = true } else { @@ -858,6 +862,7 @@ class VoiceChatBlobNode: ASDisplayNode { case speaking case active case connecting + case mutedForYou case muted } private let size: CGSize @@ -978,6 +983,8 @@ class VoiceChatBlobNode: ASDisplayNode { targetColors = [lightBlue.cgColor, blue.cgColor, blue.cgColor] case .connecting: targetColors = [lightBlue.cgColor, blue.cgColor, blue.cgColor] + case .mutedForYou: + targetColors = [pink.cgColor, destructiveColor.cgColor, destructiveColor.cgColor] case .muted: targetColors = [pink.cgColor, purple.cgColor, purple.cgColor] } diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatTileItemNode.swift b/submodules/TelegramCallsUI/Sources/VoiceChatTileItemNode.swift index 9fef829ff6..a8462820c8 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatTileItemNode.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatTileItemNode.swift @@ -191,9 +191,7 @@ final class VoiceChatTileItemNode: ASDisplayNode { gesture.cancel() return } - if item.videoReady { - contextAction(strongSelf.contextSourceNode, gesture) - } + contextAction(strongSelf.contextSourceNode, gesture) } self.contextSourceNode.willUpdateIsExtractedToContextPreview = { [weak self] isExtracted, transition in guard let strongSelf = self, let _ = strongSelf.item else { @@ -218,7 +216,7 @@ final class VoiceChatTileItemNode: ASDisplayNode { } @objc private func tap() { - if let item = self.item, item.videoReady { + if let item = self.item { item.action() } } @@ -276,9 +274,7 @@ final class VoiceChatTileItemNode: ASDisplayNode { if self.item != item { let previousItem = self.item self.item = item - - self.containerNode.isGestureEnabled = item.videoReady - + if !item.videoReady { let shimmerNode: VoiceChatTileShimmeringNode if let current = self.shimmerNode { @@ -502,7 +498,7 @@ class VoiceChatTileHighlightNode: ASDisplayNode { enum Gradient { case speaking case active - case connecting + case mutedForYou case muted } @@ -632,8 +628,8 @@ class VoiceChatTileHighlightNode: ASDisplayNode { targetColors = [activeBlue.cgColor, green.cgColor, green.cgColor] case .active: targetColors = [lightBlue.cgColor, blue.cgColor, blue.cgColor] - case .connecting: - targetColors = [lightBlue.cgColor, blue.cgColor, blue.cgColor] + case .mutedForYou: + targetColors = [pink.cgColor, destructiveColor.cgColor, destructiveColor.cgColor] case .muted: targetColors = [pink.cgColor, purple.cgColor, purple.cgColor] } diff --git a/submodules/TgVoipWebrtc/tgcalls b/submodules/TgVoipWebrtc/tgcalls index 721a34e339..e75e19b1de 160000 --- a/submodules/TgVoipWebrtc/tgcalls +++ b/submodules/TgVoipWebrtc/tgcalls @@ -1 +1 @@ -Subproject commit 721a34e3392f44f10669b9286ec69af3563660a9 +Subproject commit e75e19b1ded7a8512d50b6e0be83408376ca0838