Video Chat Improvements

This commit is contained in:
Ilya Laktyushin
2021-05-27 12:29:02 +04:00
parent 517b858168
commit 7b2ee7ac11
6 changed files with 26 additions and 20 deletions

View File

@@ -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 {

View File

@@ -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)

View File

@@ -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)

View File

@@ -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]
}

View File

@@ -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]
}